diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index 7bb51a8..7fd1eb9 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -9,6 +9,9 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; +import sagittarius.view.*; +import sagittarius.model.*; + public class SagittariusGame extends Game { // ---------- ATTRIBUTEs ---------- @@ -31,7 +34,7 @@ public class SagittariusGame extends Game { @Override public void create() { - setScreen(new GameScreen()); + setScreen(new StartScreen(this)); planetList = new ArrayList(); planetList.add( new Planet(new Vector2(400, 400), 1000, 50) ); diff --git a/core/src/sagittarius/view/StartScreen.java b/core/src/sagittarius/view/StartScreen.java new file mode 100644 index 0000000..d583bb2 --- /dev/null +++ b/core/src/sagittarius/view/StartScreen.java @@ -0,0 +1,75 @@ +package sagittarius.view; + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.ScreenAdapter; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; +import com.badlogic.gdx.utils.viewport.FitViewport; +import com.kotcrab.vis.ui.VisUI; +import com.kotcrab.vis.ui.widget.VisTable; +import com.kotcrab.vis.ui.widget.VisTextButton; + +public class StartScreen extends ScreenAdapter { + + private static final float WORLD_WIDTH = 1600; + private static final float WORLD_HEIGHT = 900; + + private final Game game; + private Stage stage; + + public StartScreen(Game game) { + this.game = game; + } + + public void show() { + stage = new Stage(new FitViewport(WORLD_WIDTH, WORLD_HEIGHT)); + Gdx.input.setInputProcessor(stage); + + VisUI.load(); + VisTable root = new VisTable(true); + root.setFillParent(true); + stage.addActor(root); + + VisTextButton startButton = new VisTextButton("start"); + 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); + game.setScreen(new GameScreen()); + } + }); + + VisTextButton quitButton = new VisTextButton("quit"); + quitButton.addListener(new ActorGestureListener() { + @Override + public void tap(InputEvent event, float x, float y, int count, int button) { + super.tap(event, x, y, count, button); + Gdx.app.exit(); + } + }); + + root.add(startButton); + root.row(); + root.add(quitButton); + root.row(); + } + + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + public void render(float deltaTime) { + stage.act(deltaTime); + stage.draw(); + } + + @Override + public void dispose() { + VisUI.dispose(); + stage.dispose(); + super.dispose(); + } + +} \ No newline at end of file