Add DEBUG value in GameConfig.

This commit is contained in:
Jan Philipp Timme 2014-10-28 17:20:55 +01:00
parent 8228c6de20
commit 04e2bcb3f2
5 changed files with 14 additions and 6 deletions

View File

@ -4,6 +4,8 @@ import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import de.teamteamteam.spacescooter.utility.GameConfig;
public abstract class Entity implements Updateable, Paintable {
/**
@ -53,8 +55,10 @@ public abstract class Entity implements Updateable, Paintable {
public void paint(Graphics g) {
//DEBUG ONLY
g.setColor(new Color(255,0,0));
g.drawRect(this.x, this.y, this.getWidth(), this.getHeight());
if(GameConfig.DEBUG) {
g.setColor(new Color(255,0,0));
g.drawRect(this.x, this.y, this.getWidth(), this.getHeight());
}
g.drawImage(this.img, this.x, this.y, null);
}

View File

@ -4,6 +4,7 @@ import java.awt.Rectangle;
import java.util.LinkedList;
import de.teamteamteam.spacescooter.screen.Screen;
import de.teamteamteam.spacescooter.utility.GameConfig;
public abstract class LivingEntity extends Entity implements Collidable {
@ -72,12 +73,12 @@ public abstract class LivingEntity extends Entity implements Collidable {
public void takeDamage(int damage) {
if(this instanceof Shot) {
System.out.println("Shot took damage: " + damage + "left: "+this.getHealthPoints()+" (" + this + ")");
if(GameConfig.DEBUG) System.out.println("Shot took damage: " + damage + "left: "+this.getHealthPoints()+" (" + this + ")");
}
// TODO: shield and health logic
this.healthPoints -= damage;
if (this.isAlive() == false) {
System.out.println(this + " ist gestorben. RIP");
if(GameConfig.DEBUG) System.out.println(this + " ist gestorben. RIP");
Screen.currentScreen.removeEntity(this);
}
}

View File

@ -33,6 +33,7 @@ public class GameFrame extends JFrame {
public void init() {
this.setTitle("Unser schöner Titel");
this.setSize(GameConfig.windowWidth, GameConfig.windowHeight);
this.setResizable(false);
this.setUndecorated(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);

View File

@ -2,7 +2,9 @@ package de.teamteamteam.spacescooter.utility;
public class GameConfig {
public static int windowHeight;
public static boolean DEBUG = false;
public static int windowWidth;
public static int windowHeight;
}

View File

@ -34,7 +34,7 @@ public class GraphicsSettings {
this.height = dm.getHeight();
this.width = dm.getWidth();
System.out.println("Display Mode " + i + ": " + this.width + "x" + this.height+ "@" + this.refreshRate + "Hz, " + this.bitDepth + " bit");
if(GameConfig.DEBUG) System.out.println("Display Mode " + i + ": " + this.width + "x" + this.height+ "@" + this.refreshRate + "Hz, " + this.bitDepth + " bit");
}
}