Moved Enemy Spawn Debug (fix too many spawn issue)

Debug for Player Position
This commit is contained in:
JJTCM 2014-11-25 15:00:37 +01:00
parent 8048486fa6
commit c11758d678
2 changed files with 41 additions and 0 deletions

View File

@ -1,9 +1,16 @@
package de.teamteamteam.spacescooter.control; package de.teamteamteam.spacescooter.control;
import java.awt.Point;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.util.ArrayList; 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. * This is our main control input source.
* It accumulates pressed keys, so we can use them to do player movement and more. * It accumulates pressed keys, so we can use them to do player movement and more.
@ -48,6 +55,13 @@ public class Keyboard implements KeyListener {
return Keyboard.activeKeys.contains((Integer) 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. * Returns true if the given keyCodes key is up.
*/ */
@ -87,6 +101,26 @@ public class Keyboard implements KeyListener {
} }
Keyboard.activeKeys.add((Integer) e.getKeyCode()); Keyboard.activeKeys.add((Integer) e.getKeyCode());
for(KeyboardListener kl : Keyboard.listener) kl.keyPressed(e); 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<Point> points = new ArrayList<Point>();
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);
}
} }
/** /**

View File

@ -158,6 +158,13 @@ public class Player extends ShootingEntity implements KeyboardListener {
if(e.getKeyCode() == KeyEvent.VK_SPACE) { if(e.getKeyCode() == KeyEvent.VK_SPACE) {
this.shoot(); 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();
}
} }
/** /**