Make GameConfig actually final, move game screen dimensions into GameConfig.

This commit is contained in:
Jan Philipp Timme 2014-12-02 12:39:56 +01:00
parent 1c80a8745a
commit 110cc98c3b
5 changed files with 40 additions and 40 deletions

View File

@ -1,4 +1,3 @@
name:Testlevel \o/
backgroundMusic:music/ScooterFriendsTurbo8Bit.wav
background:CloudBackground

View File

@ -158,6 +158,7 @@ public class GameFrame extends JFrame {
* Apply rendering hints to the given Graphics2D.
* KEY_ANTIALIASING is very expensive and doesn't do much more over KEY_TEXT_ANTIALIASING
*/
@SuppressWarnings("unused")
private void applyRenderingHints(Graphics2D bufferedGraphics) {
if(GameConfig.keyAntialiasing == true) {
bufferedGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

View File

@ -2,8 +2,9 @@ package de.teamteamteam.spacescooter.brain;
/**
* This static class contains important game configuration.
* Contains initial constant values only.
*/
public class GameConfig {
public final class GameConfig {
/**
* Whether debug output (and more) is enabled or disabled.
@ -13,47 +14,69 @@ public class GameConfig {
/**
* Width of GameWindow.
*/
public static int windowWidth = 800;
public static final int windowWidth = 800;
/**
* Height of GameWindow.
*/
public static int windowHeight = 650;
public static final int windowHeight = 650;
/**
* Offset where the X=0 coordinate of the actual game screen starts.
*/
public static final int gameScreenXOffset = 0;
/**
* Offset where the Y=0 coordinate of the actual game screen starts.
* This is currently influenced by the 50px interface bar at the top.
*/
public static final int gameScreenYOffset = 50;
/**
* Actual width of the game screen.
*/
public static final int gameScreenWidth = GameConfig.windowWidth;
/**
* Actual height of the game screen.
* This is currently influenced by the 50px interface bar at the top.
*/
public static final int gameScreenHeight = GameConfig.windowHeight - 50;
/**
* Title of the game window.
*/
public static String windowTitle = "SpaceScooter!";
public static final String windowTitle = "SpaceScooter!";
/**
* Whether or not anti aliasing will be used for shapes.
*/
public static boolean keyAntialiasing = false;
public static final boolean keyAntialiasing = false;
/**
* Whether or not to apply anti aliasing on text.
*/
public static boolean textAntialiasing = false;
public static final boolean textAntialiasing = false;
/**
* The maximum number of points a player can reach.
*/
public static int maximumPlayerScore = 99999999;
public static final int maximumPlayerScore = 99999999;
/**
* Initial health points the player will have.
*/
public static int initialPlayerHealthPoints = 100;
public static final int initialPlayerHealthPoints = 100;
/**
* Initial shield points the player ship will have.
*/
public static int initialPlayerShieldPoints = 0;
public static final int initialPlayerShieldPoints = 0;
/**
* Damage the player ships shots will cause initially.
*/
public static int initialPlayerShotDamage = 10;
public static final int initialPlayerShotDamage = 10;
/**
* Private constructor, this class will never be instantiated.

View File

@ -1,5 +1,6 @@
package de.teamteamteam.spacescooter.entity.enemy;
import de.teamteamteam.spacescooter.brain.GameConfig;
import de.teamteamteam.spacescooter.entity.explosion.MultiExplosion;
import de.teamteamteam.spacescooter.gui.BossHealthBar;
import de.teamteamteam.spacescooter.utility.Random;
@ -42,7 +43,7 @@ public class EnemyBoss extends Enemy{
@Override
public void update() {
super.update();
this.setPosition(750, this.getY()+move);
this.setPosition(GameConfig.windowWidth-65, this.getY()+move);
if(this.getY() == 51){
move = 1;
}

View File

@ -52,26 +52,6 @@ public final class Level {
*/
private int gameOverDelay;
/**
* Offset for game screen 0 coordinate on X axis.
*/
private int gameScreenXOffset;
/**
* Offset for game screen 0 coordinate on Y axis.
*/
private int gameScreenYOffset;
/**
* Actual width of game screen.
*/
private int gameScreenWidth;
/**
* Actual height of game screen.
*/
private int gameScreenHeight;
/**
* Constructor creating a LevelConfig based on a given config file.
*/
@ -80,12 +60,6 @@ public final class Level {
this.isGameOver = false;
this.gameOverDelay = 3;
this.config = Loader.getLevelConfigByFilename(levelConfig);
//TODO: Put this into the GameConfig!
this.gameScreenXOffset = 0;
this.gameScreenYOffset = 50;
this.gameScreenWidth = GameConfig.windowWidth - 1; //This is fine.
this.gameScreenHeight = GameConfig.windowHeight - 51; //TODO: NOT HARDCODE THIS :/
}
@ -131,8 +105,10 @@ public final class Level {
if(relativeTimeWithinCurrentInterval % Math.max(1,intervalModulus) == 0) {
//If the rule matches the current time, spawn the configured Entity in the configured amount:
for(int i=0; i<spawnRule[2]; i++) {
int x = this.gameScreenWidth + this.gameScreenXOffset - 1;
int y = Math.round((this.gameScreenHeight * spawnRule[4]) / 100) + this.gameScreenYOffset - 1;
//Minus one because the upper border is _excluded_ from the range!
int x = GameConfig.gameScreenWidth + GameConfig.gameScreenXOffset - 1;
//Minus one because the upper border is _excluded_ from the range!
int y = Math.round((GameConfig.gameScreenHeight * spawnRule[4]) / 100) + GameConfig.gameScreenYOffset - 1;
this.spawnEntityByAvailableName(Entity.availableNames.values()[spawnRule[1]], x, y);
}
}