Skip to content
Snippets Groups Projects
Commit b5102fc7 authored by Sander Østrem Fagernes's avatar Sander Østrem Fagernes
Browse files

feat: Welcome box added

Issue #14
parent 69a5ea69
No related branches found
No related tags found
1 merge request!1314 Main menu screen setup
Pipeline #204244 passed
frontend/assets/main-menu-welcome-box.png

462 B

......@@ -5,6 +5,7 @@ import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
......@@ -24,6 +25,7 @@ public class MainMenuScreen implements Screen {
private final MainMenuController controller;
private final Texture logo;
private final Texture welcomeBox;
private final Texture background;
private final Array<MenuButton> menuButtons;
......@@ -38,9 +40,11 @@ public class MainMenuScreen implements Screen {
this.controller = new MainMenuController(tankWarsGame);
this.logo = new Texture("tankwars-logo.png");
this.welcomeBox = new Texture("main-menu-welcome-box.png");
// TODO: Create our own pixel art background. ZyWDE4.jpg is a dummy background image
this.background = new Texture("ZyWDE4.jpg");
// TODO: Instantiate in Controller instead ?
this.menuButtons = new Array<>();
this.menuButtons.add(new MenuButton(batch, font, 0, "Find Game", 0, -50 + viewport.getWorldHeight() / 6));
this.menuButtons.add(new MenuButton(batch, font, 1, "Leaderboard", 0, -50));
......@@ -72,13 +76,23 @@ public class MainMenuScreen implements Screen {
batch.draw(logo, -logo.getWidth() * logoScaling / 2f, viewport.getWorldHeight() / 3,
logo.getWidth() * logoScaling, logo.getHeight() * logoScaling);
// TODO: Clean up the font rendering code
String welcomeMessage = "Welcome to duty";
String username = "Commander";
GlyphLayout welcomeLayout = new GlyphLayout(font, welcomeMessage);
GlyphLayout usernameLayout = new GlyphLayout(font, username);
batch.draw(welcomeBox, -viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 6);
font.draw(batch, welcomeMessage, -welcomeLayout.width / 2, viewport.getWorldHeight() / 6 + welcomeBox.getHeight() * 8f/10f);
font.draw(batch, username, -usernameLayout.width / 2, viewport.getWorldHeight() / 6 + welcomeBox.getHeight() * 8f/10f - 2 * welcomeLayout.height);
for (MenuButton menuButton : menuButtons) {
menuButton.draw();
}
batch.end();
}
private void checkInput() {
// TODO: Write as listener instead of polling
if (Gdx.input.justTouched()) {
touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
viewport.unproject(touchPos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment