Refactor brain package to english variable names.

This commit is contained in:
Jan Philipp Timme 2014-11-28 19:29:08 +01:00
parent 0afa327fda
commit d38f016ee0
8 changed files with 69 additions and 64 deletions

View File

@ -3,9 +3,7 @@ package de.teamteamteam.spacescooter;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import de.teamteamteam.spacescooter.brain.GameConfig;
import de.teamteamteam.spacescooter.screen.LoadingScreen; import de.teamteamteam.spacescooter.screen.LoadingScreen;
import de.teamteamteam.spacescooter.screen.Screen;
import de.teamteamteam.spacescooter.screen.SuperScreen; import de.teamteamteam.spacescooter.screen.SuperScreen;
import de.teamteamteam.spacescooter.thread.PaintThread; import de.teamteamteam.spacescooter.thread.PaintThread;
import de.teamteamteam.spacescooter.thread.UpdateThread; import de.teamteamteam.spacescooter.thread.UpdateThread;
@ -30,9 +28,6 @@ public class Main {
public void run() { public void run() {
GraphicsSettings gs = new GraphicsSettings(); //Get settings GraphicsSettings gs = new GraphicsSettings(); //Get settings
GameConfig.windowWidth = 800;
GameConfig.windowHeight = 650;
//Instantiate the GameFrame //Instantiate the GameFrame
final GameFrame gameFrame = new GameFrame(); final GameFrame gameFrame = new GameFrame();
@ -56,10 +51,11 @@ public class Main {
updateThread.start(); updateThread.start();
//Set up the LoadingScreen //Set up the LoadingScreen
superScreen.setOverlay(new LoadingScreen(superScreen)); LoadingScreen loadingScreen = new LoadingScreen(superScreen);
superScreen.setOverlay(loadingScreen);
//Start loading and everything will follow up. //Start loading and everything will follow up.
Loader.load((LoadingScreen) Screen.currentScreen); Loader.load(loadingScreen);
} }
}); });
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {

View File

@ -44,5 +44,8 @@ public class Credits {
*/ */
public static void remove(int credits) { public static void remove(int credits) {
Credits.credits -= credits; Credits.credits -= credits;
if(Credits.credits < 0) {
Credits.credits = 0;
}
} }
} }

View File

