diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index b632607..466eba6 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -8,8 +8,12 @@ import sagittarius.view.StartScreen; public class SagittariusGame extends Game { + // Constants + public static float G = 100; + public static boolean debugMode = true; + private static Game game; - + public SagittariusGame() { game = this; } diff --git a/core/src/sagittarius/model/Arrow.java b/core/src/sagittarius/model/Arrow.java index a216bcd..8097e21 100644 --- a/core/src/sagittarius/model/Arrow.java +++ b/core/src/sagittarius/model/Arrow.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; +import sagittarius.SagittariusGame; import sagittarius.view.GameScreen; public class Arrow extends BaseActor { @@ -88,7 +89,7 @@ public class Arrow extends BaseActor { float len2 = dx*dx + dy*dy; - float coeff = GameScreen.G * ((Planet) actor).getMass() * (float) Math.pow(len2, -3/2); + float coeff = SagittariusGame.G * ((Planet) actor).getMass() * (float) Math.pow(len2, -3/2); float gravityX = coeff * dx; float gravityY = coeff * dy; diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index 9422318..17c614e 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.Group; +import sagittarius.SagittariusGame; import sagittarius.model.*; public class GameScreen extends BaseScreen { @@ -22,9 +23,6 @@ public class GameScreen extends BaseScreen { public static Group arrows; public static Group players; - // Constants - public static float G = 100; - public static int playerTurn; // ---------- METHODs ---------- @@ -72,8 +70,8 @@ public class GameScreen extends BaseScreen { MouseInfo mouseInfo = new MouseInfo(); uiStage.addActor(mouseInfo); - mainStage.setDebugAll(true); // TODO: disable later - uiStage.setDebugAll(true); // TODO: disable later + mainStage.setDebugAll(SagittariusGame.debugMode); + uiStage.setDebugAll(SagittariusGame.debugMode); // game turns playerTurn = 0; diff --git a/core/src/sagittarius/view/SettingsScreen.java b/core/src/sagittarius/view/SettingsScreen.java index 2480c17..6f5a744 100644 --- a/core/src/sagittarius/view/SettingsScreen.java +++ b/core/src/sagittarius/view/SettingsScreen.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; import com.kotcrab.vis.ui.VisUI; import com.kotcrab.vis.ui.util.form.SimpleFormValidator; +import com.kotcrab.vis.ui.widget.VisCheckBox; import com.kotcrab.vis.ui.widget.VisLabel; import com.kotcrab.vis.ui.widget.VisTable; import com.kotcrab.vis.ui.widget.VisTextButton; @@ -29,7 +30,10 @@ public class SettingsScreen extends BaseScreen { errorLabel.setColor(Color.RED); VisValidatableTextField gConstField = new VisValidatableTextField(); - gConstField.setText(Float.toString(GameScreen.G)); + gConstField.setText(Float.toString(SagittariusGame.G)); + + VisCheckBox debugModeBox = new VisCheckBox("debug mode"); + debugModeBox.setChecked(SagittariusGame.debugMode); VisTextButton saveButton = new VisTextButton("Save"); saveButton.addListener(new ActorGestureListener() { @@ -37,7 +41,8 @@ public class SettingsScreen extends BaseScreen { public void tap(InputEvent event, float x, float y, int count, int button) { super.tap(event, x, y, count, button); - GameScreen.G = Float.parseFloat(gConstField.getText()); + SagittariusGame.G = Float.parseFloat(gConstField.getText()); + SagittariusGame.debugMode = debugModeBox.isChecked(); } }); @@ -63,6 +68,8 @@ public class SettingsScreen extends BaseScreen { table.add(new VisLabel("G constant:")); table.add(gConstField); table.row(); + table.add(debugModeBox).colspan(2); + table.row(); table.add(saveButton).colspan(2); table.row(); table.add(returnButton).colspan(2);