?? 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 + -