From d38f016ee0c50e3f9d9e8993ff55ce7392fa5ee8 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 28 Nov 2014 19:29:08 +0100 Subject: [PATCH] Refactor brain package to english variable names. --- src/de/teamteamteam/spacescooter/Main.java | 10 ++---- .../spacescooter/brain/Credits.java | 3 ++ .../spacescooter/brain/GameConfig.java | 4 +-- .../spacescooter/brain/Score.java | 28 +++++++++------ .../spacescooter/brain/StaticValue.java | 12 +++---- .../spacescooter/entity/Player.java | 22 ++++++------ .../spacescooter/gui/ShopOffer.java | 18 +++++----- .../spacescooter/screen/ShopScreen.java | 36 +++++++++---------- 8 files changed, 69 insertions(+), 64 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/Main.java b/src/de/teamteamteam/spacescooter/Main.java index 94116eb..cb66be5 100644 --- a/src/de/teamteamteam/spacescooter/Main.java +++ b/src/de/teamteamteam/spacescooter/Main.java @@ -3,9 +3,7 @@ package de.teamteamteam.spacescooter; import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; -import de.teamteamteam.spacescooter.brain.GameConfig; import de.teamteamteam.spacescooter.screen.LoadingScreen; -import de.teamteamteam.spacescooter.screen.Screen; import de.teamteamteam.spacescooter.screen.SuperScreen; import de.teamteamteam.spacescooter.thread.PaintThread; import de.teamteamteam.spacescooter.thread.UpdateThread; @@ -30,9 +28,6 @@ public class Main { public void run() { GraphicsSettings gs = new GraphicsSettings(); //Get settings - GameConfig.windowWidth = 800; - GameConfig.windowHeight = 650; - //Instantiate the GameFrame final GameFrame gameFrame = new GameFrame(); @@ -56,10 +51,11 @@ public class Main { updateThread.start(); //Set up the LoadingScreen - superScreen.setOverlay(new LoadingScreen(superScreen)); + LoadingScreen loadingScreen = new LoadingScreen(superScreen); + superScreen.setOverlay(loadingScreen); //Start loading and everything will follow up. - Loader.load((LoadingScreen) Screen.currentScreen); + Loader.load(loadingScreen); } }); } catch (InvocationTargetException e) { diff --git a/src/de/teamteamteam/spacescooter/brain/Credits.java b/src/de/teamteamteam/spacescooter/brain/Credits.java index 552b076..07375a9 100644 --- a/src/de/teamteamteam/spacescooter/brain/Credits.java +++ b/src/de/teamteamteam/spacescooter/brain/Credits.java @@ -44,5 +44,8 @@ public class Credits { */ public static void remove(int credits) { Credits.credits -= credits; + if(Credits.credits < 0) { + Credits.credits = 0; + } } } diff --git a/src/de/teamteamteam/spacescooter/brain/GameConfig.java b/src/de/teamteamteam/spacescooter/brain/GameConfig.java index 702a848..5606cdb 100644 --- a/src/de/teamteamteam/spacescooter/brain/GameConfig.java +++ b/src/de/teamteamteam/spacescooter/brain/GameConfig.java @@ -13,12 +13,12 @@ public class GameConfig { /** * Width of GameWindow. */ - public static int windowWidth; + public static int windowWidth = 800; /** * Height of GameWindow. */ - public static int windowHeight; + public static int windowHeight = 650; /** * Title of the game window. diff --git a/src/de/teamteamteam/spacescooter/brain/Score.java b/src/de/teamteamteam/spacescooter/brain/Score.java index 31138df..d9babab 100644 --- a/src/de/teamteamteam/spacescooter/brain/Score.java +++ b/src/de/teamteamteam/spacescooter/brain/Score.java @@ -1,43 +1,49 @@ package de.teamteamteam.spacescooter.brain; /** - * Score Class to represent the Player's Score + * Score Class to represent the Players Score */ public class Score { - + /** - * Score can be between 0 and 99999999 + * Score upper and lower boundaries. */ private static int score = 0; private static int maxScore = 99999999; - + + /** - * Getter for the Score + * Private constructor, this class will never be instantiated. + */ + private Score() {} + + + /** + * Getter for the Score. */ public static int getScore() { return score; } /** - * Setter for the Score + * Setter for the Score. */ public static void setScore(int score) { Score.score = score; } /** - * Method for adding Score + * Method for adding Score, capping it at the maximum value. */ public static void addScore(int score) { - if (Score.score + score >= Score.maxScore) { + Score.score += score; + if (Score.score >= Score.maxScore) { Score.setScore(Score.maxScore); - } else if (Score.score != Score.maxScore) { - Score.score += score; } } /** - * Method for removing Score + * Method for removing Score, capping it at zero. */ public static void removeScore(int score) { if (Score.score - score <= 0) { diff --git a/src/de/teamteamteam/spacescooter/brain/StaticValue.java b/src/de/teamteamteam/spacescooter/brain/StaticValue.java index e79feb7..09dd879 100644 --- a/src/de/teamteamteam/spacescooter/brain/StaticValue.java +++ b/src/de/teamteamteam/spacescooter/brain/StaticValue.java @@ -10,31 +10,31 @@ public class StaticValue { /** * the ShootDamage of the Player */ - public static int ShootDamage = 5; + public static int shotDamage = 5; /** * the HealthPoints of the Player may be changed by the 1Up-Item */ - public static int HealthPoints = 100; + public static int healthPoints = 100; /** * the ShieldPoints of the Player */ - public static int ShieldPoints = 100; + public static int shieldPoints = 100; //Shop /** * The Damage Value of the Shop */ - public static int schaden = 0; + public static int damage = 0; /** * the Shield value of the Shop */ - public static int schild = 0; + public static int shield = 0; /** * the Health value of the Shop */ - public static int leben = 0; + public static int life = 0; } diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index e3988c6..4183f91 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -49,14 +49,14 @@ public class Player extends ShootingEntity implements KeyboardListener { super(x, y); this.setImage("images/ship.png"); this.setPrimaryShotImage("images/shots/laser_blue.png"); - this.setShootDamage(StaticValue.ShootDamage); + this.setShootDamage(StaticValue.shotDamage); this.setShootDelay(20); this.setShootSpawn(50, 16); this.setShootDirection(Shot.RIGHT); this.setShootSpeed(10); this.setCollisionDamage(10); - this.setShieldPoints(StaticValue.ShieldPoints); - this.setHealthPoints(StaticValue.HealthPoints); + this.setShieldPoints(StaticValue.shieldPoints); + this.setHealthPoints(StaticValue.healthPoints); this.registerOnKeyboard(Keyboard.getInstance()); } @@ -72,11 +72,11 @@ public class Player extends ShootingEntity implements KeyboardListener { * Standard update method */ public void update() { - if (StaticValue.HealthPoints != 0) { - this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.HealthPoints) * 100; + if (StaticValue.healthPoints != 0) { + this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.healthPoints) * 100; } - if (StaticValue.ShieldPoints != 0) { - this.shieldPercent = ((double) this.getShieldPoints() / (double) StaticValue.ShieldPoints) * 100; + if (StaticValue.shieldPoints != 0) { + this.shieldPercent = ((double) this.getShieldPoints() / (double) StaticValue.shieldPoints) * 100; } if(this.canMove()) { super.update(); @@ -201,10 +201,10 @@ public class Player extends ShootingEntity implements KeyboardListener { * method for increasing the HealthPoints with the Heal-Item */ public void increaseHealthPoints(int inc) { - if (this.getHealthPoints() <= (StaticValue.HealthPoints - 15)) { + if (this.getHealthPoints() <= (StaticValue.healthPoints - 15)) { this.setHealthPoints(getHealthPoints() + inc); } else { - this.setHealthPoints(StaticValue.HealthPoints); + this.setHealthPoints(StaticValue.healthPoints); } } @@ -212,10 +212,10 @@ public class Player extends ShootingEntity implements KeyboardListener { * method for increasing the ShieldPoints with the Shield-Item */ public void increaseShieldPoints(int inc) { - if (this.getShieldPoints() <= (StaticValue.ShieldPoints - 5)) { + if (this.getShieldPoints() <= (StaticValue.shieldPoints - 5)) { this.setShieldPoints(getShieldPoints() + inc); } else { - this.setShieldPoints(StaticValue.ShieldPoints); + this.setShieldPoints(StaticValue.shieldPoints); } } diff --git a/src/de/teamteamteam/spacescooter/gui/ShopOffer.java b/src/de/teamteamteam/spacescooter/gui/ShopOffer.java index d05aa77..9513344 100644 --- a/src/de/teamteamteam/spacescooter/gui/ShopOffer.java +++ b/src/de/teamteamteam/spacescooter/gui/ShopOffer.java @@ -6,19 +6,19 @@ import java.awt.Graphics2D; import de.teamteamteam.spacescooter.entity.Entity; -public class ShopOffer extends Entity{ +public class ShopOffer extends Entity { private String offer; - private int gekauft; + private int bought; private int max; - public ShopOffer(int x, int y, int max, int gekauft, String offer) { + public ShopOffer(int x, int y, int max, int bought, String offer) { super(x, y); this.offer = offer; - this.gekauft = gekauft; + this.bought = bought; this.max = max; for (int i = 0; i= 5 && schaden.getGekauft() < schaden.getMax()){ - schaden.buy(); - StaticValue.ShootDamage += 5; - StaticValue.schaden++; + if(Credits.getCredits() >= 5 && damage.getBought() < damage.getMax()){ + damage.buy(); + StaticValue.shotDamage += 5; + StaticValue.damage++; Credits.setCredits(Credits.getCredits() - 5); } break; case 1: - if(Credits.getCredits() >= 10 && schild.getGekauft() < schild.getMax()){ - schild.buy(); - StaticValue.ShieldPoints += 10; - StaticValue.schild++; + if(Credits.getCredits() >= 10 && shield.getBought() < shield.getMax()){ + shield.buy(); + StaticValue.shieldPoints += 10; + StaticValue.shield++; Credits.setCredits(Credits.getCredits() - 10); } break; case 2: - if(Credits.getCredits() >= 10 && leben.getGekauft() < leben.getMax()){ - leben.buy(); - StaticValue.HealthPoints += 10; - StaticValue.leben++; + if(Credits.getCredits() >= 10 && life.getBought() < life.getMax()){ + life.buy(); + StaticValue.healthPoints += 10; + StaticValue.life++; Credits.setCredits(Credits.getCredits() - 10); } break;