Show boundingbox info/debug with 'o'

This commit is contained in:
Asecave 2021-06-30 17:08:57 +02:00
parent e643ec092d
commit 3a65c74546
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main;
import ea.Game;
import ea.Taste;
import main.HUD.HUD;
import main.worlds.TestWorld;
import main.worlds.World;
@ -11,6 +12,7 @@ import main.worlds.World;
public class Main extends Game {
public static Main instance;
public static boolean SHOW_DEBUG = false;
private World world;
private HUD hud;
@ -33,6 +35,9 @@ public class Main extends Game {
@Override
public void tasteReagieren(int code) {
if (code == Taste.O) {
SHOW_DEBUG = !SHOW_DEBUG;
}
}
public World getWorld() {

View File

@ -37,11 +37,14 @@ public abstract class AnimatedEntity extends Entity {
@Override
public void zeichnen(Graphics2D g, BoundingRechteck r) {
g.setColor(Color.GREEN);
if (Main.SHOW_DEBUG) {
g.setColor(Color.CYAN);
g.drawRect((int) actionFigur.positionX(), (int) actionFigur.positionY(),
(int) actionFigur.getBreite(), (int) actionFigur.getHoehe());
g.setColor(Color.GREEN);
g.drawRect((int) ((posX - width / 2) * World.SCALE), (int) ((posY - height / 2) * World.SCALE),
(int) (width * World.SCALE), (int) (height * World.SCALE));
}
super.zeichnen(g, r);
}
};
@ -62,7 +65,7 @@ public abstract class AnimatedEntity extends Entity {
}
/**
* Spiegelt die figur autmatisch, wenn n<EFBFBD>tig.
* Spiegelt die figur autmatisch, wenn nötig.
*/
protected void zustandSetzen(String name) {
actionFigur.spiegelXSetzen(side);