feat: added a debugMode checkbox to settings
This commit is contained in:
parent
0355d98baf
commit
eff5fc1f99
|
@ -8,6 +8,10 @@ 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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue