From c11758d678cbca78dcc6536f84b1732d2671f5de Mon Sep 17 00:00:00 2001 From: JJTCM Date: Tue, 25 Nov 2014 15:00:37 +0100 Subject: [PATCH] Moved Enemy Spawn Debug (fix too many spawn issue) Debug for Player Position --- .../spacescooter/control/Keyboard.java | 34 +++++++++++++++++++ .../spacescooter/entity/Player.java | 7 ++++ 2 files changed, 41 insertions(+) diff --git a/src/de/teamteamteam/spacescooter/control/Keyboard.java b/src/de/teamteamteam/spacescooter/control/Keyboard.java index cb0d5b4..a6d3420 100644 --- a/src/de/teamteamteam/spacescooter/control/Keyboard.java +++ b/src/de/teamteamteam/spacescooter/control/Keyboard.java @@ -1,9 +1,16 @@ package de.teamteamteam.spacescooter.control; +import java.awt.Point; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.ArrayList; +import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss; +import de.teamteamteam.spacescooter.entity.enemy.EnemyFour; +import de.teamteamteam.spacescooter.entity.enemy.EnemyOne; +import de.teamteamteam.spacescooter.entity.enemy.EnemyThree; +import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo; + /** * This is our main control input source. * It accumulates pressed keys, so we can use them to do player movement and more. @@ -47,6 +54,13 @@ public class Keyboard implements KeyListener { public static boolean isKeyDown(int keyCode) { return Keyboard.activeKeys.contains((Integer) keyCode); } + + /** + * Returns true if the given keyCodes key is down. + */ + public static boolean isKeyPress(int keyCode) { + return Keyboard.activeKeys.contains((Integer) keyCode); + } /** * Returns true if the given keyCodes key is up. @@ -87,6 +101,26 @@ public class Keyboard implements KeyListener { } Keyboard.activeKeys.add((Integer) e.getKeyCode()); for(KeyboardListener kl : Keyboard.listener) kl.keyPressed(e); + + //Debug Spawn Enemy on Press + if(e.getKeyCode() == KeyEvent.VK_1) { + new EnemyOne(400,400); + } + if(e.getKeyCode() == KeyEvent.VK_2) { + new EnemyTwo(400,400); + } + if(e.getKeyCode() == KeyEvent.VK_3) { + new EnemyThree(400,400); + } + if(e.getKeyCode() == KeyEvent.VK_4) { + ArrayList points = new ArrayList(); + points.add(new Point(398,306));; + points.add(new Point(10,300)); + new EnemyFour(700,51,points); + } + if(e.getKeyCode() == KeyEvent.VK_0) { + new EnemyBoss(400,400); + } } /** diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index b6dab6a..8cc7649 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -158,6 +158,13 @@ public class Player extends ShootingEntity implements KeyboardListener { if(e.getKeyCode() == KeyEvent.VK_SPACE) { this.shoot(); } + + //DEBUG: Get X and Y + if(e.getKeyCode() == KeyEvent.VK_F6) { + System.out.println("X: " + this.getX()); + System.out.println("Y: " + this.getY()); + System.out.println(); + } } /**