📄 bomb.java
字号:
// Bomb class
import javax.microedition.lcdui.*;
class Bomb
{
public int x;
public int y;
public int oldX;
public int oldY;
public int width;
public int height;
public int status;
public int dropDistance;
public int strength;
public boolean redraw; // Redraw the backgound
public int columnHit; // City column hit (Used to redraw the broken block after background redraw)
public int maxDrop;
public int xOffset;
public int yOffset;
Bomb()
{
this.init();
}
void init()
{
this.x = 0;
this.y = 0;
this.oldX = this.x;
this.oldY = this.y;
this.width = 0;
this.height = 0;
this.dropDistance = 0;
this.columnHit = -1;
this.xOffset = 0;
this.yOffset = 0;
}
void setSize(int xSize, int ySize, int iDrop, int xOff, int yOff)
{
this.width = xSize;
this.height = ySize;
this.dropDistance = iDrop;
this.xOffset = xOff;
this.yOffset = yOff;
}
// Drop a bomb in if available
void drop(int dropX, int dropY)
{
if (this.status != 0) return;
dropX /= this.width;
dropX++;
dropX *= this.width;
this.status = 1;
this.x = dropX + this.xOffset;
this.y = dropY + this.yOffset;
this.strength = 4;
this.oldX = this.x;
this.oldY = this.y;
this.columnHit = -1;
}
// Move the bomb down the screen
void move()
{
if (this.status == 0) return;
// Save the location and set redraw background to true
this.oldX = this.x;
this.oldY = this.y;
this.redraw = true;
// Move the bomb
this.y += dropDistance;
if (this.y > maxDrop) this.status = 0;
}
void killBomb()
{
// Save the location and set redraw background to true
this.oldX = this.x;
this.oldY = this.y;
this.redraw = true;
this.status = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -