public void move() { x += 2.0 * gamespeed * xdir; if (x < 0 + xPosition) { xdir = 1; } if (x > pfWidth() / 2 + xPosition - 44) { xdir = -1; } if ((int) x % 20 == 0) { if (bullets.size < 3) { long timeNow = System.currentTimeMillis(); if (timeNow - lastBullet > 300) { JGObject bullet = new JGObject("bullet", true, x - 8, y - 8, 4, "bullet", 0, -14, -2); bullets.put(bullet.getName(), bullet); playAudio("shoot"); lastBullet = timeNow; } } } for (int i = 0; i < bullets.size; i++) { JGObject obj = (JGObject) bullets.values[i]; if (!obj.isAlive()) { bullets.remove(obj.getName()); } } }
public void move() { if (getKey(KeyLeft) && x > 14) { x -= 14 * gamespeed; } if (getKey(KeyUp) && y > 14) { y -= 14 * gamespeed; } if (getKey(KeyRight) && x < pfWidth() - 51 - 14) { x += 14 * gamespeed; } if (getKey(KeyDown) && y < pfHeight() - 51 - 14) { y += 14 * gamespeed; } if (getKey(' ')) { if (bullets.size < 2) { long timeNow = System.currentTimeMillis(); if (timeNow - lastBullet > 500) { JGObject bullet = new JGObject("bullet", true, x - 8, y - 8, 4, "bullet", 0, -14, -2); bullets.put(bullet.getName(), bullet); playAudio("shoot"); clearKey(' '); lastBullet = timeNow; } } } for (int i = 0; i < bullets.size; i++) { JGObject obj = (JGObject) bullets.values[i]; if (!obj.isAlive()) { bullets.remove(obj.getName()); } } }
public void hit(JGObject obj) { lostHP = 7; // drawImageString(lostHP + "", x - 5, y - 5, -1, "font_map", 32, 0); int avaiableHP = getHP() - lostHP; setHP(avaiableHP > 0 ? avaiableHP : 0); new JGObject("explo", true, x, y, 0, "explo", 0, 0, 32); if (getHP() <= 0) { remove(); addGameState("GameOver"); new JGTimer(100, true) { public void alarm() { startLevel(); } }; } else if (getHP() < 80 && getHP() > 70) { AutoPlayer player = new AutoPlayer(0, pfHeight() - 113); players.put(player.getName(), player); } else if (getHP() < 40 && getHP() > 30) { AutoPlayer player = new AutoPlayer(pfWidth() / 2, pfHeight() - 113); players.put(player.getName(), player); } else { enemies.remove(obj.getName()); obj.remove(); } }
public void hit(JGObject obj) { lostHP = 10; // drawImageString(lostHP + "", x - 5, y - 5, -1, "font_map", 32, 0); int avaiableHP = getHP() - lostHP; setHP(avaiableHP > 0 ? avaiableHP : 0); new JGObject("explo", true, x, y, 0, "explo", 0, 0, 32); if (getHP() <= 0) { remove(); } else { enemies.remove(obj.getName()); obj.remove(); } }
public void hit(JGObject obj) { if (invulnerability <= 0) { lifeLost(); obj.remove(); playAudio("playerexplo"); } }
public void hit(JGObject obj) { new JGObject("explo", true, x, y, 0, "explo", 0, 0, 32); playAudio("explo"); remove(); enemies.remove(getName()); obj.remove(); score += 5; }
public void hit(JGObject o) { playAudio("explo"); for (int i = 0; i < (isMidlet() ? 5 : 8); i++) new JGObject( "explo", true, x, y, 0, "explo", random(-2, 2), random(-2, 2), (int) random(8, 32)); o.remove(); remove(); score += 5; }
public void move() { if (to_follow != null) { // follow the player if (!to_follow.isAlive()) remove(); shiftPos(to_follow.x, to_follow.y); // JGPoint newpos = shiftPos(to_follow.getLastX(), // to_follow.getLastY() ); // x = newpos.x; // y = newpos.y; } }
public void hit(JGObject obj) { if (and(obj.colid, gp_playerdieobjtype) && invulnerability == 0) lifeLost(); if (and(obj.colid, gp_playergetobjtype)) { obj.remove(); score += gp_playergetscore; new StdScoring( "pts", obj.x, obj.y, 0, -1.0, 40, (int) gp_playergetscore + " pts", scoring_font, new JGColor[] {JGColor.red, JGColor.yellow}, 2); } }
public void hit(JGObject obj) { remove(); if (!and(obj.colid, 16)) { obj.remove(); if (obj instanceof Bat) { score += 10; } else if (obj instanceof Tank) { score += 20; } else { score += 5; } new Explo(x + 8, y + 8); if (isMidlet()) { playAudio("explo0"); } else { playAudio("explo" + random(0, 1, 1)); } } }
public void hit(JGObject obj) { if (and(obj.colid, dieobjtype)) { die(); if ((obj.colid & BULLETTYPE) != 0) obj.remove(); } }