DEADSOFTWARE

More convenient controls on desktop
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / GameRenderer.java
index f1e830d61586e77267c6ca88b8494f8e84aeff6d..7eed8a7d85884890c8cbc87eb8b11ebd90646707 100644 (file)
@@ -1,6 +1,7 @@
 package ru.deadsoftware.cavecraft.game;
 
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.graphics.OrthographicCamera;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@@ -18,9 +19,9 @@ public class GameRenderer {
 
     private GameProc gameProc;
 
-    public OrthographicCamera camera, fontCam, touchCam;
+    public OrthographicCamera camera, fontCam;
     ShapeRenderer shapeRenderer;
-    SpriteBatch spriteBatch, fontBatch, touchBatch;
+    SpriteBatch spriteBatch, fontBatch;
 
     public GameRenderer(GameProc gameProc) {
         Gdx.gl.glClearColor(0f,.6f,.6f,1f);
@@ -30,8 +31,8 @@ public class GameRenderer {
             camera.setToOrtho(true, 480,
                     480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         } else {
-            camera.setToOrtho(true, 240,
-                    240 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
+            camera.setToOrtho(true, 320,
+                    320 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         }
         shapeRenderer = new ShapeRenderer();
         shapeRenderer.setProjectionMatrix(camera.combined);
@@ -43,11 +44,6 @@ public class GameRenderer {
         fontCam.setToOrtho(true, GameScreen.getWidth(), GameScreen.getHeight());
         fontBatch = new SpriteBatch();
         fontBatch.setProjectionMatrix(fontCam.combined);
-        touchCam = new OrthographicCamera();
-        touchCam.setToOrtho(true, 240,
-                240*((float)GameScreen.getHeight()/GameScreen.getWidth()));
-        touchBatch = new SpriteBatch();
-        touchBatch.setProjectionMatrix(touchCam.combined);
     }
 
     private void setFontColor(int r, int g, int b) {
@@ -167,7 +163,7 @@ public class GameRenderer {
         for (int i=0; i<9; i++) {
             if (gameProc.player.inventory[i]>0)
                 spriteBatch.draw(Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture(),
-                        x+8+i*18, y+184);
+                        x+8+i*18, y+Assets.creativeInv.getRegionHeight()-24);
         }
     }
 
@@ -192,13 +188,13 @@ public class GameRenderer {
     }
 
     private void drawTouchGui() {
-        touchBatch.draw(Assets.touchArrows[0],26,touchCam.viewportHeight-52);
-        touchBatch.draw(Assets.touchArrows[1],0,touchCam.viewportHeight-26);
-        touchBatch.draw(Assets.touchArrows[2],26,touchCam.viewportHeight-26);
-        touchBatch.draw(Assets.touchArrows[3],52,touchCam.viewportHeight-26);
-        touchBatch.draw(Assets.touchLMB, touchCam.viewportWidth-52, touchCam.viewportHeight-26);
-        touchBatch.draw(Assets.touchRMB, touchCam.viewportWidth-26, touchCam.viewportHeight-26);
-        touchBatch.draw(Assets.touchToggleMode, 78, touchCam.viewportHeight-26);
+        spriteBatch.draw(Assets.touchArrows[0],26,camera.viewportHeight-52);
+        spriteBatch.draw(Assets.touchArrows[1],0,camera.viewportHeight-26);
+        spriteBatch.draw(Assets.touchArrows[2],26,camera.viewportHeight-26);
+        spriteBatch.draw(Assets.touchArrows[3],52,camera.viewportHeight-26);
+        spriteBatch.draw(Assets.touchLMB, camera.viewportWidth-52, camera.viewportHeight-26);
+        spriteBatch.draw(Assets.touchRMB, camera.viewportWidth-26, camera.viewportHeight-26);
+        spriteBatch.draw(Assets.touchToggleMode, 78, camera.viewportHeight-26);
     }
 
     private void drawGamePlay() {
@@ -224,10 +220,16 @@ public class GameRenderer {
         }
         spriteBatch.end();
 
+        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
+        shapeRenderer.setColor(Color.ORANGE);
+        shapeRenderer.line(0-camera.position.x, 128*16-camera.position.y,
+                gameProc.world.getWidth()*16-camera.position.x, 128*16-camera.position.y);
+        shapeRenderer.end();
+
         if (CaveGame.TOUCH) {
-            touchBatch.begin();
+            spriteBatch.begin();
             drawTouchGui();
-            touchBatch.end();
+            spriteBatch.end();
         }
 
         fontBatch.begin();
@@ -236,6 +238,7 @@ public class GameRenderer {
         drawString("FPS: "+GameScreen.FPS, 0, 20);
         drawString("X: "+(int)(gameProc.player.position.x/16), 0, 40);
         drawString("Y: "+(int)(gameProc.player.position.y/16), 0, 60);
+        drawString("Seed: "+WorldGen.getSeed(), 0, 80);
         fontBatch.end();
     }