From 507ece02cdc5e1eec771a27ffb1b1b5031d08e5a Mon Sep 17 00:00:00 2001 From: Gaganx0 Date: Fri, 29 Sep 2023 15:47:33 +1000 Subject: [PATCH] Help screen --- .../com/csse3200/game/screens/HelpScreen.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 source/core/src/main/com/csse3200/game/screens/HelpScreen.java diff --git a/source/core/src/main/com/csse3200/game/screens/HelpScreen.java b/source/core/src/main/com/csse3200/game/screens/HelpScreen.java new file mode 100644 index 000000000..bfbcc7ae1 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/screens/HelpScreen.java @@ -0,0 +1,79 @@ +package com.csse3200.game.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.ScreenAdapter; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.utils.viewport.FitViewport; +import com.csse3200.game.GdxGame; + +public class HelpScreen extends ScreenAdapter { + private final GdxGame game; + private Stage stage; + private SpriteBatch spriteBatch; + + public HelpScreen(GdxGame game) { + this.game = game; + stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + spriteBatch = new SpriteBatch(); + + // Create a table to organize the four image placeholders + Table table = new Table(); + table.setFillParent(true); // Makes the table the size of the stage + + // Create four image placeholders + Image image1 = new Image(new Texture("images/lava_bg.png")); + Image image2 = new Image(new Texture("images/lava_bg.png")); + Image image3 = new Image(new Texture("images/lava_bg.png")); + Image image4 = new Image(new Texture("images/lava_bg.png")); + + // Add the image placeholders to the table + table.add(image1).expand().fill(); + table.row(); // Move to the next row + table.add(image2).expand().fill(); + table.row(); + table.add(image3).expand().fill(); + table.row(); + table.add(image4).expand().fill(); + + // Add the table to the stage + stage.addActor(table); + } + + @Override + public void show() { + // Set this screen as the input processor + Gdx.input.setInputProcessor(stage); + } + + @Override + public void render(float delta) { + // Clear the screen + spriteBatch.begin(); + spriteBatch.end(); + + // Draw the stage + stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); + stage.draw(); + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + @Override + public void hide() { + // Remove this screen as the input processor + Gdx.input.setInputProcessor(null); + } + + @Override + public void dispose() { + stage.dispose(); + spriteBatch.dispose(); + } +}