X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameRenderer.java;h=682984a5611adc334464374b8aad5fa46223746f;hb=c9d399d3ae0b7f797d6fd62a4c22202a12a8825b;hp=9183c677e3ee90c1c7ba09d52ff5abd2efcd69c3;hpb=769c26b45cc2bc91439f5f4f92bb7ac75fadfa91;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 9183c67..682984a 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -19,16 +19,18 @@ public class GameRenderer { private GameProc gameProc; - public OrthographicCamera camera, fontCam; + public boolean showCreative = false; + + public OrthographicCamera camera, fontCam, touchCam; ShapeRenderer shapeRenderer; - SpriteBatch spriteBatch, fontBatch; + SpriteBatch spriteBatch, fontBatch, touchBatch; public GameRenderer(GameProc gameProc) { Gdx.gl.glClearColor(0f,.6f,.6f,1f); this.gameProc = gameProc; camera = new OrthographicCamera(); - camera.setToOrtho(true, 360, - 360*((float)GameScreen.getHeight()/GameScreen.getWidth())); + camera.setToOrtho(true, 480, + 480*((float)GameScreen.getHeight()/GameScreen.getWidth())); shapeRenderer = new ShapeRenderer(); shapeRenderer.setProjectionMatrix(camera.combined); @@ -40,6 +42,11 @@ 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) { @@ -141,6 +148,22 @@ public class GameRenderer { Assets.playerSkin[0][2].draw(spriteBatch); } + private void drawCreative() { + float x = camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2; + float y = camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2; + spriteBatch.draw(Assets.creativeInv, x, y); + spriteBatch.draw(Assets.creativeScroll, x+156, y+18); + for (int i=1; i0) + spriteBatch.draw(Items.BLOCKS.getValueAt(gameProc.player.inventory[i]).getTexture(), + x+8+i*18, y+184); + } + } + private void drawGUI() { spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2, 0); for (int i=0; i<9; i++) { @@ -154,20 +177,18 @@ public class GameRenderer { camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2 - 1 + 20*gameProc.invSlot, -1); - if (CaveGame.TOUCH) { - 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.touchSpace, camera.viewportWidth/2-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); - if (gameProc.ctrlMode==1) { - Assets.shade.setPosition(83, camera.viewportHeight-21); - Assets.shade.draw(spriteBatch); - } - } + if (showCreative) drawCreative(); + } + + 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.touchSpace, touchCam.viewportWidth/2-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); } public void render() { @@ -179,9 +200,14 @@ public class GameRenderer { drawPlayer(gameProc.player); drawWorldForeground(); drawGUI(); - spriteBatch.end(); + if (CaveGame.TOUCH) { + touchBatch.begin(); + drawTouchGui(); + touchBatch.end(); + } + if (gameProc.ctrlMode==1) { shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(Color.ORANGE);