DEADSOFTWARE

Add GameRenderer and GameWorld
authorfred-boy <fred-boy@protonmail.com>
Thu, 5 Apr 2018 06:50:08 +0000 (13:50 +0700)
committerfred-boy <fred-boy@protonmail.com>
Thu, 5 Apr 2018 06:50:08 +0000 (13:50 +0700)
core/src/ru/deadsoftware/cavecraft/CaveGame.java
core/src/ru/deadsoftware/cavecraft/GameScreen.java [new file with mode: 0644]
core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java [new file with mode: 0644]
core/src/ru/deadsoftware/cavecraft/game/GameWorld.java [new file with mode: 0644]

index 28275c90d765a700df4e1ff11deabf9d4c376b26..447a91e60281b4845e03f8bdf36a80ba245b6e9c 100644 (file)
@@ -6,6 +6,7 @@ public class CaveGame extends Game {
 
        @Override
        public void create () {
+               setScreen(new GameScreen());
        }
 
 }
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java
new file mode 100644 (file)
index 0000000..f227302
--- /dev/null
@@ -0,0 +1,57 @@
+package ru.deadsoftware.cavecraft;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Screen;
+import ru.deadsoftware.cavecraft.game.GameRenderer;
+
+public class GameScreen implements Screen {
+
+    private GameRenderer renderer;
+
+    public GameScreen() {
+        renderer = new GameRenderer();
+    }
+
+    public static int getWidth() {
+        return Gdx.graphics.getWidth();
+    }
+
+    public static int getHeight() {
+        return Gdx.graphics.getHeight();
+    }
+
+    @Override
+    public void show() {
+
+    }
+
+    @Override
+    public void render(float delta) {
+        renderer.render();
+    }
+
+    @Override
+    public void resize(int width, int height) {
+
+    }
+
+    @Override
+    public void pause() {
+
+    }
+
+    @Override
+    public void resume() {
+
+    }
+
+    @Override
+    public void hide() {
+
+    }
+
+    @Override
+    public void dispose() {
+
+    }
+}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
new file mode 100644 (file)
index 0000000..61f7a3a
--- /dev/null
@@ -0,0 +1,24 @@
+package ru.deadsoftware.cavecraft.game;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.GL20;
+import com.badlogic.gdx.graphics.OrthographicCamera;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import com.badlogic.gdx.graphics.Color;
+import ru.deadsoftware.cavecraft.GameScreen;
+
+public class GameRenderer {
+
+    private OrthographicCamera camera;
+    private ShapeRenderer shapeRenderer;
+
+    public GameRenderer() {
+        Gdx.gl.glClearColor(0f,.8f,.8f,1f);
+    }
+
+    public void render() {
+        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
+
+    }
+
+}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
new file mode 100644 (file)
index 0000000..68a7a01
--- /dev/null
@@ -0,0 +1,40 @@
+package ru.deadsoftware.cavecraft.game;
+
+public class GameWorld {
+
+    private final int WIDTH, HEIGHT;
+    private int[][] foreMap;
+    private int[][] backMap;
+
+    public GameWorld(int w, int h) {
+        WIDTH = w;
+        HEIGHT = h;
+        foreMap = new int[WIDTH][HEIGHT];
+        backMap = new int[WIDTH][HEIGHT];
+    }
+
+    public int getWidth() {
+        return WIDTH;
+    }
+
+    public int getHeight() {
+        return HEIGHT;
+    }
+
+    public int getForeMap(int x, int y) {
+        return foreMap[x][y];
+    }
+
+    public void setForeMap(int x, int y, int value) {
+        foreMap[x][y] = value;
+    }
+
+    public int getBackMap(int x, int y) {
+        return backMap[x][y];
+    }
+
+    public void setBackMap(int x, int y, int value) {
+        backMap[x][y] = value;
+    }
+
+}