Refactor brain package to english variable names.
This commit is contained in:
parent
0afa327fda
commit
d38f016ee0
|
@ -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) {
|
||||
|
|
|
@ -44,5 +44,8 @@ public class Credits {
|
|||
*/
|
||||
public static void remove(int credits) {
|
||||
Credits.credits -= credits;
|
||||
if(Credits.credits < 0) {
|
||||
Credits.credits = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.setScore(Score.maxScore);
|
||||
} else if (Score.score != Score.maxScore) {
|
||||
Score.score += score;
|
||||
if (Score.score >= Score.maxScore) {
|
||||
Score.setScore(Score.maxScore);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for removing Score
|
||||
* Method for removing Score, capping it at zero.
|
||||
*/
|
||||
public static void removeScore(int score) {
|
||||
if (Score.score - score <= 0) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@ import de.teamteamteam.spacescooter.entity.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<max; i++){
|
||||
if(i<gekauft){
|
||||
if(i<bought){
|
||||
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest02.png");
|
||||
}else{
|
||||
new ShopOfferValue(x + 100 + i*35, y, "images/shopTest01.png");
|
||||
|
@ -36,12 +36,12 @@ public class ShopOffer extends Entity{
|
|||
public void update() {}
|
||||
|
||||
public void buy(){
|
||||
new ShopOfferValue(this.getX() + 100 + gekauft*35, this.getY(), "images/shopTest02.png");
|
||||
gekauft++;
|
||||
new ShopOfferValue(this.getX() + 100 + bought*35, this.getY(), "images/shopTest02.png");
|
||||
bought++;
|
||||
}
|
||||
|
||||
public int getGekauft() {
|
||||
return gekauft;
|
||||
public int getBought() {
|
||||
return bought;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
|
|
|
@ -23,17 +23,17 @@ public class ShopScreen extends Screen {
|
|||
private boolean keyPressed = false;
|
||||
private Player player;
|
||||
private int animationStatus = 0; //0 = Animation noch nicht gestartet, 1 = Animation laeuft, 2 = Animation beendet
|
||||
private ShopOffer schaden;
|
||||
private ShopOffer schild;
|
||||
private ShopOffer leben;
|
||||
private ShopOffer damage;
|
||||
private ShopOffer shield;
|
||||
private ShopOffer life;
|
||||
|
||||
public ShopScreen(Screen parent) {
|
||||
super(parent);
|
||||
this.img = Loader.getBufferedImageByFilename("images/testbackground.png");
|
||||
new Button(GameConfig.windowWidth/2-125, 450);
|
||||
schaden = new ShopOffer(100, 160, 15, StaticValue.schaden, "Schaden");
|
||||
schild = new ShopOffer(100, 260, 15, StaticValue.schild, "Schild");
|
||||
leben = new ShopOffer(100, 360, 15, StaticValue.leben, "Leben");
|
||||
damage = new ShopOffer(100, 160, 15, StaticValue.damage, "Schaden");
|
||||
shield = new ShopOffer(100, 260, 15, StaticValue.shield, "Schild");
|
||||
life = new ShopOffer(100, 360, 15, StaticValue.life, "Leben");
|
||||
player = new Player(50, 159);
|
||||
player.setCanMove(false);
|
||||
player.setCanShoot(false);
|
||||
|
@ -76,26 +76,26 @@ public class ShopScreen extends Screen {
|
|||
///////////////////////////////////////////////////////////////
|
||||
switch (this.menuPoint) {
|
||||
case 0:
|
||||
if(Credits.getCredits() >= 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;
|
||||
|
|
Loading…
Reference in New Issue