📄 battle_on_the_river_kwai_n60.java
字号:
expcnt--;
}
}
drawbg(g, IN_Game);
drawgrid(g);
for (int i = 0; i < t.length; i++) {
if (t[i] == null) {
switch (lv) {
case 1:
t[i] = new Troops(g,
ranno(1, 5) * 30 +
ranno(1, 15),
ranno(15, 18),
react_tim[level] + i * 4, -10,
-10);
break;
case 2:
t[i] = new Troops(g,
ranno(3, 5) * 25 +
ranno(40, 50), ranno(100, 105),
react_tim[level] + i * 4, -50,
-50);
break;
case 3:
t[i] = new Troops(g,
ranno(1, 5) * 9 + ranno(1, 5),
ranno(70, 80),
react_tim[level] + i * 4, -50,
-50);
break;
}
} else {
t[i].move(g);
}
}
if (lv < 2) {
g.drawImage(fg, 0, 93, Graphics.TOP | Graphics.LEFT);
}
tt = 0;
while (tt < t.length && t[tt] != null) {
if (gun == 1) {
//System.out.println("cx: "+cx+" cy: "+cy+" t[tt].tx: "+(t[tt].tx)+" t[tt].ty: "+(t[tt].ty));//+" t[tt].ty-t[tt].esh:"+(t[tt].ty-t[tt].esh)+" t[tt].ty-20:"+(t[tt].ty-20));
if (cx >= t[tt].tx - 5 && cx <= t[tt].tx + 5 &&
cy <= t[tt].ty - 2 && cy >= t[tt].ty - 30 &&
(t[tt].alive == true)) {
//System.out.println("killllllllllllllllllled");
kill++;
score = score + 10;
enemy--;
if (enemy == 0) {
level++;
islv = true;
}
// if(kill>=9)
// {
// level++;
// kill=0;//score+=scorel;
// }
t[tt].alive = false;
gun = 0;
//break;
}
//System.out.println(grid[getrow(cx,cy)][getcol(cx,cy)]);
switch (grid[getrow(cx, cy)][getcol(cx, cy)]) {
case 0:
grass_shot(g, cx, cy);
break;
case 1:
water_shot(g, cx, cy);
break;
case 2:
grass_shot(g, cx, cy);
break;
}
g.drawImage(target, cx, cy - 5,
Graphics.HCENTER | Graphics.VCENTER);
}
//
if (gun == 0) {
g.drawImage(target, cx, cy,
Graphics.HCENTER | Graphics.VCENTER);
}
if (life == 0 && t[tt].alive == true && i_am_dead == false) {
playsnd(3);
i_am_dead = true;
// g.drawImage(gbreak, w / 2, 0,
// Graphics.TOP | Graphics.HCENTER);
}
if (t[tt].dc > 7 && t[tt].alive == false) {
// System.out.println("Troop got KILLED tt: "+tt+" t[tt].tx: "+t[tt].tx+" t[tt].ty: "+t[tt].ty+" t[tt].alive: "+t[tt].alive+" t[tt].react_ctr: "+t[tt].react_ctr);
switch (lv) {
case 1:
t[tt] = new Troops(g,
ranno(1, 5) * ranno(20, 30) +
ranno(1, 15), ranno(15, 18),
react_tim[level] + tt * 3, -10, -10);
break;
case 2:
t[tt] = new Troops(g,
ranno(3, 5) * ranno(20, 25) +
ranno(40, 50), ranno(120, 125),
react_tim[level] + tt * 3, -50, -50);
break;
case 3:
t[tt] = new Troops(g,
ranno(1, 5) * ranno(1, 8) + ranno(1, 5),
ranno(70, 80),
react_tim[level] + tt * 3, -50, -50);
break;
}
// System.out.println("Troop reinitialized: "+tt+" t[i].tx: "+t[i].tx+" t[i].ty: "+t[i].ty+" t[i].alive: "+t[i].alive +" t[tt].react_ctr: "+t[tt].react_ctr);
}
if (i_am_dead == true) {
if (gc % 2 == 0) {
tindex++;
}
if (tindex < 15) {
// g.drawImage(gbreak, w / 2, 0,
// Graphics.TOP | Graphics.HCENTER);
} else {
End();
}
}
// System.out.println("enemy position:" +t[tt].tx+"/"+t[tt].ty);
tt++;
}
tt = 0;
gun = 0;
/**/
//alion
if (lv == 3) {
for (int i = 0; i < al.length; i++) {
al[i].allian(g, t[i].tx);
}
}
if (gc % 3 == 0) {
anim++;
}
if (anim >= 4) {
anim = 0;
}
if (tt >= t.length) {
tt = 0;
}
//show Score level
drawState(g, lv, showTime((time + stime)).substring(3));
gamePaint++;
if (gamePaint >= 2) {
gamePaint = 2;
}
} else {
g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
Font.SIZE_MEDIUM));
g.setColor(255, 255, 255);
g.fillRect(0, h / 2 - 10, w, 20);
g.setColor(0, 0, 0);
g.drawString("PAUSED", w / 2, (h / 2) - 5,
Graphics.TOP | Graphics.HCENTER);
}
}
}
public void grass_shot(Graphics g, int gx, int gy) {
if (anim == 1) {
g.drawImage(shotanim[anim - 1], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
} else if (anim == 2) {
g.drawImage(shotanim[anim - 1], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
} else if (anim == 3) {
g.drawImage(shotanim[anim - 1], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
}
}
public void water_shot(Graphics g, int gx, int gy) {
if (anim == 1) {
g.drawImage(shotanim[anim + 2], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
} else if (anim == 2) {
g.drawImage(shotanim[anim + 2], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
} else if (anim == 3) {
g.drawImage(shotanim[anim + 2], gx, gy,
Graphics.BOTTOM | Graphics.HCENTER);
}
}
public void keyPressed(int keyCode) {
switch (getGameAction(keyCode)) {
case RIGHT:
if (!checkPause && i_am_dead == false) {
rt = 1;
lf = 0;
uup = 0;
dn = 0;
}
break;
case LEFT:
if (!checkPause && i_am_dead == false) {
lf = 1;
rt = 0;
uup = 0;
dn = 0;
}
break;
case UP:
if (!checkPause && i_am_dead == false) {
uup = 1;
lf = 0;
rt = 0;
dn = 0;
}
if (prevl) {
page--;
}
break;
case DOWN:
if (!checkPause && i_am_dead == false) {
dn = 1;
lf = 0;
uup = 0;
rt = 0;
}
if (prevl) {
page++;
}
break;
case FIRE:
i_bloodNum = 0;
if (!checkPause && gun == 0 && i_am_dead == false) {
//End();
playsnd(1);
gun = 1;
//System.out.println("Gun:="+gun);
}
if (prevl) {
prevl = false;
}
if (islv) {
if (lv == 3) {
End();
} else {
initwater();
System.out.println("gamecanvas");
if (lv < 3) {
lv++;
}
init_all_var(lv);
islv = false;
}
}
break;
default:
if (keyCode == KEY_SOFTKEY1 && !checkPause) {
// System.out.println("KEY_SOFTKEY1 start a="+a);
gamePaint = 0;
if (game == 1) {
a = 9;
} else {
a = 2;
}
no = 1;
// System.out.println("KEY_SOFTKEY1 end a=" +a);
display.setCurrent(intro);
}
if (keyCode == KEY_SOFTKEY2) {
checkPause = (checkPause == true ? false : true);
// System.out.println("softkey2 set checkPause");
repaint();
}
if (keyCode == KEY_NUM0 && !checkPause) {
}
break;
}
}
public void keyReleased(int keyCode) {
switch (getGameAction(keyCode)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -