📄 yosamabin_n60$gamecanvas.java
字号:
import com.nokia.mid.ui.DirectGraphics;
import com.nokia.mid.ui.DirectUtils;
import com.nokia.mid.ui.FullCanvas;
import java.util.Random;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class GameCanvas extends FullCanvas
{
private final YosamaBin_N60 this$0;
public GameCanvas()
{
this.this$0 = paramYosamaBin_N60;
}
public void paint()
{
if (!(this.this$0.checkPause))
{
YosamaBin_N60.game = 1;
YosamaBin_N60.gameend = 0;
DirectGraphics localDirectGraphics = DirectUtils.getDirectGraphics(paramGraphics);
this.this$0.gcounter += 1;
paramGraphics.drawImage(this.this$0.bg, 0, 0, 0x10 | 0x4);
if (!(this.this$0.levelchanged))
{
this.this$0.drawstones(paramGraphics);
if (this.this$0.weight >= 200)
this.this$0.motion = 3;
if (this.this$0.weight >= 400)
this.this$0.motion = 2;
if (this.this$0.hit)
{
if (this.this$0.hitcount == 1)
this.this$0.playsnd(5);
if (this.this$0.side == 1)
{
this.this$0.bullet1x = -50;
this.this$0.bullet2x = -50;
}
else
{
this.this$0.bullet1x = (YosamaBin_N60.w + 50);
this.this$0.bullet2x = (YosamaBin_N60.w + 50);
}
this.this$0.up = false;
this.this$0.down = false;
this.this$0.left = false;
this.this$0.right = false;
this.this$0.hitcount += 1;
if (this.this$0.hitcount < 5)
{
paramGraphics.drawImage(this.this$0.imhit, this.this$0.yosamax - 30, this.this$0.yosamay - 25, 0x10 | 0x4);
}
else
{
if (this.this$0.hitcount % 2 == 0)
this.this$0.yosamamov(paramGraphics, localDirectGraphics);
if (this.this$0.hitcount >= 20)
{
this.this$0.hit = false;
this.this$0.lives -= 1;
this.this$0.hitcount = 0;
}
}
}
else
{
this.this$0.yosamamov(paramGraphics, localDirectGraphics);
if (this.this$0.dropsanim == 1)
{
if (this.this$0.dir == 2)
paramGraphics.drawImage(this.this$0.drops[1], this.this$0.yosamax + this.this$0.stand[1].getWidth(), this.this$0.yosamay + 10, 0x10 | 0x4);
else
paramGraphics.drawImage(this.this$0.drops[4], this.this$0.yosamax - this.this$0.stand[1].getWidth() / 2, this.this$0.yosamay + 10, 0x10 | 0x4);
this.this$0.dropsanim += 1;
}
else if (this.this$0.dropsanim == 2)
{
if (this.this$0.dir == 2)
paramGraphics.drawImage(this.this$0.drops[2], this.this$0.yosamax + this.this$0.stand[1].getWidth(), this.this$0.yosamay + 10, 0x10 | 0x4);
else
paramGraphics.drawImage(this.this$0.drops[5], this.this$0.yosamax - this.this$0.stand[1].getWidth() / 2, this.this$0.yosamay + 10, 0x10 | 0x4);
this.this$0.dropsanim += 1;
}
else if (this.this$0.dropsanim == 3)
{
if (this.this$0.dir == 2)
paramGraphics.drawImage(this.this$0.drops[3], this.this$0.yosamax + this.this$0.stand[1].getWidth(), this.this$0.yosamay + 10, 0x10 | 0x4);
else
paramGraphics.drawImage(this.this$0.drops[6], this.this$0.yosamax - this.this$0.stand[1].getWidth() / 2, this.this$0.yosamay + 10, 0x10 | 0x4);
this.this$0.dropsanim = 0;
}
}
if (this.this$0.points > 0)
{
paramGraphics.setColor(255, 0, 0);
paramGraphics.setFont(Font.getFont(0, 1, 8));
paramGraphics.drawString("" + this.this$0.points, this.this$0.pointx, this.this$0.pointy, 0x10 | 0x4);
this.this$0.pcount += 1;
this.this$0.pointy -= 8;
if (this.this$0.pcount % 2 == 0)
this.this$0.pointx += 4;
else
this.this$0.pointx -= 4;
if (this.this$0.pcount >= 10)
{
this.this$0.points = 0;
this.this$0.pointx = (this.this$0.pointy = 0);
this.this$0.pcount = 0;
}
}
if (YosamaBin_N60.level >= 3)
{
if ((((this.this$0.man1x >= YosamaBin_N60.w) || (this.this$0.man1x <= -this.this$0.sol[4].getWidth()))) && (((this.this$0.man2x <= -this.this$0.sol[1].getWidth()) || (this.this$0.man2x >= YosamaBin_N60.w))))
if (this.this$0.gap >= 50)
{
this.this$0.side = (this.this$0.rd.nextInt() % 2);
if (this.this$0.side < 0)
this.this$0.side = (-this.this$0.side);
this.this$0.side += 1;
this.this$0.k = (this.this$0.rd.nextInt() % 10);
if (this.this$0.k < 0)
this.this$0.k = (-this.this$0.k);
if (this.this$0.k <= 4)
{
this.this$0.m1visible = true;
this.this$0.wait1 = 0;
this.this$0.k = 0;
if (this.this$0.side == 1)
{
this.this$0.bullet1x = (YosamaBin_N60.w + 50);
this.this$0.man1x = YosamaBin_N60.w;
}
else
{
this.this$0.bullet1x = -50;
this.this$0.man1x = (-this.this$0.sol[4].getWidth());
}
}
else
{
this.this$0.m2visible = true;
this.this$0.wait2 = 0;
this.this$0.k = 1;
if (this.this$0.side == 1)
{
this.this$0.bullet2x = (YosamaBin_N60.w + 50);
this.this$0.man2x = YosamaBin_N60.w;
}
else
{
this.this$0.bullet2x = -50;
this.this$0.man2x = (-this.this$0.sol[1].getWidth());
}
}
this.this$0.gap = 0;
}
else
{
this.this$0.gap += 1;
}
if (this.this$0.k == 0)
this.this$0.man1(paramGraphics, localDirectGraphics);
else
this.this$0.man2(paramGraphics, localDirectGraphics);
}
if (YosamaBin_N60.level == 2)
{
if ((this.this$0.man1x >= YosamaBin_N60.w) || (this.this$0.man1x <= -this.this$0.sol[4].getWidth()))
if (this.this$0.gap >= 50)
{
this.this$0.side = (this.this$0.rd.nextInt() % 2);
if (this.this$0.side < 0)
this.this$0.side = (-this.this$0.side);
this.this$0.side += 1;
this.this$0.k = (this.this$0.rd.nextInt() % 2);
if (this.this$0.k < 0)
this.this$0.k = (-this.this$0.k);
if (this.this$0.k == 1)
{
this.this$0.m1visible = true;
this.this$0.wait1 = 0;
if (this.this$0.side == 1)
{
this.this$0.bullet1x = (YosamaBin_N60.w + 50);
this.this$0.man1x = YosamaBin_N60.w;
}
else
{
this.this$0.bullet1x = -50;
this.this$0.man1x = (-this.this$0.sol[4].getWidth());
}
}
this.this$0.gap = 0;
}
else
{
this.this$0.gap += 1;
}
if (this.this$0.k == 1)
this.this$0.man1(paramGraphics, localDirectGraphics);
}
if (YosamaBin_N60.level > 3)
this.this$0.para(paramGraphics);
if ((this.this$0.pieces >= 20) && (YosamaBin_N60.level < 4))
{
YosamaBin_N60.level += 1;
YosamaBin_N60.score = this.this$0.weight;
this.this$0.levelchanged = true;
}
}
else
{
this.this$0.right = true;
this.this$0.up = false;
this.this$0.down = false;
this.this$0.left = false;
this.this$0.yosamamov(paramGraphics, localDirectGraphics);
paramGraphics.setColor(255, 255, 255);
paramGraphics.fillRoundRect(YosamaBin_N60.w / 2 - 60, YosamaBin_N60.h / 2 - 50, 120, 60, 20, 20);
paramGraphics.setColor(0, 0, 0);
paramGraphics.fillRoundRect(YosamaBin_N60.w / 2 - 60 + 2, YosamaBin_N60.h / 2 - 50 + 2, 116, 56, 20, 20);
paramGraphics.setColor(255, 0, 0);
paramGraphics.drawString("Proceed to", YosamaBin_N60.w / 2, YosamaBin_N60.h / 2 - 35, 0x10 | 0x1);
paramGraphics.drawString("Level " + YosamaBin_N60.level, YosamaBin_N60.w / 2, YosamaBin_N60.h / 2 - 15, 0x10 | 0x1);
if (this.this$0.yosamax >= YosamaBin_N60.w + 10)
{
this.this$0.yosamax = (-this.this$0.stand[1].getWidth());
this.this$0.maround = true;
}
if ((this.this$0.maround) && (this.this$0.yosamax >= 65))
{
this.this$0.levelchanged = false;
this.this$0.levelch();
}
}
if (this.this$0.lives <= 0)
{
YosamaBin_N60.score = this.this$0.weight;
this.this$0.End();
}
paramGraphics.setColor(8720666);
paramGraphics.setFont(Font.getFont(0, 1, 8));
paramGraphics.drawString("" + this.this$0.weight, 45, 3, 0x10 | 0x4);
paramGraphics.drawString("" + this.this$0.lives, YosamaBin_N60.w - 2, 3, 0x10 | 0x8);
YosamaBin_N60.score = this.this$0.weight;
YosamaBin_N60.gamePaint = (byte)(YosamaBin_N60.gamePaint + 1);
if (YosamaBin_N60.gamePaint >= 2)
YosamaBin_N60.gamePaint = 2;
}
else
{
paramGraphics.setFont(Font.getFont(0, 1, 0));
paramGraphics.setColor(255, 255, 255);
paramGraphics.fillRect(0, YosamaBin_N60.h / 2 - 10, YosamaBin_N60.w, 20);
paramGraphics.setColor(255, 0, 0);
paramGraphics.drawString("PAUSED", YosamaBin_N60.w / 2, YosamaBin_N60.h / 2 - 5, 17);
}
}
public void scroll()
{
repaint();
}
public void keyPressed()
{
switch (getGameAction(paramInt))
{
case 8:
if (this.this$0.checkPause)
return;
this.this$0.fire = true;
break;
case 1:
if (this.this$0.checkPause)
return;
this.this$0.up = true;
this.this$0.janim = 0;
break;
case 6:
if (this.this$0.checkPause)
return;
this.this$0.down = true;
this.this$0.danim = 0;
break;
case 2:
if (this.this$0.checkPause)
return;
this.this$0.left = true;
this.this$0.wanim = 0;
break;
case 5:
if (this.this$0.checkPause)
return;
this.this$0.right = true;
this.this$0.wanim = 0;
break;
case 3:
case 4:
case 7:
default:
if ((paramInt == -6) && (!(this.this$0.checkPause)))
{
YosamaBin_N60.gamePaint = 0;
YosamaBin_N60.a = 15;
this.this$0.display.setCurrent(this.this$0.intro);
}
if (paramInt == -7)
{
this.this$0.checkPause = (this.this$0.checkPause != true);
repaint();
}
if ((paramInt != 48) || (this.this$0.checkPause))
return;
}
}
public void keyReleased()
{
switch (getGameAction(paramInt))
{
case 2:
if (this.this$0.checkPause)
return;
this.this$0.left = false;
break;
case 5:
if (this.this$0.checkPause)
return;
this.this$0.right = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -