From 4140ddda97930af75b0d50b821ed9eb6337273e2 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sun, 22 Apr 2018 02:47:38 +0700 Subject: [PATCH] Add menu screen and game logo --- android/assets/gamelogo.png | Bin 0 -> 4888 bytes android/assets/gamelogo_s.png | Bin 0 -> 4560 bytes .../src/ru/deadsoftware/cavecraft/Assets.java | 4 ++ .../ru/deadsoftware/cavecraft/CaveGame.java | 2 +- .../ru/deadsoftware/cavecraft/GameScreen.java | 47 +++++++++++++----- .../ru/deadsoftware/cavecraft/GameState.java | 1 + ...nputHandler.java => InputHandlerGame.java} | 10 ++-- .../cavecraft/InputHandlerMenu.java | 47 ++++++++++++++++++ .../ru/deadsoftware/cavecraft/Renderer.java | 33 ++++++++++++ .../{GameInputHandler.java => GameInput.java} | 4 +- .../cavecraft/game/GameRenderer.java | 13 ++--- .../cavecraft/menu/MenuRenderer.java | 23 +++++++++ 12 files changed, 156 insertions(+), 28 deletions(-) create mode 100644 android/assets/gamelogo.png create mode 100644 android/assets/gamelogo_s.png rename core/src/ru/deadsoftware/cavecraft/{InputHandler.java => InputHandlerGame.java} (95%) create mode 100644 core/src/ru/deadsoftware/cavecraft/InputHandlerMenu.java create mode 100644 core/src/ru/deadsoftware/cavecraft/Renderer.java rename core/src/ru/deadsoftware/cavecraft/game/{GameInputHandler.java => GameInput.java} (98%) create mode 100644 core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java diff --git a/android/assets/gamelogo.png b/android/assets/gamelogo.png new file mode 100644 index 0000000000000000000000000000000000000000..7984a531e2529c3c87d2c79e197152b8e064048f GIT binary patch literal 4888 zcmXw-1y~f{*T;ucSVCz@5fG52V;4zjq*Iy&iCqOG6%YjEhe$|DgEUCjD%~Y4A)xe< z%F^BWAK&MBXXf5J&pb18XU;w6dp`Gu>1wNzlQNP506?y;rlb$HyI^^6n;5KZat*(O z4Y93;suFPXZ_jEjj0dlfxT=|Y004ygU%>-X(-{DOs!m<$iJ|xOmZh_kp;7HS?L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raft/Assets.java b/core/src/ru/deadsoftware/cavecraft/Assets.java index acdebdf..427ebc6 100644 --- a/core/src/ru/deadsoftware/cavecraft/Assets.java +++ b/core/src/ru/deadsoftware/cavecraft/Assets.java @@ -12,6 +12,8 @@ public class Assets { public static BitmapFont minecraftFont; + public static Sprite gameLogo; + public static Texture charTexture; public static Sprite[][] playerSprite = new Sprite[2][4]; @@ -82,6 +84,8 @@ public class Assets { public static void load() { minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true); + gameLogo = new Sprite(new Texture(Gdx.files.internal("gamelogo.png"))); + gameLogo.flip(false, true); loadPlayer(); loadPig(); diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java index 99e4f68..6ef0427 100644 --- a/core/src/ru/deadsoftware/cavecraft/CaveGame.java +++ b/core/src/ru/deadsoftware/cavecraft/CaveGame.java @@ -16,7 +16,7 @@ public class CaveGame extends Game { public CaveGame(boolean touch) { TOUCH = touch; - STATE = GameState.GAME_PLAY; + STATE = GameState.MENU_MAIN; } @Override diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index 2a2c262..6daa039 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -1,23 +1,23 @@ package ru.deadsoftware.cavecraft; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input; -import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.Screen; -import ru.deadsoftware.cavecraft.game.GameInputHandler; import ru.deadsoftware.cavecraft.game.GameProc; +import ru.deadsoftware.cavecraft.menu.MenuRenderer; public class GameScreen implements Screen { public static int FPS; private GameProc gameProc; + private Renderer renderer; public GameScreen() { Assets.load(); Items.load(); gameProc = new GameProc(); - Gdx.input.setInputProcessor(new InputHandler(gameProc)); + renderer = new MenuRenderer(); + Gdx.input.setInputProcessor(new InputHandlerMenu()); } public static int getWidth() { @@ -28,6 +28,13 @@ public class GameScreen implements Screen { return Gdx.graphics.getHeight(); } + private void game(float delta) { + gameProc.update(delta); + } + + private void menu() { + } + @Override public void show() { @@ -35,19 +42,35 @@ public class GameScreen implements Screen { @Override public void render(float delta) { - if (CaveGame.STATE == GameState.RESTART) { - gameProc = new GameProc(); - Gdx.input.setInputProcessor(new InputHandler(gameProc)); - CaveGame.STATE = GameState.GAME_PLAY; - } FPS = (int)(1/delta); - gameProc.update(delta); - gameProc.renderer.render(); + switch (CaveGame.STATE) { + case GAME_PLAY: case GAME_CREATIVE_INV: + game(delta); + break; + + case MENU_MAIN: + menu(); + break; + + case RESTART: + gameProc = new GameProc(); + Gdx.input.setInputProcessor(new InputHandlerGame(gameProc)); + CaveGame.STATE = GameState.GAME_PLAY; + break; + } + renderer.render(); } @Override public void resize(int width, int height) { - gameProc.resetRenderer(); + switch (CaveGame.STATE) { + case MENU_MAIN: + renderer = new MenuRenderer(); + break; + case GAME_PLAY: case GAME_CREATIVE_INV: + gameProc.resetRenderer(); + break; + } } @Override diff --git a/core/src/ru/deadsoftware/cavecraft/GameState.java b/core/src/ru/deadsoftware/cavecraft/GameState.java index dd6b021..d8be71a 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameState.java +++ b/core/src/ru/deadsoftware/cavecraft/GameState.java @@ -2,6 +2,7 @@ package ru.deadsoftware.cavecraft; public enum GameState { RESTART, + MENU_MAIN, GAME_PLAY, GAME_CREATIVE_INV } diff --git a/core/src/ru/deadsoftware/cavecraft/InputHandler.java b/core/src/ru/deadsoftware/cavecraft/InputHandlerGame.java similarity index 95% rename from core/src/ru/deadsoftware/cavecraft/InputHandler.java rename to core/src/ru/deadsoftware/cavecraft/InputHandlerGame.java index da3e9e4..e22caec 100644 --- a/core/src/ru/deadsoftware/cavecraft/InputHandler.java +++ b/core/src/ru/deadsoftware/cavecraft/InputHandlerGame.java @@ -2,22 +2,22 @@ package ru.deadsoftware.cavecraft; import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; -import ru.deadsoftware.cavecraft.game.GameInputHandler; +import ru.deadsoftware.cavecraft.game.GameInput; import ru.deadsoftware.cavecraft.game.GameProc; import static ru.deadsoftware.cavecraft.GameScreen.getHeight; import static ru.deadsoftware.cavecraft.GameScreen.getWidth; -public class InputHandler implements InputProcessor { +public class InputHandlerGame implements InputProcessor { private GameProc gameProc; - private GameInputHandler gameInput; + private GameInput gameInput; private float tWidth, tHeight; - public InputHandler(GameProc gameProc) { + public InputHandlerGame(GameProc gameProc) { this.gameProc = gameProc; - this.gameInput = new GameInputHandler(gameProc); + this.gameInput = new GameInput(gameProc); tWidth = gameProc.renderer.camera.viewportWidth; tHeight = gameProc.renderer.camera.viewportHeight; } diff --git a/core/src/ru/deadsoftware/cavecraft/InputHandlerMenu.java b/core/src/ru/deadsoftware/cavecraft/InputHandlerMenu.java new file mode 100644 index 0000000..fe3cb4d --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/InputHandlerMenu.java @@ -0,0 +1,47 @@ +package ru.deadsoftware.cavecraft; + +import com.badlogic.gdx.InputProcessor; + +public class InputHandlerMenu implements InputProcessor{ + + @Override + public boolean keyDown(int keycode) { + return false; + } + + @Override + public boolean keyUp(int keycode) { + return false; + } + + @Override + public boolean keyTyped(char character) { + return false; + } + + @Override + public boolean touchDown(int screenX, int screenY, int pointer, int button) { + return false; + } + + @Override + public boolean touchUp(int screenX, int screenY, int pointer, int button) { + return false; + } + + @Override + public boolean touchDragged(int screenX, int screenY, int pointer) { + return false; + } + + @Override + public boolean mouseMoved(int screenX, int screenY) { + return false; + } + + @Override + public boolean scrolled(int amount) { + return false; + } + +} diff --git a/core/src/ru/deadsoftware/cavecraft/Renderer.java b/core/src/ru/deadsoftware/cavecraft/Renderer.java new file mode 100644 index 0000000..635af85 --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/Renderer.java @@ -0,0 +1,33 @@ +package ru.deadsoftware.cavecraft; + +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; + +public abstract class Renderer { + + public OrthographicCamera camera; + public ShapeRenderer shapeRenderer; + public SpriteBatch spriteBatch; + + public Renderer() { + } + + public Renderer(float width, float height) { + camera = new OrthographicCamera(); + shapeRenderer = new ShapeRenderer(); + spriteBatch = new SpriteBatch(); + camera.setToOrtho(true, width, height); + shapeRenderer.setProjectionMatrix(camera.combined); + spriteBatch.setProjectionMatrix(camera.combined); + } + + public float getWidth() { + return camera.viewportWidth; + } + + public float getHeight() {return camera.viewportHeight;} + + public abstract void render(); + +} diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java similarity index 98% rename from core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java rename to core/src/ru/deadsoftware/cavecraft/game/GameInput.java index dc19afd..3e72368 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -5,11 +5,11 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.*; -public class GameInputHandler { +public class GameInput { private GameProc gameProc; - public GameInputHandler(GameProc gameProc) { + public GameInput(GameProc gameProc) { this.gameProc = gameProc; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 009d9b7..e64ed13 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -6,20 +6,16 @@ import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavecraft.Assets; -import ru.deadsoftware.cavecraft.CaveGame; -import ru.deadsoftware.cavecraft.GameScreen; -import ru.deadsoftware.cavecraft.Items; +import ru.deadsoftware.cavecraft.*; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.objects.Player; -public class GameRenderer { +public class GameRenderer extends Renderer{ private GameProc gameProc; - public OrthographicCamera camera, fontCam; - ShapeRenderer shapeRenderer; - SpriteBatch spriteBatch, fontBatch; + public OrthographicCamera fontCam; + SpriteBatch fontBatch; public GameRenderer(GameProc gameProc) { Gdx.gl.glClearColor(0f,.6f,.6f,1f); @@ -199,6 +195,7 @@ public class GameRenderer { drawGUI(); } + @Override public void render() { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); diff --git a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java new file mode 100644 index 0000000..0f8011d --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java @@ -0,0 +1,23 @@ +package ru.deadsoftware.cavecraft.menu; + +import ru.deadsoftware.cavecraft.Assets; +import ru.deadsoftware.cavecraft.GameScreen; +import ru.deadsoftware.cavecraft.Items; +import ru.deadsoftware.cavecraft.Renderer; + +public class MenuRenderer extends Renderer { + + public MenuRenderer() { + super(480,480*((float) GameScreen.getHeight()/GameScreen.getWidth())); + } + + @Override + public void render() { + spriteBatch.begin(); + for (int x=0; x<=getWidth(); x++) + for (int y=0; y<=getHeight(); y++) + spriteBatch.draw(Items.BLOCKS.get("dirt").getTexture(),x*16,y*16); + spriteBatch.draw(Assets.gameLogo, getWidth()/2-Assets.gameLogo.getWidth()/2, 0); + spriteBatch.end(); + } +} -- 2.29.2