@ -13,12 +13,12 @@ public class GameConfig {
/** /**
* Width of GameWindow. * Width of GameWindow.
*/ */
public static int windowWidth; public static int windowWidth = 800;
/** /**
* Height of GameWindow. * Height of GameWindow.
*/ */
public static int windowHeight; public static int windowHeight = 650;
/** /**
* Title of the game window. * Title of the game window.

View File

@ -1,43 +1,49 @@
package de.teamteamteam.spacescooter.brain; package de.teamteamteam.spacescooter.brain;
/** /**
* Score Class to represent the Player's Score * Score Class to represent the Players Score
*/ */
public class Score { public class Score {
/** /**
* Score can be between 0 and 99999999 * Score upper and lower boundaries.
*/ */
private static int score = 0; private static int score = 0;
private static int maxScore = 99999999; 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() { public static int getScore() {
return score; return score;
} }
/** /**
* Setter for the Score * Setter for the Score.
*/ */
public static void setScore(int score) { public static void setScore(int score) {
Score.score = score; Score.score = score;
} }
/** /**
* Method for adding Score * Method for adding Score, capping it at the maximum value.
*/ */
public static void addScore(int score) { public static void addScore(int score) {
if (Score.score + score >= Score.maxScore) { Score.score += score;
if (Score.score >= Score.maxScore) {
Score.setScore(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) { public static void removeScore(int score) {
if (Score.score - score <= 0) { if (Score.score - score <= 0) {

View File

@ -10,31 +10,31 @@ public class StaticValue {
/** /**
* the ShootDamage of the Player * 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 * 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 * the ShieldPoints of the Player
*/ */
public static int ShieldPoints = 100; public static int shieldPoints = 100;
//Shop //Shop
/** /**
* The Damage Value of the Shop * The Damage Value of the Shop
*/ */
public static int schaden = 0; public static int damage = 0;
/** /**
* the Shield value of the Shop * the Shield value of the Shop
*/ */
public static int schild = 0; public static int shield = 0;
/** /**
* the Health value of the Shop * the Health value of the Shop
*/ */
public static int leben = 0; public static int life = 0;
} }

View File

@ -49,14 +49,14 @@ public class Player extends ShootingEntity implements KeyboardListener {
super(x, y); super(x, y);
this.setImage("images/ship.png"); this.setImage("images/ship.png");
this.setPrimaryShotImage("images/shots/laser_blue.png"); this.setPrimaryShotImage("images/shots/laser_blue.png");
this.setShootDamage(StaticValue.ShootDamage); this.setShootDamage(StaticValue.shotDamage);
this.setShootDelay(20); this.setShootDelay(20);
this.setShootSpawn(50, 16); this.setShootSpawn(50, 16);
this.setShootDirection(Shot.RIGHT); this.setShootDirection(Shot.RIGHT);
this.setShootSpeed(10); this.setShootSpeed(10);
this.setCollisionDamage(10); this.setCollisionDamage(10);
this.setShieldPoints(StaticValue.ShieldPoints); this.setShieldPoints(StaticValue.shieldPoints);
this.setHealthPoints(StaticValue.HealthPoints); this.setHealthPoints(StaticValue.healthPoints);
this.registerOnKeyboard(Keyboard.getInstance()); this.registerOnKeyboard(Keyboard.getInstance());
} }
@ -72,11 +72,11 @@ public class Player extends ShootingEntity implements KeyboardListener {
* Standard update method * Standard update method
*/ */
public void update() { public void update() {
if (StaticValue.HealthPoints != 0) { if (StaticValue.healthPoints != 0) {
this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.HealthPoints) * 100; this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.healthPoints) * 100;
} }
if (StaticValue.ShieldPoints != 0) { if (StaticValue.shieldPoints != 0) {
this.shieldPercent = ((double) this.getShieldPoints() / (double) StaticValue.ShieldPoints) * 100; this.shieldPercent = ((double) this.getShieldPoints() / (double) StaticValue.shieldPoints) * 100;
} }
if(this.canMove()) { if(this.canMove()) {
super.update(); super.update();
@ -201,10 +201,10 @@ public class Player extends ShootingEntity implements KeyboardListener {
* method for increasing the HealthPoints with the Heal-Item * method for increasing the HealthPoints with the Heal-Item
*/ */
public void increaseHealthPoints(int inc) { public void increaseHealthPoints(int inc) {
if (this.getHealthPoints() <= (StaticValue.HealthPoints - 15)) { if (this.getHealthPoints() <= (StaticValue.healthPoints - 15)) {
this.setHealthPoints(getHealthPoints() + inc); this.setHealthPoints(getHealthPoints() + inc);
} else { } 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 * method for increasing the ShieldPoints with the Shield-Item
*/ */
public void increaseShieldPoints(int inc) { public void increaseShieldPoints(int inc) {
if (this.getShieldPoints() <= (StaticValue.ShieldPoints - 5)) { if (this.getShieldPoints() <= (StaticValue.shieldPoints - 5)) {
this.setShieldPoints(getShieldPoints() + inc); this.setShieldPoints(getShieldPoints() + inc);
} else { } else {
this.setShieldPoints(StaticValue.ShieldPoints); this.setShieldPoints(StaticValue.shieldPoints);
} }
} }

View File

@ -6,19 +6,19 @@ import java.awt.Graphics2D;
import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.entity.Entity;
public class ShopOffer extends Entity{ public class ShopOffer extends Entity {
private String offer; private String offer;
private int gekauft; private int bought;
private int max; 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); super(x, y);
this.offer = offer; this.offer = offer;
this.gekauft = gekauft; this.bought = bought;
this.max = max; this.max = max;
for (int i = 0; i<max; i++){ for (int i = 0; i<max; i++){
if(i<gekauft){ if(i<bought){
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest02.png"); new ShopOfferValue(x + 100 + i*35, y, "images/shopTest02.png");
}else{ }else{
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest01.png"); new ShopOfferValue(x + 100 + i*35, y, "images/shopTest01.png");
@ -36,12 +36,12 @@ public class ShopOffer extends Entity{
public void update() {} public void update() {}
public void buy(){ public void buy(){
new ShopOfferValue(this.getX() + 100 + gekauft*35, this.getY(), "images/shopTest02.png"); new ShopOfferValue(this.getX() + 100 + bought*35, this.getY(), "images/shopTest02.png");
gekauft++; bought++;
} }
public int getGekauft() { public int getBought() {
return gekauft; return bought;
} }
public int getMax() { public int getMax() {

View File

@ -23,17 +23,17 @@ public class ShopScreen extends Screen {
private boolean keyPressed = false; private boolean keyPressed = false;
private Player player; private Player player;
private int animationStatus = 0; //0 = Animation noch nicht gestartet, 1 = Animation laeuft, 2 = Animation beendet private int animationStatus = 0; //0 = Animation noch nicht gestartet, 1 = Animation laeuft, 2 = Animation beendet
private ShopOffer schaden; private ShopOffer damage;
private ShopOffer schild; private ShopOffer shield;
private ShopOffer leben; private ShopOffer life;
public ShopScreen(Screen parent) { public ShopScreen(Screen parent) {
super(parent); super(parent);
this.img = Loader.getBufferedImageByFilename("images/testbackground.png"); this.img = Loader.getBufferedImageByFilename("images/testbackground.png");
new Button(GameConfig.windowWidth/2-125, 450); new Button(GameConfig.windowWidth/2-125, 450);
schaden = new ShopOffer(100, 160, 15, StaticValue.schaden, "Schaden"); damage = new ShopOffer(100, 160, 15, StaticValue.damage, "Schaden");
schild = new ShopOffer(100, 260, 15, StaticValue.schild, "Schild"); shield = new ShopOffer(100, 260, 15, StaticValue.shield, "Schild");
leben = new ShopOffer(100, 360, 15, StaticValue.leben, "Leben"); life = new ShopOffer(100, 360, 15, StaticValue.life, "Leben");
player = new Player(50, 159); player = new Player(50, 159);
player.setCanMove(false); player.setCanMove(false);
player.setCanShoot(false); player.setCanShoot(false);
@ -76,26 +76,26 @@ public class ShopScreen extends Screen {
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
switch (this.menuPoint) { switch (this.menuPoint) {
case 0: case 0:
if(Credits.getCredits() >= 5 && schaden.getGekauft() < schaden.getMax()){ if(Credits.getCredits() >= 5 && damage.getBought() < damage.getMax()){
schaden.buy(); damage.buy();
StaticValue.ShootDamage += 5; StaticValue.shotDamage += 5;
StaticValue.schaden++; StaticValue.damage++;
Credits.setCredits(Credits.getCredits() - 5); Credits.setCredits(Credits.getCredits() - 5);
} }
break; break;
case 1: case 1:
if(Credits.getCredits() >= 10 && schild.getGekauft() < schild.getMax()){ if(Credits.getCredits() >= 10 && shield.getBought() < shield.getMax()){
schild.buy(); shield.buy();
StaticValue.ShieldPoints += 10; StaticValue.shieldPoints += 10;
StaticValue.schild++; StaticValue.shield++;
Credits.setCredits(Credits.getCredits() - 10); Credits.setCredits(Credits.getCredits() - 10);
} }
break; break;
case 2: case 2:
if(Credits.getCredits() >= 10 && leben.getGekauft() < leben.getMax()){ if(Credits.getCredits() >= 10 && life.getBought() < life.getMax()){
leben.buy(); life.buy();
StaticValue.HealthPoints += 10; StaticValue.healthPoints += 10;
StaticValue.leben++; StaticValue.life++;
Credits.setCredits(Credits.getCredits() - 10); Credits.setCredits(Credits.getCredits() - 10);
} }
break; break;