* Added Gameover Screen
* Now with more Buttonmashing for Shooting
This commit is contained in:
parent
a6d7bd3b95
commit
aaf970f2e4
@ -9,6 +9,7 @@ public class EnemyOne extends Enemy {
|
|||||||
this.setShootDelay(42);
|
this.setShootDelay(42);
|
||||||
this.setShootSpawn(-8, 10);
|
this.setShootSpawn(-8, 10);
|
||||||
this.setHealthPoints(5);
|
this.setHealthPoints(5);
|
||||||
|
this.setCollisionDamage(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,11 +5,13 @@ import de.teamteamteam.spacescooter.control.Keyboard;
|
|||||||
import de.teamteamteam.spacescooter.utility.GameConfig;
|
import de.teamteamteam.spacescooter.utility.GameConfig;
|
||||||
|
|
||||||
public class Player extends ShootingEntity {
|
public class Player extends ShootingEntity {
|
||||||
|
|
||||||
|
protected boolean shoot = false;
|
||||||
|
|
||||||
public Player(int x, int y) {
|
public Player(int x, int y) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
this.setImage("images/ship.png");
|
this.setImage("images/ship.png");
|
||||||
this.setShootDelay(40);
|
this.setShootDelay(5);
|
||||||
this.setShootSpawn(50, 16);
|
this.setShootSpawn(50, 16);
|
||||||
this.setShootDirection(Shot.RIGHT);
|
this.setShootDirection(Shot.RIGHT);
|
||||||
this.setShootSpeed(2);
|
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())) {
|
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && this.x < (GameConfig.windowWidth - this.getImage().getWidth())) {
|
||||||
this.x += off;
|
this.x += off;
|
||||||
}
|
}
|
||||||
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
|
if(Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==false) {
|
||||||
|
shoot = true;
|
||||||
this.shoot();
|
this.shoot();
|
||||||
}
|
}
|
||||||
|
if(!Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==true) {
|
||||||
|
shoot = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
34
src/de/teamteamteam/spacescooter/screen/GameOverScreen.java
Normal file
34
src/de/teamteamteam/spacescooter/screen/GameOverScreen.java
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -42,6 +42,12 @@ public class GameScreen extends Screen {
|
|||||||
if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) {
|
if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) {
|
||||||
this.setOverlay(new GamePausedScreen(this));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user