📄 ufo.java
字号:
package game0925;
import javax.microedition.lcdui.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class UFO extends Sprite {
private Image ufoimg = null;
private Image ufomissimg = null;
protected int direction;
protected static final int DIR_LEFT = 0;
protected static final int DIR_RIGHT = 1;
protected int count;
protected int speed;
public UFO(int x, int y, int direction, boolean isAlive, int speed) {
if (ufoimg == null) {
ufoimg = ImageTools.getImage("/img/ufo.png");
ufomissimg = ImageTools.getImage("/img/burst.png");
}
this.speed = speed;
this.x = x;
this.y = y;
this.direction = direction;
this.isAlive = isAlive;
width = 11;
height = 11;
}
/**
* doMove
*
* @todo Implement this game0925.Sprite method
*/
protected void setDirection(int direction) {
this.direction = direction;
}
void doMove() {
if (this.isAlive()) {
switch (direction) {
case DIR_LEFT:
switch (speed) {
case 5:
x += 1;
break;
case 4:
x += 2;
break;
case 3:
x += 3;
break;
case 2:
x +=4;
break;
case 1:
x +=5;
break;
default:
x += 6;
break;
}
break;
case DIR_RIGHT:
switch (speed) {
case 5:
x -= 5;
break;
case 4:
x -= 6;
break;
case 3:
x -= 2;
break;
case 2:
x -= 1;
break;
case 1:
x -= 8;
break;
default:
x -= 3;
break;
}
break;
}
}
}
/**
* paint
*
* @param g Graphics
* @todo Implement this game0925.Sprite method
*/
void paint(Graphics g) {
if (this.isHit()) {
g.drawImage(ufomissimg, x, y, Graphics.TOP | Graphics.LEFT);
} else {
g.drawImage(ufoimg, x, y, Graphics.TOP | Graphics.LEFT);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -