📄 arkanoidcanvas.java
字号:
import com.nokia.mid.sound.Sound;
import com.nokia.mid.ui.FullCanvas;
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;
class ArkanoidCanvas extends FullCanvas implements Runnable {
public ArkanoidCanvas(Arkanoid arkanoid) {
Img_title = new Image[2];
Img_vouse = new Image[4];
Img_laser = new Image[2];
Img_wall = new Image[10];
Img_item = new Image[9];
Img_bg = new Image[2];
Img_doh = new Image[4];
Inst_item = new Image[9];
Doh_Inst = 0;
DohCount = 0;
Miss_Flag = false;
RoundClearFlag = false;
Scene = 0;
Back_Scene = 0;
Wd = new int[170];
Id = new int[36];
Rd = 1;
TRd = 1;
TRdv = 1;
CRd = 1;
Wc = 0;
Sc = 0;
Doh = 0;
HSc = 0;
Cd = 10;
Brf = 0;
Tn = 0;
Pm = 0;
Ltm = 0;
Dc = 0;
Mp = 0;
Vxp = 45;
Vxp0 = 45;
Vs = 20;
V = 0;
Vst = 0;
Vr = 3;
Tdx = new int[8];
Tdy = new int[8];
Txp = new int[8];
Typ = new int[8];
Txp0 = new int[8];
Typ0 = new int[8];
Lv = new int[8];
di = new int[8];
Pk = 0;
T = 5;
Re = 0;
Rix = new int[2];
Riy = new int[2];
Rin = new int[2];
next_item = 0;
Lix = new int[2];
Liy = new int[2];
Ll = new int[2];
Lh = new int[2];
Lt = 0;
Lc = 0;
DLx = new int[2];
DLy = new int[2];
DLxb = new int[2];
DLyb = new int[2];
DLT = 0;
Dlf = 1;
DLxe = 0;
DLye = 0;
AllKeyCode = 0;
Rnd = new Random();
All_Clear_Time = 0L;
Classic_Clear_Time = 0L;
ph = new Sound[13];
MenuCount = 0;
m_Game_Pause_Flg = false;
KeyInst = 0L;
KeyCount = 0L;
ContinueFlag = false;
Menu_Screen_Count = 0;
Round_Select_Count = 1;
InstCount = 0;
showNotifyFlg = false;
showNotifyCount = 0;
GameOverScene = 0;
laser_flg = 0;
try {
byte abyte0[] = new byte[2555];
byte abyte1[] = new byte[8138];
byte abyte2[] = new byte[7800];
DataInputStream datainputstream = null;
Ar = arkanoid;
LibVer = System.getProperty("microedition.profiles");
recordJob(false);
datainputstream = new DataInputStream(Class.forName("Arkanoid").
getResourceAsStream("image.dat"));
int k = datainputstream.readInt();
for (int i = 0; i < k; i++) {
int l = datainputstream.readInt();
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(
l);
datainputstream.readFully(abyte0, 0, l);
bytearrayoutputstream.write(abyte0, 0, l);
if (i < 2) {
Img_title[i] = Image.createImage(bytearrayoutputstream.toByteArray(),
0, l);
} else
if (i < 4) {
Img_bg[i -
2] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 8) {
Img_doh[i -
4] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 17) {
Img_item[i -
8] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 19) {
Img_laser[i -
17] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 23) {
Img_vouse[i -
19] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 33) {
Img_wall[i -
23] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 34) {
Img_icon = Image.createImage(bytearrayoutputstream.toByteArray(), 0,
l);
} else
if (i < 43) {
Inst_item[i -
34] = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
} else
if (i < 44) {
Arrow = Image.createImage(bytearrayoutputstream.toByteArray(), 0, l);
}
bytearrayoutputstream.close();
}
datainputstream.close();
BGbuf = Image.createImage(100, 130);
SCbuf = Image.createImage(176, 208);
BGg = BGbuf.getGraphics();
SCg = SCbuf.getGraphics();
datainputstream = new DataInputStream(Class.forName("Arkanoid").
getResourceAsStream("sound.dat"));
k = datainputstream.readInt();
for (int j = 0; j < k; j++) {
int i1 = datainputstream.readInt();
ByteArrayOutputStream bytearrayoutputstream1 = new
ByteArrayOutputStream(i1);
datainputstream.readFully(abyte2, 0, i1);
bytearrayoutputstream1.write(abyte2, 0, i1);
ph[j] = new Sound(bytearrayoutputstream1.toByteArray(), 1);
bytearrayoutputstream1.close();
}
datainputstream.close();
runner = new Thread(this);
runner.start();
} catch (Exception exception) {
System.out.println("ArkanoidCanvas Constructor ERROR: " + exception);
exception.printStackTrace();
}
}
protected synchronized void recordJob(boolean flag) {
Object obj = null;
Object obj1 = null;
Object obj3 = null;
try {
RecordStore recordstore = RecordStore.openRecordStore("Arkanoid", true);
if (recordstore.getNumRecords() == 0) {
String s = Integer.toString(HSc);
byte abyte0[] = s.getBytes();
recordstore.addRecord(abyte0, 0, abyte0.length);
s = Integer.toString(TRd);
abyte0 = s.getBytes();
recordstore.addRecord(abyte0, 0, abyte0.length);
s = Integer.toString(Pm);
abyte0 = s.getBytes();
recordstore.addRecord(abyte0, 0, abyte0.length);
s = Integer.toString(TRdv);
abyte0 = s.getBytes();
recordstore.addRecord(abyte0, 0, abyte0.length);
} else
if (flag) {
String s1 = Integer.toString(HSc);
byte abyte1[] = s1.getBytes();
recordstore.setRecord(1, abyte1, 0, abyte1.length);
s1 = Integer.toString(TRd);
abyte1 = s1.getBytes();
recordstore.setRecord(2, abyte1, 0, abyte1.length);
s1 = Integer.toString(Pm);
abyte1 = s1.getBytes();
recordstore.setRecord(3, abyte1, 0, abyte1.length);
s1 = Integer.toString(TRdv);
abyte1 = s1.getBytes();
recordstore.setRecord(4, abyte1, 0, abyte1.length);
} else
if (!flag) {
byte abyte2[] = recordstore.getRecord(1);
HSc = Integer.parseInt(new String(abyte2));
abyte2 = recordstore.getRecord(2);
TRd = Integer.parseInt(new String(abyte2));
abyte2 = recordstore.getRecord(3);
Pm = Integer.parseInt(new String(abyte2));
abyte2 = recordstore.getRecord(4);
TRdv = Integer.parseInt(new String(abyte2));
}
recordstore.closeRecordStore();
recordstore = null;
Object obj2 = null;
Object obj4 = null;
} catch (Exception exception) {}
}
public void ini() {
Brf = 0;
Tn = 0;
Pk = 0;
Vxp = 45;
Vxp0 = 45;
Vs = 20;
T = 5;
KeyInst = 0L;
V = 0;
Vst = 0;
Re = 0;
DLT = 0;
Dc = 0;
Tdx[0] = 1;
Tdy[0] = -1;
Txp0[0] = 55;
Typ0[0] = 122;
Txp[0] = 55;
Typ[0] = 122;
di[0] = 5;
Lv[0] = 1;
for (int i = 1; i < 8; i++) {
Tdx[i] = 0;
Tdy[i] = 0;
Txp0[i] = 0;
Typ0[i] = 0;
Txp[i] = 0;
Typ[i] = 0;
di[i] = 0;
Lv[i] = 0;
}
Riy[0] = 0;
Riy[1] = 0;
Liy[0] = 0;
Liy[1] = 0;
Ll[0] = 0;
Ll[1] = 0;
Lt = 0;
Lc = 0;
Lh[0] = 5;
Lh[1] = 5;
}
protected synchronized void keyPressed(int i) {
int j = i;
if (j < 0) {
j = getGameAction(i);
}
if (j != 49) {
if (j == 50 && Scene == 15) {
AllKeyCode |= 0x200;
} else
if (j == 1 && Scene == 15) {
AllKeyCode |= 0x200;
} else
if (j == 2 || j == 52) {
AllKeyCode |= 4;
} else
if (j == 5 || j == 53 || j == 54) {
AllKeyCode |= 8;
} else
if (j == 55) {
AllKeyCode |= 0x200;
} else
if (j == 57) {
AllKeyCode |= 0x800;
} else
if (j == 8) {
AllKeyCode |= 0x10;
} else
if (j == 1) {
AllKeyCode |= 1;
} else
if (j == 6) {
AllKeyCode |= 2;
} else
if (j == 35) {
AllKeyCode |= 0x10000;
} else
if (j == 42) {
AllKeyCode |= 0x8000;
}
}
if (Scene != 40) {
if (Scene == 1000) {
if (i == -1) {
Menu_Screen_Count--;
if (Menu_Screen_Count < 0) {
Menu_Screen_Count = 0;
}
} else
if (i == -2) {
Menu_Screen_Count++;
if (!ContinueFlag) {
if (Menu_Screen_Count > 4) {
Menu_Screen_Count = 4;
}
} else
if (ContinueFlag && Menu_Screen_Count > 5) {
Menu_Screen_Count = 5;
}
} else
if (i == -7) {
Scene = 0;
if (Menu_Screen_Count == 5) {
Menu_Screen_Count = 4;
}
ContinueFlag = false;
} else
if (i == -6 || i == -5) {
i = -6;
if (!ContinueFlag) {
if (Menu_Screen_Count == 0) {
SetRound1();
set_newgame();
ContinueFlag = true;
} else
if (Menu_Screen_Count == 1) {
Scene = 1010;
} else
if (Menu_Screen_Count == 2) {
Scene = 1020;
} else
if (Menu_Screen_Count == 3) {
Scene = 1030;
} else
if (Menu_Screen_Count == 4) {
Scene = 1040;
}
} else
if (ContinueFlag) {
if (Menu_Screen_Count == 0) {
Scene = Back_Scene;
} else
if (Menu_Screen_Count == 1) {
SetRound1();
set_newgame();
} else
if (Menu_Screen_Count == 2) {
Scene = 1010;
} else
if (Menu_Screen_Count == 3) {
Scene = 1020;
} else
if (Menu_Screen_Count == 4) {
Scene = 1030;
} else
if (Menu_Screen_Count == 5) {
Scene = 1040;
}
}
}
} else
if (Scene == 1010) {
if (i == -1) {
RoundSelectDown();
} else
if (i == -2) {
RoundSelectUp();
} else
if (i == -7) {
Scene = 1000;
} else
if (i == -6 || i == -5) {
set_newgame();
ContinueFlag = true;
Menu_Screen_Count = 0;
}
} else
if (Scene == 1020) {
if (i == -6 || i == -5) {
if (Pm == 0) {
Pm = 1;
} else
if (Pm == 1) {
Pm = 0;
}
} else
if (i == -7) {
Scene = 1000;
}
} else
if (Scene == 1030) {
if (i == -6 || -2 == i) {
InstCount++;
if (InstCount > 4) {
InstCount = 0;
}
} else
if (i == -1) {
InstCount--;
if (InstCount < 0) {
InstCount = 4;
}
} else
if (i == -7) {
Scene = 1000;
}
} else
if (Scene == 1040) {
if (i == -7) {
Scene = 1000;
}
} else
if (i == -6) {
PauseGame();
if (15 == Scene || 50 == Scene) {
TRdv++;
if (TRd <= TRdv) {
TRdv = TRd;
}
ContinueFlag = true;
} else
if (Scene == 30 || Scene == 35) {
ContinueFlag = false;
}
Scene = 1000;
} else
if (i == -7) {
if (5 == Scene) {
Ar.destroyApp(false);
Ar.notifyDestroyed();
} else
if (15 == Scene || 50 == Scene) {
Scene = 0;
ContinueFlag = false;
} else
if (35 == Scene) {
ContinueGame();
}
}
}
}
private void StartNewGame1() {
SetRound1();
set_newgame();
StartGame();
}
protected synchronized void keyReleased(int i) {
int k = i;
if (k < 0) {
k = getGameAction(i);
}
if (k == 2 || k == 52) {
AllKeyCode &= -5;
V = 0;
} else
if (k == 5 || k == 53 || k == 54) {
AllKeyCode &= -9;
V = 0;
} else
if (k == 8 || k == 1 && Scene == 15 || k == 50 || k == 55 || k == 57) {
AllKeyCode &= 0xfffff5ef;
if (Scene == 15 && Vst == 4) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -