📄 gogo.java
字号:
import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class GoGo extends Canvas implements Runnable {
Go go;
boolean G9huizhi = true;
Image tu[] = new Image[9];
boolean an[] = new boolean[9];
int y = 0;
public GoGo(Go go) {
go = go;
try {
for (int i = 0; i < 9; i++) {
tu[i] = Image.createImage("/0" + (i + 1) + ".png");
}
} catch (IOException e) {
}
Thread tt = new Thread(this);
tt.start();
}
protected void paint(Graphics g) {
g.setColor(0);
g.fillRect(0, 0, 180, 180);
g.setClip(0, 0, 180, 180);
if (G9huizhi) {
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 3; i++) {
g.drawImage(tu[i + j * 3], i * 60, 0 + j * 60, 0);
}
}
}
move(g);
}
public void run() {
while (true) {
repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}
public void move(Graphics g) {
for (int i = 0; i < 9; i++) {
if (an[i]) {
G9huizhi = false;
g.setColor(255, 0, 0);
g.drawString("第" + (i + 1) + "事件启动", 50, 50, 0);
}
}
}
protected void keyPressed(int k) {
if (!G9huizhi) {
G9huizhi = true;
for (int i = 0; i < 9; i++) {
an[i] = false;
}
return;
}
if (getGameAction(k) == GAME_A) {
an[0] = true;
}
if (getGameAction(k) == GAME_B) {
an[2] = true;
}
if (getGameAction(k) == GAME_C) {
an[6] = true;
}
if (getGameAction(k) == GAME_D) {
an[8] = true;
}
if (getGameAction(k) == UP) {
an[1] = true;
}
if (getGameAction(k) == DOWN) {
an[7] = true;
}
if (getGameAction(k) == RIGHT) {
an[5] = true;
}
if (getGameAction(k) == LEFT) {
an[3] = true;
}
if (getGameAction(k) == FIRE) {
an[4] = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -