From: fred-boy Date: Thu, 5 Apr 2018 06:50:08 +0000 (+0700) Subject: Add GameRenderer and GameWorld X-Git-Tag: alpha0.1~28 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=62aa73cc7dfd177befe22784940c1bab13d94024;p=cavedroid.git Add GameRenderer and GameWorld --- diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java index 28275c9..447a91e 100644 --- a/core/src/ru/deadsoftware/cavecraft/CaveGame.java +++ b/core/src/ru/deadsoftware/cavecraft/CaveGame.java @@ -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 index 0000000..f227302 --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -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 index 0000000..61f7a3a --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -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 index 0000000..68a7a01 --- /dev/null +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -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; + } + +}