diff --git a/Military-Hero-Core/src/com/annimon/militaryhero/MainApp.java b/Military-Hero-Core/src/com/annimon/militaryhero/MainApp.java index 6a77419..3798d89 100644 --- a/Military-Hero-Core/src/com/annimon/militaryhero/MainApp.java +++ b/Military-Hero-Core/src/com/annimon/militaryhero/MainApp.java @@ -21,16 +21,20 @@ public class MainApp extends InputProcessor implements ApplicationListener { private Background background; private SniperAim aim; private Enemy[] enemies; + private int enemiesLeft; public void onStartApp(int width, int height) { this.width = width; this.height = height; background = new Background(); aim = new SniperAim(width, height); + enemies = new Enemy[COORD.length / 2]; for (int i = 0; i < enemies.length; i++) { enemies[i] = new Enemy(COORD[i * 2], COORD[i * 2 + 1]); } + enemiesLeft = enemies.length; + Jecp.inputListener = this; Keys.numericdAsDpad = true; Keys.wasdAsDpad = true; @@ -65,6 +69,16 @@ public class MainApp extends InputProcessor implements ApplicationListener { } public void isFirePressed() { - + if (enemiesLeft == 0) return; + + final int x = aim.getAimX(); + final int y = aim.getAimY(); + int counter = 0; + for (int i = 0; i < enemies.length; i++) { + if (enemies[i].isVisible() && !enemies[i].isCollide(x, y)) { + counter++; + } + } + enemiesLeft = counter; } }