Remove Highscore file from git, change order of the screens.
This commit is contained in:
parent
74f0f778e2
commit
56109f2774
|
@ -5,3 +5,5 @@
|
|||
bin
|
||||
compiled
|
||||
game.jar
|
||||
|
||||
./Highscore
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.awt.event.KeyEvent;
|
|||
|
||||
import de.teamteamteam.spacescooter.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.entity.enemy.EnemyOne;
|
||||
|
||||
/**
|
||||
* This is the Screen where you can look at all those awesome guys who created this game. :D
|
||||
|
|
|
@ -0,0 +1,216 @@
|
|||
package de.teamteamteam.spacescooter.screen;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import de.teamteamteam.spacescooter.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
import de.teamteamteam.spacescooter.utility.Highscore;
|
||||
|
||||
/**
|
||||
* This is the EnterHighscoreScreen, which is displayed once the player ended
|
||||
* the game by either winning (beating all levels) or losing.
|
||||
* Once a name is entered, the ViewHighscoreScreen is shown.
|
||||
*/
|
||||
public class EnterHighscoreScreen extends Screen {
|
||||
|
||||
private ImageEntity cursor;
|
||||
private float cursorMoveSpeed = 0;
|
||||
private int colorValue = 0;
|
||||
private boolean colorValueIncrease = true;
|
||||
private int animationStatus = 0; //0 = Noch nicht gestartet, 1 = Animation läuft, 2 = Animation beendet
|
||||
|
||||
private boolean keyPressed = false;
|
||||
private boolean uppercase = true;
|
||||
private Point cursorPosition = new Point(0, 0);
|
||||
private int score;
|
||||
private int enteredLetter = 0;
|
||||
private ImageEntity[] letters = new ImageEntity[10];
|
||||
private ImageEntity[] lettersbox = new ImageEntity[10];
|
||||
|
||||
public EnterHighscoreScreen(Screen parent) {
|
||||
super(parent);
|
||||
new ImageEntity(0, 0, "images/shopbackground.png");
|
||||
this.score = PlayerSession.getScore();
|
||||
this.cursor = new ImageEntity(173, 293, "images/ship.png");
|
||||
for(int i = 0; i<10; i++){
|
||||
lettersbox[i] = new ImageEntity(150 + (i*50), 200, "images/letterbox.png");
|
||||
}
|
||||
PlayerSession.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
this.entityPaintIterator.reset();
|
||||
while (this.entityPaintIterator.hasNext()) {
|
||||
this.entityPaintIterator.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, 120);
|
||||
// Paint the screen to enter a name for the high score
|
||||
g.setFont(new Font("Monospace", 0, 30));
|
||||
g.setColor(Color.WHITE);
|
||||
if(uppercase){
|
||||
g.drawString("A C D E G", 210, 320);
|
||||
g.drawString("B F", 267, 320);
|
||||
g.drawString("H I J K L M N", 210, 380);
|
||||
g.drawString("O Q S T U", 210, 440);
|
||||
g.drawString("P R", 267, 440);
|
||||
g.drawString("V Z", 210, 500);
|
||||
g.drawString("W X Y", 263, 500);
|
||||
g.setFont(new Font("Monospace", 0, 15));
|
||||
g.drawString("abc", 497, 493);
|
||||
}else{
|
||||
g.drawString("a b c d e", 210, 320);
|
||||
g.drawString("f g", 505, 320);
|
||||
g.drawString("h k l m n", 210, 380);
|
||||
g.drawString("i j", 273, 380);
|
||||
g.drawString("o p q r s t u", 210, 440);
|
||||
g.drawString("v", 210, 500);
|
||||
g.drawString("w x y z", 264, 500);
|
||||
g.setFont(new Font("Monospace", 0, 15));
|
||||
g.drawString("ABC", 496, 493);
|
||||
}
|
||||
g.setColor(Color.RED);
|
||||
g.drawString("del", 555, 493);
|
||||
g.setFont(new Font("Monospace", 0, 20));
|
||||
g.setColor(Color.GREEN);
|
||||
g.drawString("Fertig", GameConfig.gameScreenWidth/2-40, 555);
|
||||
g.drawString("Du bist auf dem " + (Highscore.getPlacement(score)+1) + ". Platz!", GameConfig.gameScreenWidth/2-130, 170);
|
||||
// Paint the normal gameover screen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {
|
||||
this.entityUpdateIterator.reset();
|
||||
while (this.entityUpdateIterator.hasNext()) {
|
||||
this.entityUpdateIterator.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;
|
||||
}
|
||||
//Control while enter the name for the high score.
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_UP) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.getY() > 0){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() - 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() - 60);
|
||||
}else if(cursorPosition.getY() == 4){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() - 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() - 60);
|
||||
}else{
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), 4);
|
||||
this.cursor.setPosition(325, 533);
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.getY() < 3){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() + 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() + 60);
|
||||
}else if(cursorPosition.getY() == 3){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() + 1);
|
||||
this.cursor.setPosition(325, this.cursor.getY() + 60);
|
||||
}else{
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), 0);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), 293);
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_LEFT) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(cursorPosition.getY() !=4){
|
||||
if(this.cursorPosition.getX() > 0){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX() - 1, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(this.cursor.getX() - 58, this.cursor.getY());
|
||||
}else{
|
||||
this.cursorPosition.setLocation(6, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(521, this.cursor.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(cursorPosition.getY() !=4){
|
||||
if(this.cursorPosition.getX() < 6){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX() + 1, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(this.cursor.getX() + 58, this.cursor.getY());
|
||||
}else{
|
||||
this.cursorPosition.setLocation(0, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(173, this.cursor.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
if((Keyboard.isKeyDown(KeyEvent.VK_ENTER) || Keyboard.isKeyDown(KeyEvent.VK_SPACE)) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.equals(new Point(5, 3))){
|
||||
if(uppercase) uppercase = false;
|
||||
else uppercase = true;
|
||||
}else if(this.cursorPosition.equals(new Point(6, 3))){
|
||||
if(enteredLetter > 0){
|
||||
enteredLetter--;
|
||||
letters[enteredLetter].remove();
|
||||
}
|
||||
}else if(cursorPosition.getY() == 4){
|
||||
String eingabeName = "";
|
||||
for(int i = 0; i<10; i++){
|
||||
if(letters[i] != null){
|
||||
eingabeName += letters[i].getText();
|
||||
}
|
||||
}
|
||||
Highscore.newScore(this.score, eingabeName);
|
||||
animationStatus = 1;
|
||||
}else{
|
||||
if(this.enteredLetter < 10) this.searchForChar();
|
||||
}
|
||||
}
|
||||
if(this.animationStatus == 1) {
|
||||
if(this.cursor.getX() <= GameConfig.windowWidth) {
|
||||
this.cursor.setPosition(this.cursor.getX() + (int) this.cursorMoveSpeed, this.cursor.getY());
|
||||
this.cursorMoveSpeed += 0.1;
|
||||
} else this.animationStatus = 2;
|
||||
} else if(this.animationStatus == 2) {
|
||||
//clean up and go to ViewHighscoreScreen
|
||||
this.cursor.remove();
|
||||
for(int i = 0; i<10; i++){
|
||||
if(lettersbox[i] != null) lettersbox[i].remove();
|
||||
if(letters[i] != null)letters[i].remove();
|
||||
}
|
||||
this.parent.setOverlay(new ViewHighscoreScreen(this.parent));
|
||||
}
|
||||
if(!Keyboard.isKeyDown(KeyEvent.VK_ENTER) && !Keyboard.isKeyDown(KeyEvent.VK_SPACE) && !Keyboard.isKeyDown(KeyEvent.VK_UP) && !Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !Keyboard.isKeyDown(KeyEvent.VK_LEFT) && !Keyboard.isKeyDown(KeyEvent.VK_RIGHT)){
|
||||
this.keyPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void searchForChar(){
|
||||
char eingabe = (char) ('A' + this.cursorPosition.getX()+this.cursorPosition.getY()*7);
|
||||
if(!this.uppercase){
|
||||
eingabe += 32;
|
||||
}
|
||||
if(eingabe == 'W'){
|
||||
letters[enteredLetter] = new ImageEntity(155+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else if(eingabe == 'I' || eingabe =='J' || eingabe =='i' || eingabe =='j' || eingabe =='t' || eingabe =='l' || eingabe =='f'){
|
||||
letters[enteredLetter] = new ImageEntity(165+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else if(eingabe == 'w'){
|
||||
letters[enteredLetter] = new ImageEntity(157+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else{
|
||||
letters[enteredLetter] = new ImageEntity(161+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}
|
||||
enteredLetter++;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,267 +0,0 @@
|
|||
package de.teamteamteam.spacescooter.screen;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import de.teamteamteam.spacescooter.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.gui.Button;
|
||||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
import de.teamteamteam.spacescooter.utility.Highscore;
|
||||
|
||||
/**
|
||||
* This is the GameOverScreen, which is displayed once the player
|
||||
* died and the game is over.
|
||||
* It allows to start a new game or going to the MainMenuScreen.
|
||||
*/
|
||||
public class GameOverScreen extends Screen {
|
||||
|
||||
private ImageEntity cursor;
|
||||
private float cursorMoveSpeed = 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
|
||||
|
||||
private boolean keyPressed = false;
|
||||
private boolean saveScoreMenu = true;
|
||||
private boolean uppercase = true;
|
||||
private Point cursorPosition = new Point(0, 0);
|
||||
private int score;
|
||||
private int enteredLetter = 0;
|
||||
private ImageEntity[] letters = new ImageEntity[10];
|
||||
private ImageEntity[] lettersbox = new ImageEntity[10];
|
||||
|
||||
public GameOverScreen(Screen parent) {
|
||||
super(parent);
|
||||
new ImageEntity(0, 0, "images/shopbackground.png");
|
||||
this.score = PlayerSession.getScore();
|
||||
if(Highscore.getPlacement(score) != -1){ // Player has a new high score
|
||||
saveScoreMenu = true;
|
||||
this.cursor = new ImageEntity(173, 293, "images/ship.png");
|
||||
for(int i = 0; i<10; i++){
|
||||
lettersbox[i] = new ImageEntity(150 + (i*50), 200, "images/letterbox.png");
|
||||
}
|
||||
}else{
|
||||
saveScoreMenu = false;
|
||||
new Button(GameConfig.windowWidth/2-125, 300);
|
||||
new Button(GameConfig.windowWidth/2-125, 400);
|
||||
this.cursor = new ImageEntity(GameConfig.windowWidth/2-170, 309, "images/ship.png");
|
||||
}
|
||||
PlayerSession.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
this.entityPaintIterator.reset();
|
||||
while (this.entityPaintIterator.hasNext()) {
|
||||
this.entityPaintIterator.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, 120);
|
||||
// Paint the screen to enter a name for the high score
|
||||
if(saveScoreMenu){
|
||||
g.setFont(new Font("Monospace", 0, 30));
|
||||
g.setColor(Color.WHITE);
|
||||
if(uppercase){
|
||||
g.drawString("A C D E G", 210, 320);
|
||||
g.drawString("B F", 267, 320);
|
||||
g.drawString("H I J K L M N", 210, 380);
|
||||
g.drawString("O Q S T U", 210, 440);
|
||||
g.drawString("P R", 267, 440);
|
||||
g.drawString("V Z", 210, 500);
|
||||
g.drawString("W X Y", 263, 500);
|
||||
g.setFont(new Font("Monospace", 0, 15));
|
||||
g.drawString("abc", 497, 493);
|
||||
}else{
|
||||
g.drawString("a b c d e", 210, 320);
|
||||
g.drawString("f g", 505, 320);
|
||||
g.drawString("h k l m n", 210, 380);
|
||||
g.drawString("i j", 273, 380);
|
||||
g.drawString("o p q r s t u", 210, 440);
|
||||
g.drawString("v", 210, 500);
|
||||
g.drawString("w x y z", 264, 500);
|
||||
g.setFont(new Font("Monospace", 0, 15));
|
||||
g.drawString("ABC", 496, 493);
|
||||
}
|
||||
g.setColor(Color.RED);
|
||||
g.drawString("del", 555, 493);
|
||||
g.setFont(new Font("Monospace", 0, 20));
|
||||
g.setColor(Color.GREEN);
|
||||
g.drawString("Fertig", GameConfig.gameScreenWidth/2-40, 555);
|
||||
g.drawString("Du bist auf dem " + (Highscore.getPlacement(score)+1) + ". Platz!", GameConfig.gameScreenWidth/2-130, 170);
|
||||
// Paint the normal gameover screen
|
||||
}else{
|
||||
g.setFont(new Font("Monospace", 0, 20));
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawString("Wiederholen", GameConfig.windowWidth/2-60, 332);
|
||||
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-60, 432);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {
|
||||
this.entityUpdateIterator.reset();
|
||||
while (this.entityUpdateIterator.hasNext()) {
|
||||
this.entityUpdateIterator.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;
|
||||
}
|
||||
//Control while enter the name for the high score.
|
||||
if(this.saveScoreMenu){
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_UP) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.getY() > 0){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() - 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() - 60);
|
||||
}else if(cursorPosition.getY() == 4){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() - 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() - 60);
|
||||
}else{
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), 4);
|
||||
this.cursor.setPosition(325, 533);
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.getY() < 3){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() + 1);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), this.cursor.getY() + 60);
|
||||
}else if(cursorPosition.getY() == 3){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), this.cursorPosition.getY() + 1);
|
||||
this.cursor.setPosition(325, this.cursor.getY() + 60);
|
||||
}else{
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX(), 0);
|
||||
this.cursor.setPosition(173+(int)(this.cursorPosition.getX()*58), 293);
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_LEFT) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(cursorPosition.getY() !=4){
|
||||
if(this.cursorPosition.getX() > 0){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX() - 1, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(this.cursor.getX() - 58, this.cursor.getY());
|
||||
}else{
|
||||
this.cursorPosition.setLocation(6, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(521, this.cursor.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_RIGHT) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(cursorPosition.getY() !=4){
|
||||
if(this.cursorPosition.getX() < 6){
|
||||
this.cursorPosition.setLocation(this.cursorPosition.getX() + 1, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(this.cursor.getX() + 58, this.cursor.getY());
|
||||
}else{
|
||||
this.cursorPosition.setLocation(0, this.cursorPosition.getY());
|
||||
this.cursor.setPosition(173, this.cursor.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
if((Keyboard.isKeyDown(KeyEvent.VK_ENTER) || Keyboard.isKeyDown(KeyEvent.VK_SPACE)) && !this.keyPressed){
|
||||
this.keyPressed = true;
|
||||
if(this.cursorPosition.equals(new Point(5, 3))){
|
||||
if(uppercase) uppercase = false;
|
||||
else uppercase = true;
|
||||
}else if(this.cursorPosition.equals(new Point(6, 3))){
|
||||
if(enteredLetter > 0){
|
||||
enteredLetter--;
|
||||
letters[enteredLetter].remove();
|
||||
}
|
||||
}else if(cursorPosition.getY() == 4){
|
||||
String eingabeName = "";
|
||||
for(int i = 0; i<10; i++){
|
||||
if(letters[i] != null){
|
||||
eingabeName += letters[i].getText();
|
||||
}
|
||||
}
|
||||
Highscore.newScore(this.score, eingabeName);
|
||||
animationStatus = 1;
|
||||
}else{
|
||||
if(this.enteredLetter < 10) this.searchForChar();
|
||||
}
|
||||
}
|
||||
|
||||
//Control in the game normal over menu (if the player does not came in the high score).
|
||||
}else{
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_DOWN) && this.animationStatus == 0){
|
||||
this.menuPoint = 1;
|
||||
this.cursor.setPosition(this.cursor.getX(), 409);
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_UP) && this.animationStatus == 0){
|
||||
this.menuPoint = 0;
|
||||
this.cursor.setPosition(this.cursor.getX(), 309);
|
||||
}
|
||||
|
||||
// make a selection
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_ENTER) || Keyboard.isKeyDown(KeyEvent.VK_SPACE) && !this.keyPressed) {
|
||||
this.animationStatus = 1;
|
||||
}
|
||||
}
|
||||
if(this.animationStatus == 1) {
|
||||
if(this.cursor.getX() <= GameConfig.windowWidth) {
|
||||
this.cursor.setPosition(this.cursor.getX() + (int) this.cursorMoveSpeed, this.cursor.getY());
|
||||
this.cursorMoveSpeed += 0.1;
|
||||
} else this.animationStatus = 2;
|
||||
} else if(this.animationStatus == 2) {
|
||||
if(saveScoreMenu){
|
||||
this.cursor.remove();
|
||||
for(int i = 0; i<10; i++){
|
||||
if(lettersbox[i] != null) lettersbox[i].remove();
|
||||
if(letters[i] != null)letters[i].remove();
|
||||
}
|
||||
this.saveScoreMenu = false;
|
||||
new Button(GameConfig.windowWidth/2-125, 300);
|
||||
new Button(GameConfig.windowWidth/2-125, 400);
|
||||
this.cursor = new ImageEntity(GameConfig.windowWidth/2-170, 309, "images/ship.png");
|
||||
this.animationStatus = 0;
|
||||
this.cursorMoveSpeed = 0;
|
||||
}else{
|
||||
switch (this.menuPoint) {
|
||||
case 0:
|
||||
this.parent.setOverlay(new GameScreen(this.parent));
|
||||
break;
|
||||
case 1:
|
||||
this.parent.setOverlay(new MainMenuScreen(this.parent));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!Keyboard.isKeyDown(KeyEvent.VK_ENTER) && !Keyboard.isKeyDown(KeyEvent.VK_SPACE) && !Keyboard.isKeyDown(KeyEvent.VK_UP) && !Keyboard.isKeyDown(KeyEvent.VK_DOWN) && !Keyboard.isKeyDown(KeyEvent.VK_LEFT) && !Keyboard.isKeyDown(KeyEvent.VK_RIGHT)){
|
||||
this.keyPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void searchForChar(){
|
||||
char eingabe = (char) ('A' + this.cursorPosition.getX()+this.cursorPosition.getY()*7);
|
||||
if(!this.uppercase){
|
||||
eingabe += 32;
|
||||
}
|
||||
if(eingabe == 'W'){
|
||||
letters[enteredLetter] = new ImageEntity(155+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else if(eingabe == 'I' || eingabe =='J' || eingabe =='i' || eingabe =='j' || eingabe =='t' || eingabe =='l' || eingabe =='f'){
|
||||
letters[enteredLetter] = new ImageEntity(165+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else if(eingabe == 'w'){
|
||||
letters[enteredLetter] = new ImageEntity(157+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}else{
|
||||
letters[enteredLetter] = new ImageEntity(161+(50*this.enteredLetter), 230, null);
|
||||
letters[enteredLetter].drawString("" + eingabe, 30, Color.WHITE);
|
||||
}
|
||||
enteredLetter++;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.awt.Font;
|
|||
import java.awt.Graphics2D;
|
||||
import java.awt.event.KeyEvent;
|
||||
import de.teamteamteam.spacescooter.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.gui.Button;
|
||||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
|
@ -87,6 +88,8 @@ public class GamePausedScreen extends Screen {
|
|||
this.parent.setOverlay(null, false);
|
||||
break;
|
||||
case 1:
|
||||
//Clear the PlayerSession
|
||||
PlayerSession.reset();
|
||||
//Replaces its parents (the GameScreen) parent (the SuperScreen) overlay.
|
||||
this.parent.parent.setOverlay(new MainMenuScreen(this.parent.parent));
|
||||
break;
|
||||
|
|
|
@ -13,6 +13,7 @@ import de.teamteamteam.spacescooter.gui.SecondaryWeaponAmount;
|
|||
import de.teamteamteam.spacescooter.gui.ShieldBar;
|
||||
import de.teamteamteam.spacescooter.level.Level;
|
||||
import de.teamteamteam.spacescooter.utility.CollisionHandler;
|
||||
import de.teamteamteam.spacescooter.utility.Highscore;
|
||||
|
||||
/**
|
||||
* In this GameScreen, the actual gameplay takes place.
|
||||
|
@ -92,16 +93,27 @@ public class GameScreen extends Screen {
|
|||
|
||||
//React if the game is actually over.
|
||||
if (this.level.isGameOver()) {
|
||||
boolean playerGotNewHighscore = (Highscore.getPlacement(PlayerSession.getScore()) != -1);
|
||||
if(this.level.playerHasWon()) {
|
||||
if(PlayerSession.getNextLevel() == null) {
|
||||
this.parent.setOverlay(new HighscoreScreen(this.parent));
|
||||
//Allow entering a new highscore depending on whether it actually is a new highscore.
|
||||
if(playerGotNewHighscore) {
|
||||
this.parent.setOverlay(new EnterHighscoreScreen(this.parent));
|
||||
} else {
|
||||
this.parent.setOverlay(new ViewHighscoreScreen(this.parent));
|
||||
}
|
||||
} else {
|
||||
//Go to the I don't know yet Screen if the game is over and the player WON.
|
||||
this.parent.setOverlay(new GameWonScreen(this.parent));
|
||||
}
|
||||
} else {
|
||||
//Go to GameOverScreen if the game is over - the player died and lost the game.
|
||||
this.parent.setOverlay(new GameOverScreen(this.parent));
|
||||
//Allow entering a new highscore depending on whether it actually is a new highscore.
|
||||
if(playerGotNewHighscore) {
|
||||
this.parent.setOverlay(new EnterHighscoreScreen(this.parent));
|
||||
} else {
|
||||
this.parent.setOverlay(new ViewHighscoreScreen(this.parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ public class GameWonScreen extends Screen {
|
|||
g.setFont(new Font("Monospace", 0, 20));
|
||||
g.setColor(new Color(0, 0, 0));
|
||||
g.drawString("Weiter", GameConfig.windowWidth/2-70, 332);
|
||||
g.drawString("Hauptmen\u00fc", GameConfig.windowWidth/2-60, 432);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,9 +89,6 @@ public class GameWonScreen extends Screen {
|
|||
case 0:
|
||||
this.parent.setOverlay(new ShopScreen(this.parent));
|
||||
break;
|
||||
case 1:
|
||||
this.parent.setOverlay(new MainMenuScreen(this.parent));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
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.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
|
||||
/**
|
||||
* A Screen providing all the cool instructions about how to play.
|
||||
*/
|
||||
public class HelpScreen extends Screen {
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
public HelpScreen(Screen parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Credits :)
|
||||
*/
|
||||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
g.setColor(new Color(0,0,120));
|
||||
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
|
||||
g.setColor(Color.WHITE);
|
||||
g.setFont(new Font("Monospace", 0, 50));
|
||||
String text = "Hilfe kommt";
|
||||
g.drawString(text, (GameConfig.windowWidth - g.getFontMetrics().stringWidth(text))/2, 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* In case the Loader is done, immediately fire up the MainMenuScreen.
|
||||
*/
|
||||
@Override
|
||||
protected void update() {
|
||||
if(Keyboard.isKeyDown(KeyEvent.VK_ENTER) || Keyboard.isKeyDown(KeyEvent.VK_SPACE)) {
|
||||
this.parent.setOverlay(new MainMenuScreen(this.parent));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ import java.awt.event.KeyEvent;
|
|||
|
||||
import de.teamteamteam.spacescooter.background.StarBackground;
|
||||
import de.teamteamteam.spacescooter.brain.GameConfig;
|
||||
import de.teamteamteam.spacescooter.brain.PlayerSession;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.gui.Button;
|
||||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
|
@ -101,10 +100,10 @@ public class MainMenuScreen extends Screen {
|
|||
this.parent.setOverlay(new GameScreen(this.parent));
|
||||
break;
|
||||
case 1:
|
||||
this.parent.setOverlay(new ShopScreen(this.parent));
|
||||
this.parent.setOverlay(new HelpScreen(this.parent));
|
||||
break;
|
||||
case 2:
|
||||
this.parent.setOverlay(new HighscoreScreen(this.parent));
|
||||
this.parent.setOverlay(new ViewHighscoreScreen(this.parent));
|
||||
break;
|
||||
case 3:
|
||||
this.parent.setOverlay(new CreditsScreen(this.parent));
|
||||
|
|
|
@ -36,10 +36,8 @@ public class ShopScreen extends Screen {
|
|||
new ImageEntity(GameConfig.windowWidth / 2 - 120, 365, "images/shop/shoprocket.png");
|
||||
new ImageEntity(GameConfig.windowWidth / 2 + 30, 365, "images/shop/shopbeam.png");
|
||||
if(PlayerSession.getSecondsecondaryWeapon() == 1){
|
||||
System.out.println("1");
|
||||
select = new ImageEntity(GameConfig.windowWidth / 2 - 130, 355, "images/shop/select.png");
|
||||
}else{
|
||||
System.out.println("2");
|
||||
select = new ImageEntity(GameConfig.windowWidth / 2 + 20, 355, "images/shop/select.png");
|
||||
}
|
||||
this.cursor = new ImageEntity(50, 149, "images/ship.png");
|
||||
|
|
|
@ -11,7 +11,10 @@ import de.teamteamteam.spacescooter.gui.Button;
|
|||
import de.teamteamteam.spacescooter.gui.ImageEntity;
|
||||
import de.teamteamteam.spacescooter.utility.Highscore;
|
||||
|
||||
public class HighscoreScreen extends Screen{
|
||||
/**
|
||||
* This one displays the whole HighScore and offers an option to go back to the MainMenu.
|
||||
*/
|
||||
public class ViewHighscoreScreen extends Screen{
|
||||
|
||||
private ImageEntity cursor;
|
||||
private float cursorMoveSpeed = 0;
|
||||
|
@ -19,7 +22,7 @@ public class HighscoreScreen extends Screen{
|
|||
private int[] points;
|
||||
private String[] names;
|
||||
|
||||
public HighscoreScreen(Screen parent) {
|
||||
public ViewHighscoreScreen(Screen parent) {
|
||||
super(parent);
|
||||
new ImageEntity(0, 0, "images/shopbackground.png");
|
||||
new Button(GameConfig.windowWidth/2-125, GameConfig.windowHeight-75);
|
Loading…
Reference in New Issue