summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 94cf380)
raw | patch | inline | side by side (parent: 94cf380)
author | fred-boy <fred-boy@protonmail.com> | |
Sat, 21 Apr 2018 19:47:38 +0000 (02:47 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Sat, 21 Apr 2018 20:04:28 +0000 (03:04 +0700) |
12 files changed:
diff --git a/android/assets/gamelogo.png b/android/assets/gamelogo.png
new file mode 100644 (file)
index 0000000..7984a53
Binary files /dev/null and b/android/assets/gamelogo.png differ
index 0000000..7984a53
Binary files /dev/null and b/android/assets/gamelogo.png differ
diff --git a/android/assets/gamelogo_s.png b/android/assets/gamelogo_s.png
new file mode 100644 (file)
index 0000000..e91b200
Binary files /dev/null and b/android/assets/gamelogo_s.png differ
index 0000000..e91b200
Binary files /dev/null and b/android/assets/gamelogo_s.png differ
diff --git a/core/src/ru/deadsoftware/cavecraft/Assets.java b/core/src/ru/deadsoftware/cavecraft/Assets.java
index acdebdffafdba033f4d3f887fcf8f8ec62a9a097..427ebc66bf2efc23ea32812d36e0bb0e6a4396b2 100644 (file)
public static BitmapFont minecraftFont;
+ public static Sprite gameLogo;
+
public static Texture charTexture;
public static Sprite[][] playerSprite = new Sprite[2][4];
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 99e4f689c11bccede1c6702cb9d6e789a0080e5f..6ef042799292bf0973a0ebcc530633817c88de43 100644 (file)
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 2a2c262a6f4fe3cb0a36feb45f33f996080cc091..6daa039bdb5043143300029941094c1b18a10ff5 100644 (file)
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() {
return Gdx.graphics.getHeight();
}
+ private void game(float delta) {
+ gameProc.update(delta);
+ }
+
+ private void menu() {
+ }
+
@Override
public void show() {
@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 dd6b021ee1894055516d61e78db7a7190e5e3fde..d8be71ab9655859791276a47bf2cf1665efd5547 100644 (file)
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 da3e9e43d9be2deaf71a0454ae92f0a92d288519..e22caec183bf6c522cc31db12a2a97739b1e889d 100644 (file)
rename from core/src/ru/deadsoftware/cavecraft/InputHandler.java
rename to core/src/ru/deadsoftware/cavecraft/InputHandlerGame.java
index da3e9e43d9be2deaf71a0454ae92f0a92d288519..e22caec183bf6c522cc31db12a2a97739b1e889d 100644 (file)
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
--- /dev/null
@@ -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
--- /dev/null
@@ -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 dc19afdb0f42a6bd207fe3fc04956f274e85fb54..3e72368c319ef927efe0492d639a38d86b5d35ba 100644 (file)
rename from core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java
rename to core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index dc19afdb0f42a6bd207fe3fc04956f274e85fb54..3e72368c319ef927efe0492d639a38d86b5d35ba 100644 (file)
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 009d9b75765768e7a793daec3228a0230f7a4d09..e64ed135335265ce1d48948e10af7c1c0e7cac11 100644 (file)
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);
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
--- /dev/null
@@ -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();
+ }
+}