* Added Gameover Screen

* Now with more Buttonmashing for Shooting
This commit is contained in:
JJTCM 2014-10-31 10:46:39 +01:00
parent a6d7bd3b95
commit aaf970f2e4
4 changed files with 50 additions and 2 deletions

View File

@ -9,6 +9,7 @@ public class EnemyOne extends Enemy {
this.setShootDelay(42);
this.setShootSpawn(-8, 10);
this.setHealthPoints(5);
this.setCollisionDamage(100);
}
@Override

View File

@ -5,11 +5,13 @@ 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(40);
this.setShootDelay(5);
this.setShootSpawn(50, 16);
this.setShootDirection(Shot.RIGHT);
this.setShootSpeed(2);
@ -31,9 +33,14 @@ public class Player extends ShootingEntity {
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && this.x < (GameConfig.windowWidth - this.getImage().getWidth())) {
this.x += off;
}
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==false) {
shoot = true;
this.shoot();
}
if(!Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==true) {
shoot = false;
}
}
}

View File

@ -0,0 +1,34 @@
package de.teamteamteam.spacescooter.screen;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.utility.GameConfig;
public class GameOverScreen extends Screen {
public GameOverScreen(Screen parent) {
super(parent);
}
@Override
protected void paint(Graphics2D g) {
g.setColor(new Color(0,0,120));
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
g.setColor(new Color(255,255,255));
g.setFont(new Font("Monospace", 0, 50));
g.drawString("LOL you died!", 100, 100);
g.drawString("Press space to retry!", 100, 400);
}
@Override
protected void update() {
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
this.parent.setOverlay(new MainMenuScreen(this.parent));
}
}
}

View File

@ -42,6 +42,12 @@ public class GameScreen extends Screen {
if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) {
this.setOverlay(new GamePausedScreen(this));
}
if (list.get(1) instanceof Player) {
Player player = (Player) list.get(1);
if (!player.isAlive()) {
this.parent.setOverlay(new GameOverScreen(this.parent));
}
}
}
}