Skip to content

Commit

Permalink
Simplify debug hotkeys, keep 4: debug-physics, gui, restart, spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Henauxg committed Jun 24, 2023
1 parent 1d2eac7 commit 46b6a04
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions core/src/fr/baldurcrew/gdx25/CoreGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class CoreGame extends ApplicationAdapter {
public static boolean debugEnableWaterDrag = true;
public static boolean debugEnableFakeWaterVelocity = true;
public static boolean debugEnableLiftForce = true;
public static boolean debugEnableImGui = false;
public SpriteBatch spriteBatch;
private List<ParallaxLayer> backgroundLayers;
private List<ParallaxLayer> foregroundLayers;
Expand Down Expand Up @@ -121,6 +122,7 @@ public class CoreGame extends ApplicationAdapter {
private float[] uiSailingTime = new float[1];
private GameState gameState;


@Override
public void create() {
gameState = GameState.WaitingToStart;
Expand Down Expand Up @@ -307,7 +309,9 @@ private void renderImGui() {
imGuiGlfw.newFrame();
ImGui.newFrame();
// --- ImGUI draw commands go here ---
drawUI();
if (debugEnableImGui) {
drawUI();
}
// ---
ImGui.render();
imGuiGl3.renderDrawData(ImGui.getDrawData());
Expand Down Expand Up @@ -471,36 +475,15 @@ public void handleDebugInputs(OrthographicCamera camera) {
if (Gdx.input.isKeyJustPressed(Input.Keys.F1)) {
debugMode = !debugMode;
}
if (debugMode) {
if (Gdx.input.isKeyJustPressed(Input.Keys.F2)) {
debugEnableWaterRendering = !debugEnableWaterRendering;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F3)) {
debugEnableBoatRendering = !debugEnableBoatRendering;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F4)) {
debugClearColor = !debugClearColor;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F5)) {
debugEnableWaveGeneration = !debugEnableWaveGeneration;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F6)) {
debugEnableCharacterGeneration = !debugEnableCharacterGeneration;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F12)) {
disposeCurrentLevel();
createTestLevel();
}
if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) {
playerCharacter = this.spawnCharacter(CharacterResources.getPlayerCharacterIndex(), false, charactersSpawnRangeX.getRandom(), charactersSpawnRangeY.getRandom());
}

if (Gdx.input.justTouched()) {
float xViewportPercent = (float) Gdx.input.getX() / (float) Gdx.graphics.getWidth();
float xWorld = xViewportPercent * Constants.VIEWPORT_WIDTH;
monster.eat(spawnCharacter(CharacterResources.getRandomCharacterIndex(), true, xWorld, water.getWaterLevel()));
water.handleInput(xWorld);
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F2)) {
debugEnableImGui = !debugEnableImGui;
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F3)) {
disposeCurrentLevel();
createTestLevel();
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F4)) {
playerCharacter = this.spawnCharacter(CharacterResources.getPlayerCharacterIndex(), false, charactersSpawnRangeX.getRandom(), charactersSpawnRangeY.getRandom());
}
}

Expand Down

0 comments on commit 46b6a04

Please sign in to comment.