feat: improved the menus, turn system still broken by me
This commit is contained in:
parent
bcfdc1e5d5
commit
91008f575b
|
@ -56,6 +56,5 @@ project(":core") {
|
||||||
dependencies {
|
dependencies {
|
||||||
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
api "com.kotcrab.vis:vis-ui:1.3.0"
|
api "com.kotcrab.vis:vis-ui:1.3.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
package sagittarius;
|
package sagittarius;
|
||||||
|
|
||||||
import com.badlogic.gdx.Game;
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.kotcrab.vis.ui.VisUI;
|
||||||
|
|
||||||
import sagittarius.view.BaseScreen;
|
import sagittarius.view.BaseScreen;
|
||||||
import sagittarius.view.GameScreen;
|
import sagittarius.view.StartScreen;
|
||||||
|
|
||||||
public class SagittariusGame extends Game {
|
public class SagittariusGame extends Game {
|
||||||
|
|
||||||
// Constants
|
private static Game game;
|
||||||
public static final int G = 100;
|
|
||||||
|
|
||||||
// Game
|
|
||||||
public static GameScreen gameScreen;
|
|
||||||
private static SagittariusGame game;
|
|
||||||
|
|
||||||
public SagittariusGame() {
|
public SagittariusGame() {
|
||||||
game = this;
|
game = this;
|
||||||
|
@ -28,7 +24,8 @@ public class SagittariusGame extends Game {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
gameScreen = new GameScreen();
|
VisUI.load();
|
||||||
this.setScreen(gameScreen);
|
game.setScreen(new StartScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
import sagittarius.SagittariusGame;
|
|
||||||
import sagittarius.view.GameScreen;
|
import sagittarius.view.GameScreen;
|
||||||
|
|
||||||
public class Arrow extends BaseActor {
|
public class Arrow extends BaseActor {
|
||||||
|
@ -55,6 +54,7 @@ public class Arrow extends BaseActor {
|
||||||
this.TTL -= dt;
|
this.TTL -= dt;
|
||||||
this.setRotation(this.velocity.angleDeg());
|
this.setRotation(this.velocity.angleDeg());
|
||||||
verifyLanding();
|
verifyLanding();
|
||||||
|
verifyHittingPlayer();
|
||||||
|
|
||||||
if (TTL <= 0) {
|
if (TTL <= 0) {
|
||||||
GameScreen.arrows.removeActor(this);
|
GameScreen.arrows.removeActor(this);
|
||||||
|
@ -88,7 +88,7 @@ public class Arrow extends BaseActor {
|
||||||
|
|
||||||
float len2 = dx*dx + dy*dy;
|
float len2 = dx*dx + dy*dy;
|
||||||
|
|
||||||
float coeff = SagittariusGame.G * ((Planet) actor).getMass() * (float) Math.pow(len2, -3/2);
|
float coeff = GameScreen.G * ((Planet) actor).getMass() * (float) Math.pow(len2, -3/2);
|
||||||
|
|
||||||
float gravityX = coeff * dx;
|
float gravityX = coeff * dx;
|
||||||
float gravityY = coeff * dy;
|
float gravityY = coeff * dy;
|
||||||
|
@ -132,13 +132,25 @@ public class Arrow extends BaseActor {
|
||||||
landed = true;
|
landed = true;
|
||||||
this.crash = planet;
|
this.crash = planet;
|
||||||
this.offset = this.getPosition().sub( planet.getPosition() );
|
this.offset = this.getPosition().sub( planet.getPosition() );
|
||||||
|
Bow.changeShooter(GameScreen.nextTurn());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyHittingPlayer() {
|
private void verifyHittingPlayer() {
|
||||||
|
for (Actor actor : GameScreen.players.getChildren()) {
|
||||||
|
|
||||||
|
Player player = (Player) actor;
|
||||||
|
|
||||||
|
if (TTL < 19 && player.hitbox.contains(getX(), getY())) {
|
||||||
|
landed = true;
|
||||||
|
GameScreen.players.removeActor(player);
|
||||||
|
GameScreen.arrows.removeActor(this);
|
||||||
|
Bow.changeShooter(GameScreen.nextTurn());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** // TODO : pass directly an Arrow instead of 3 arguments
|
/** // TODO : pass directly an Arrow instead of 3 arguments
|
||||||
|
@ -154,6 +166,8 @@ public class Arrow extends BaseActor {
|
||||||
Arrow dummyArrow = new Arrow(angle, power, shooter);
|
Arrow dummyArrow = new Arrow(angle, power, shooter);
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
dummyArrow.integrationVerlet(timeStep);
|
dummyArrow.integrationVerlet(timeStep);
|
||||||
|
// dummyArrow.verifyLanding();
|
||||||
|
// dummyArrow.verifyHittingPlayer(); // fix -> return booleans, take action after
|
||||||
path.add(dummyArrow.getX());
|
path.add(dummyArrow.getX());
|
||||||
path.add(dummyArrow.getY());
|
path.add(dummyArrow.getY());
|
||||||
}
|
}
|
||||||
|
@ -170,10 +184,6 @@ public class Arrow extends BaseActor {
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 getPosition() {
|
|
||||||
return new Vector2( getX(), getY() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInfo() {
|
protected String getInfo() {
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,22 +1,34 @@
|
||||||
package sagittarius.model;
|
package sagittarius.model;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||||
|
import com.badlogic.gdx.math.Intersector;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
import com.badlogic.gdx.math.Polygon;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
public abstract class BaseActor extends Actor {
|
public abstract class BaseActor extends Actor {
|
||||||
|
|
||||||
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
static private BitmapFont fontDebug = new BitmapFont();
|
static private BitmapFont fontDebug = new BitmapFont();
|
||||||
|
|
||||||
/**
|
protected Polygon hitbox = new Polygon(test());
|
||||||
* @return debug String displayed in {@link #draw()}
|
|
||||||
*/
|
|
||||||
protected abstract String getInfo();
|
|
||||||
|
|
||||||
protected float angle; // encapsulate ?
|
protected float angle; // encapsulate ?
|
||||||
|
|
||||||
|
// ---------- METHODs ----------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
super.act(delta);
|
||||||
|
hitbox.setVertices(test());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
|
@ -28,11 +40,63 @@ public abstract class BaseActor extends Actor {
|
||||||
if (!getDebug()) return;
|
if (!getDebug()) return;
|
||||||
shapes.set(ShapeType.Line);
|
shapes.set(ShapeType.Line);
|
||||||
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
|
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
|
||||||
shapes.rect(getX() - getOriginX(), getY() - getOriginY(),
|
// shapes.rect(getX() - getOriginX(), getY() - getOriginY(),
|
||||||
getOriginX(), getOriginY(),
|
// getOriginX(), getOriginY(),
|
||||||
getWidth(), getHeight(),
|
// getWidth(), getHeight(),
|
||||||
getScaleX(), getScaleY(),
|
// getScaleX(), getScaleY(),
|
||||||
getRotation());
|
// getRotation());
|
||||||
|
shapes.setColor(Color.RED);
|
||||||
|
shapes.polygon(test());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ShapeRenderer#rect}
|
||||||
|
* @return vertices of the hitbox polygon
|
||||||
|
*/
|
||||||
|
protected float[] test() { // convert position + rotation and other shit to polygon
|
||||||
|
float cos = MathUtils.cosDeg(getRotation());
|
||||||
|
float sin = MathUtils.sinDeg(getRotation());
|
||||||
|
float fx = -getOriginX();
|
||||||
|
float fy = -getOriginY();
|
||||||
|
float fx2 = getWidth() - getOriginX();
|
||||||
|
float fy2 = getHeight() - getOriginY();
|
||||||
|
|
||||||
|
if (getScaleX() != 1 || getScaleX() != 1) {
|
||||||
|
fx *= getScaleX();
|
||||||
|
fy *= getScaleY();
|
||||||
|
fx2 *= getScaleX();
|
||||||
|
fy2 *= getScaleY();
|
||||||
|
}
|
||||||
|
|
||||||
|
float worldOriginX = getX();
|
||||||
|
float worldOriginY = getY();
|
||||||
|
|
||||||
|
float x1 = cos * fx - sin * fy + worldOriginX;
|
||||||
|
float y1 = sin * fx + cos * fy + worldOriginY;
|
||||||
|
|
||||||
|
float x2 = cos * fx2 - sin * fy + worldOriginX;
|
||||||
|
float y2 = sin * fx2 + cos * fy + worldOriginY;
|
||||||
|
|
||||||
|
float x3 = cos * fx2 - sin * fy2 + worldOriginX;
|
||||||
|
float y3 = sin * fx2 + cos * fy2 + worldOriginY;
|
||||||
|
|
||||||
|
float x4 = x1 + (x3 - x2);
|
||||||
|
float y4 = y3 - (y2 - y1);
|
||||||
|
|
||||||
|
return new float[] { x1, y1, x2, y2, x3, y3, x4, y4 };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return debug String displayed in {@link #draw()}
|
||||||
|
*/
|
||||||
|
protected abstract String getInfo();
|
||||||
|
|
||||||
|
protected boolean overlaps(BaseActor other) {
|
||||||
|
return Intersector.overlapConvexPolygons(hitbox, other.hitbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 getPosition() {
|
||||||
|
return new Vector2( getX(), getY() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class Bow extends Actor {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
private Player shooter;
|
private static Player shooter;
|
||||||
private boolean aimAssist = false;
|
private boolean aimAssist = false;
|
||||||
private boolean pressed = false;
|
private boolean pressed = false;
|
||||||
private float angle;
|
private float angle;
|
||||||
|
@ -25,9 +25,8 @@ public class Bow extends Actor {
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
public Bow(Player shooter, boolean aimAssist) {
|
public Bow(boolean aimAssist) {
|
||||||
super();
|
super();
|
||||||
this.shooter = shooter;
|
|
||||||
this.aimAssist = aimAssist;
|
this.aimAssist = aimAssist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +41,8 @@ public class Bow extends Actor {
|
||||||
} else if (Gdx.input.isButtonPressed(Buttons.LEFT) && pressed) {
|
} else if (Gdx.input.isButtonPressed(Buttons.LEFT) && pressed) {
|
||||||
computeArrow();
|
computeArrow();
|
||||||
} else if (pressed) {
|
} else if (pressed) {
|
||||||
GameScreen.arrows.addActor(getArrow());
|
|
||||||
pressed = false;
|
pressed = false;
|
||||||
|
GameScreen.arrows.addActor(getArrow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +79,8 @@ public class Bow extends Actor {
|
||||||
return new Arrow(angle, power, shooter);
|
return new Arrow(angle, power, shooter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeShooter(Player newShooter) {
|
public static void changeShooter(Player newShooter) {
|
||||||
this.shooter = newShooter;
|
shooter = newShooter;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package sagittarius.model;
|
package sagittarius.model;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
import sagittarius.view.GameScreen;
|
import sagittarius.view.GameScreen;
|
||||||
|
|
||||||
public class MouseInfo extends BaseActor {
|
public class MouseInfo extends BaseActor {
|
||||||
|
@ -9,7 +11,7 @@ public class MouseInfo extends BaseActor {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
setX(GameScreen.worldCursor.x);
|
setX(GameScreen.worldCursor.x); // use direct method
|
||||||
setY(GameScreen.worldCursor.y);
|
setY(GameScreen.worldCursor.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,6 @@ public class Planet extends BaseActor {
|
||||||
return mass;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 getPosition() {
|
|
||||||
return new Vector2( getX(), getY() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getInfo() {
|
protected String getInfo() {
|
||||||
return
|
return
|
||||||
|
|
|
@ -4,8 +4,6 @@ import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.GL30;
|
import com.badlogic.gdx.graphics.GL30;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
|
||||||
import sagittarius.model.BaseActor;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
|
|
||||||
public abstract class BaseScreen implements Screen {
|
public abstract class BaseScreen implements Screen {
|
||||||
|
|
|
@ -22,7 +22,10 @@ public class GameScreen extends BaseScreen {
|
||||||
public static Group arrows;
|
public static Group arrows;
|
||||||
public static Group players;
|
public static Group players;
|
||||||
|
|
||||||
private int playerTurn;
|
// Constants
|
||||||
|
public static float G = 100;
|
||||||
|
|
||||||
|
public static int playerTurn;
|
||||||
|
|
||||||
// ---------- METHODs ----------
|
// ---------- METHODs ----------
|
||||||
|
|
||||||
|
@ -59,7 +62,7 @@ public class GameScreen extends BaseScreen {
|
||||||
mainStage.addActor(arrows);
|
mainStage.addActor(arrows);
|
||||||
|
|
||||||
// The one and only Bow
|
// The one and only Bow
|
||||||
Bow bow = new Bow(player1, true);
|
Bow bow = new Bow(true);
|
||||||
mainStage.addActor(bow);
|
mainStage.addActor(bow);
|
||||||
|
|
||||||
// others
|
// others
|
||||||
|
@ -75,6 +78,7 @@ public class GameScreen extends BaseScreen {
|
||||||
// game turns
|
// game turns
|
||||||
playerTurn = 0;
|
playerTurn = 0;
|
||||||
player1.setActive(true);
|
player1.setActive(true);
|
||||||
|
Bow.changeShooter(player1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,30 +89,40 @@ public class GameScreen extends BaseScreen {
|
||||||
unprojectedCursor = mainStage.getCamera().unproject(new Vector3(screenCursor, 0));
|
unprojectedCursor = mainStage.getCamera().unproject(new Vector3(screenCursor, 0));
|
||||||
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);
|
worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y);
|
||||||
|
|
||||||
Player actualPlayer = (Player) players.getChild(playerTurn);
|
// Player actualPlayer = (Player) players.getChild(playerTurn);
|
||||||
if (actualPlayer.isActive()) {
|
// if (actualPlayer.isActive()) {
|
||||||
actualPlayer.setActive(true);
|
// actualPlayer.setActive(true);
|
||||||
playerTurn++;
|
// playerTurn++;
|
||||||
playerTurn %= players.getChildren().size;
|
// playerTurn %= players.getChildren().size;
|
||||||
actualPlayer = (Player) players.getChild(playerTurn);
|
// actualPlayer = (Player) players.getChild(playerTurn);
|
||||||
actualPlayer.setActive(false);
|
// actualPlayer.setActive(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
public static Player nextTurn() {
|
||||||
int index = players.getChildren().indexOf(player, true);
|
((Player) players.getChild(playerTurn++)).setActive(false);
|
||||||
if (index < playerTurn) {
|
if ( playerTurn % players.getChildren().size == 0 ) {
|
||||||
players.removeActor(player);
|
playerTurn = 0;
|
||||||
playerTurn++;
|
|
||||||
playerTurn %= players.getChildren().size;
|
|
||||||
} else if (index == playerTurn) {
|
|
||||||
players.removeActor(player);
|
|
||||||
playerTurn %= players.getChildren().size;
|
|
||||||
Player actualPlayer = (Player) players.getChild(playerTurn);
|
|
||||||
actualPlayer.setActive(true);
|
|
||||||
} else {
|
|
||||||
players.removeActor(player);
|
|
||||||
}
|
}
|
||||||
|
Player newPlayer = (Player) players.getChild(playerTurn);
|
||||||
|
newPlayer.setActive(true);
|
||||||
|
return newPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void removePlayer(Player player) {
|
||||||
|
// int index = players.getChildren().indexOf(player, true);
|
||||||
|
// if (index < playerTurn) {
|
||||||
|
// players.removeActor(player);
|
||||||
|
// playerTurn++;
|
||||||
|
// playerTurn %= players.getChildren().size;
|
||||||
|
// } else if (index == playerTurn) {
|
||||||
|
// players.removeActor(player);
|
||||||
|
// playerTurn %= players.getChildren().size;
|
||||||
|
// Player actualPlayer = (Player) players.getChild(playerTurn);
|
||||||
|
// actualPlayer.setActive(true);
|
||||||
|
// } else {
|
||||||
|
// players.removeActor(player);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
81
core/src/sagittarius/view/SettingsScreen.java
Normal file
81
core/src/sagittarius/view/SettingsScreen.java
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
package sagittarius.view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
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.VisLabel;
|
||||||
|
import com.kotcrab.vis.ui.widget.VisTable;
|
||||||
|
import com.kotcrab.vis.ui.widget.VisTextButton;
|
||||||
|
import com.kotcrab.vis.ui.widget.VisValidatableTextField;
|
||||||
|
|
||||||
|
import sagittarius.SagittariusGame;
|
||||||
|
|
||||||
|
public class SettingsScreen extends BaseScreen {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
|
||||||
|
Gdx.input.setInputProcessor(mainStage);
|
||||||
|
|
||||||
|
// Table creation
|
||||||
|
VisTable table = new VisTable(true);
|
||||||
|
table.setFillParent(true);
|
||||||
|
mainStage.addActor(table);
|
||||||
|
|
||||||
|
VisLabel errorLabel = new VisLabel();
|
||||||
|
errorLabel.setColor(Color.RED);
|
||||||
|
|
||||||
|
VisValidatableTextField gConstField = new VisValidatableTextField();
|
||||||
|
|
||||||
|
VisTextButton saveButton = new VisTextButton("Save");
|
||||||
|
saveButton.addListener(new ActorGestureListener() {
|
||||||
|
@Override
|
||||||
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
VisTextButton returnButton = new VisTextButton("Go Back");
|
||||||
|
returnButton.addListener(new ActorGestureListener() {
|
||||||
|
@Override
|
||||||
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
|
super.tap(event, x, y, count, button);
|
||||||
|
SagittariusGame.setActiveScreen( new StartScreen() );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleFormValidator validator;
|
||||||
|
validator = new SimpleFormValidator(saveButton, errorLabel, "smooth");
|
||||||
|
validator.notEmpty(gConstField, "G cannot be empty");
|
||||||
|
validator.floatNumber(gConstField, "G must be a float");
|
||||||
|
validator.valueGreaterThan(gConstField, "G must be positive", 0, true);
|
||||||
|
|
||||||
|
// Table structure
|
||||||
|
table.add(errorLabel);
|
||||||
|
table.row();
|
||||||
|
table.add(new VisLabel("G constant:"));
|
||||||
|
table.add(gConstField);
|
||||||
|
table.row();
|
||||||
|
table.add(saveButton);
|
||||||
|
table.row();
|
||||||
|
table.add(returnButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float dt) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
VisUI.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
core/src/sagittarius/view/SetupScreen.java
Normal file
34
core/src/sagittarius/view/SetupScreen.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package sagittarius.view;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.kotcrab.vis.ui.VisUI;
|
||||||
|
import com.kotcrab.vis.ui.widget.VisTable;
|
||||||
|
|
||||||
|
|
||||||
|
public class SetupScreen extends BaseScreen {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
|
||||||
|
Gdx.input.setInputProcessor(uiStage);
|
||||||
|
|
||||||
|
// Table creation
|
||||||
|
VisUI.load();
|
||||||
|
VisTable table = new VisTable(true);
|
||||||
|
table.setFillParent(true);
|
||||||
|
uiStage.addActor(table);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float dt) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
VisUI.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,17 +14,25 @@ public class StartScreen extends BaseScreen {
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(mainStage);
|
Gdx.input.setInputProcessor(uiStage);
|
||||||
|
|
||||||
// Table creation
|
// Table creation
|
||||||
VisUI.load();
|
|
||||||
VisTable table = new VisTable(true);
|
VisTable table = new VisTable(true);
|
||||||
table.setFillParent(true);
|
table.setFillParent(true);
|
||||||
mainStage.addActor(table);
|
uiStage.addActor(table);
|
||||||
|
|
||||||
// Start Button
|
VisTextButton setupButton = new VisTextButton("Setup a game");
|
||||||
VisTextButton startButton = new VisTextButton("start");
|
setupButton.addListener(new ActorGestureListener() {
|
||||||
startButton.addListener(new ActorGestureListener() {
|
@Override
|
||||||
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
|
super.tap(event, x, y, count, button);
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// quick Button
|
||||||
|
VisTextButton quickButton = new VisTextButton("Quick Game");
|
||||||
|
quickButton.addListener(new ActorGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
super.tap(event, x, y, count, button);
|
super.tap(event, x, y, count, button);
|
||||||
|
@ -32,8 +40,17 @@ public class StartScreen extends BaseScreen {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
VisTextButton settingsButton = new VisTextButton("Settings");
|
||||||
|
settingsButton.addListener(new ActorGestureListener() {
|
||||||
|
@Override
|
||||||
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
|
super.tap(event, x, y, count, button);
|
||||||
|
SagittariusGame.setActiveScreen( new SettingsScreen() );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Quit button
|
// Quit button
|
||||||
VisTextButton quitButton = new VisTextButton("quit");
|
VisTextButton quitButton = new VisTextButton("Exit");
|
||||||
quitButton.addListener(new ActorGestureListener() {
|
quitButton.addListener(new ActorGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
|
@ -43,15 +60,19 @@ public class StartScreen extends BaseScreen {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Table structure
|
// Table structure
|
||||||
table.add(startButton);
|
table.add(setupButton).width(150);
|
||||||
table.row();
|
table.row();
|
||||||
table.add(quitButton);
|
table.add(quickButton).width(150);
|
||||||
|
table.row();
|
||||||
|
table.add(settingsButton).width(150);
|
||||||
|
table.row();
|
||||||
|
table.add(quitButton).width(150);
|
||||||
table.row();
|
table.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
//
|
// nothing (?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue