From aaf970f2e4fa3924d5e21aaca5e00c46c2366371 Mon Sep 17 00:00:00 2001 From: JJTCM Date: Fri, 31 Oct 2014 10:46:39 +0100 Subject: [PATCH 1/3] * Added Gameover Screen * Now with more Buttonmashing for Shooting --- .../spacescooter/entity/EnemyOne.java | 1 + .../spacescooter/entity/Player.java | 11 ++++-- .../spacescooter/screen/GameOverScreen.java | 34 +++++++++++++++++++ .../spacescooter/screen/GameScreen.java | 6 ++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/de/teamteamteam/spacescooter/screen/GameOverScreen.java diff --git a/src/de/teamteamteam/spacescooter/entity/EnemyOne.java b/src/de/teamteamteam/spacescooter/entity/EnemyOne.java index 5274953..ee93fa9 100644 --- a/src/de/teamteamteam/spacescooter/entity/EnemyOne.java +++ b/src/de/teamteamteam/spacescooter/entity/EnemyOne.java @@ -9,6 +9,7 @@ public class EnemyOne extends Enemy { this.setShootDelay(42); this.setShootSpawn(-8, 10); this.setHealthPoints(5); + this.setCollisionDamage(100); } @Override diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 4a192ef..795daa0 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -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; + } + } } diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java new file mode 100644 index 0000000..d9fed1b --- /dev/null +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -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)); + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 55fd6a3..857e52b 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -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)); + } + } } } From 7563048cca72b2f81c7fa0b622eb66cf552b1b3b Mon Sep 17 00:00:00 2001 From: Sosch Date: Fri, 31 Oct 2014 11:00:17 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Enemy=202=20und=203=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spacescooter/entity/EnemyThree.java | 55 +++++++++++++++++++ .../spacescooter/entity/EnemyTwo.java | 34 ++++++++++++ .../spacescooter/screen/GameScreen.java | 11 ++-- 3 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 src/de/teamteamteam/spacescooter/entity/EnemyThree.java create mode 100644 src/de/teamteamteam/spacescooter/entity/EnemyTwo.java diff --git a/src/de/teamteamteam/spacescooter/entity/EnemyThree.java b/src/de/teamteamteam/spacescooter/entity/EnemyThree.java new file mode 100644 index 0000000..95fd918 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/EnemyThree.java @@ -0,0 +1,55 @@ +package de.teamteamteam.spacescooter.entity; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Random; + +import de.teamteamteam.spacescooter.screen.Screen; +import de.teamteamteam.spacescooter.utility.GameConfig; + +public class EnemyThree extends Enemy{ + + private double newY; + private double ySpeed = 0.4; + + public EnemyThree(int x, int y) { + super(x, y); + Random random = new Random(); + this.setImage("images/nyancat.png"); + this.setShootSpeed(4); + this.setShootDelay(42); + this.setShootSpawn(-10, 10); + this.setHealthPoints(5); + this.setPosition(GameConfig.windowWidth, random.nextInt(GameConfig.windowHeight - this.getHeight())); + this.newY = this.getY(); + } + + @Override + public void update() { + super.update(); + this.setPosition(this.getX()-1, this.getY()); + if(this.getX() < 0-getWidth()){ + this.remove(); + Screen.currentScreen.addEntity(new EnemyThree(0, 0)); + } + if(!this.isAlive()){ + Screen.currentScreen.addEntity(new EnemyThree(0, 0)); + } + LinkedList list = Screen.currentScreen.getEntities(); + Iterator i = list.iterator(); + while (i.hasNext()) { + Entity entity = i.next(); + if(entity instanceof Player){ + Player player = (Player) entity; + if(this.y < player.getY()){ + this.newY += ySpeed; + this.setPosition(this.getX(), (int) newY); + }else if(this.y > player.getY()){ + this.newY -= ySpeed; + this.setPosition(this.getX(), (int) newY); + } + } + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/entity/EnemyTwo.java b/src/de/teamteamteam/spacescooter/entity/EnemyTwo.java new file mode 100644 index 0000000..5ae4204 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/EnemyTwo.java @@ -0,0 +1,34 @@ +package de.teamteamteam.spacescooter.entity; + +import java.util.Random; + +import de.teamteamteam.spacescooter.screen.Screen; +import de.teamteamteam.spacescooter.utility.GameConfig; + +public class EnemyTwo extends Enemy{ + + public EnemyTwo(int x, int y) { + super(x, y); + Random random = new Random(); + this.setImage("images/nyancat.png"); + this.setShootSpeed(4); + this.setShootDelay(42); + this.setShootSpawn(-10, 10); + this.setHealthPoints(5); + this.setPosition(GameConfig.windowWidth, random.nextInt(GameConfig.windowHeight - this.getHeight())); + } + + @Override + public void update() { + super.update(); + this.setPosition(this.getX()-1, this.getY()); + if(this.getX() < 0-getWidth()){ + this.remove(); + Screen.currentScreen.addEntity(new EnemyTwo(0, 0)); + } + if(!this.isAlive()){ + Screen.currentScreen.addEntity(new EnemyTwo(0, 0)); + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 55fd6a3..a452960 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -7,7 +7,8 @@ import java.util.LinkedList; import de.teamteamteam.spacescooter.background.StarBackground; import de.teamteamteam.spacescooter.control.Keyboard; -import de.teamteamteam.spacescooter.entity.EnemyOne; +import de.teamteamteam.spacescooter.entity.EnemyThree; +import de.teamteamteam.spacescooter.entity.EnemyTwo; import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.entity.Player; @@ -17,10 +18,10 @@ public class GameScreen extends Screen { super(parent); this.entities.add(new StarBackground(0, 0)); this.entities.add(new Player(200, 300)); - this.entities.add(new EnemyOne(650, 300)); - this.entities.add(new EnemyOne(450, 100)); - this.entities.add(new EnemyOne(750, 550)); - this.entities.add(new EnemyOne(150, 250)); + this.entities.add(new EnemyThree(650, 300)); + this.entities.add(new EnemyThree(450, 100)); + this.entities.add(new EnemyTwo(750, 550)); + this.entities.add(new EnemyTwo(150, 250)); } @Override From d013afb4656b3370a31964def3859e05ee93a382 Mon Sep 17 00:00:00 2001 From: JJTCM Date: Fri, 31 Oct 2014 11:06:30 +0100 Subject: [PATCH 3/3] * Merge Confilct --- .../spacescooter/entity/Player.java | 10 ++- .../spacescooter/screen/GameOverScreen.java | 80 +++++++++++++++++-- 2 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 71ef49e..796221a 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -35,13 +35,15 @@ 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; + } } - if(!Keyboard.isKeyDown(KeyEvent.VK_SPACE) && shoot==true) { - shoot = false; - } + } diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java index d9fed1b..62812e1 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -4,30 +4,96 @@ import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.util.Iterator; +import java.util.LinkedList; import de.teamteamteam.spacescooter.control.Keyboard; +import de.teamteamteam.spacescooter.entity.Entity; +import de.teamteamteam.spacescooter.entity.Player; +import de.teamteamteam.spacescooter.gui.Button; import de.teamteamteam.spacescooter.utility.GameConfig; +import de.teamteamteam.spacescooter.utility.Loader; public class GameOverScreen extends Screen { + private BufferedImage img; + private Player player; + private float playerMoveSpeed = 0; + private int colorValue = 0; + private boolean colorValueIncrease = true; + private int menuPoint = 0; + private int animationStatus = 0; //0 = Noch nicht gestartet, 1 = Animation läuft, 2 = Animation beendet + public GameOverScreen(Screen parent) { super(parent); + this.img = Loader.getBufferedImageByFilename("images/pausebackground.png"); + this.entities.add(new Button(GameConfig.windowWidth/2-125, 300)); + this.entities.add(new Button(GameConfig.windowWidth/2-125, 400)); + player = new Player(GameConfig.windowWidth/2-170, 309); + player.setCanMove(false); + this.entities.add(player); } @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); + g.drawImage(this.img, 0, 0, null); + LinkedList list = this.getEntities(); + Iterator i = list.iterator(); + while (i.hasNext()) { + i.next().paint(g); + } + g.setFont(new Font("Monospace", 0, 100)); + g.setColor(new Color(75 + colorValue, 175 + colorValue, 175 + colorValue)); + g.drawString("Game Over", GameConfig.windowWidth/2-290, 200); + g.setFont(new Font("Monospace", 0, 20)); + g.setColor(new Color(0, 0, 0)); + g.drawString("Wiederholen", GameConfig.windowWidth/2-60, 332); + g.drawString("Hauptmenü", GameConfig.windowWidth/2-60, 432); } @Override protected void update() { + LinkedList list = this.getEntities(); + Iterator i = list.iterator(); + while (i.hasNext()) { + i.next().update(); + } + + if(this.colorValueIncrease){ + this.colorValue += 2; + if(this.colorValue > 70) this.colorValueIncrease = false; + }else{ + this.colorValue -= 2; + if(this.colorValue < -70) this.colorValueIncrease = true; + } + + if(Keyboard.isKeyDown(KeyEvent.VK_DOWN)){ + this.menuPoint = 1; + player.setPosition(player.getX(), 409); + } + if(Keyboard.isKeyDown(KeyEvent.VK_UP)){ + this.menuPoint = 0; + player.setPosition(player.getX(), 309); + } + if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) { - this.parent.setOverlay(new MainMenuScreen(this.parent)); + this.animationStatus = 1; + } + if(this.animationStatus == 1){ + if(player.getX() <= GameConfig.windowWidth){ + player.setPosition(player.getX() + (int)playerMoveSpeed, player.getY()); + playerMoveSpeed += 0.1; + }else this.animationStatus = 2; + }else if(this.animationStatus == 2){ + switch (this.menuPoint) { + case 0: + this.parent.setOverlay(new GameScreen(this.parent)); + break; + case 1: + this.parent.setOverlay(new MainMenuScreen(this.parent)); + break; + } } }