Files
SpaceScooter/src/de/teamteamteam/spacescooter/entity/Player.java
T
JJTCM aaf970f2e4 * Added Gameover Screen
* Now with more Buttonmashing for Shooting
2014-10-31 10:46:39 +01:00

47 lines
1.2 KiB
Java

package de.teamteamteam.spacescooter.entity;
import java.awt.event.KeyEvent;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.utility.GameConfig;
public class Player extends ShootingEntity {
protected boolean shoot = false;
public Player(int x, int y) {
super(x, y);
this.setImage("images/ship.png");
this.setShootDelay(5);
this.setShootSpawn(50, 16);
this.setShootDirection(Shot.RIGHT);
this.setShootSpeed(2);
this.setHealthPoints(100);
}
public void update() {
super.update();
int off = 3;
if(Keyboard.isKeyDown(KeyEvent.VK_UP) && this.y > 0) {
this.y -= off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && this.y < (GameConfig.windowHeight - this.getImage().getHeight())) {
this.y += off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_LEFT) && this.x > 0) {
this.x -= off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && this.x < (GameConfig.windowWidth - this.getImage().getWidth())) {
this.x += off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==false) {
shoot = true;
this.shoot();
}
if(!Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==true) {
shoot = false;
}
}
}