DEADSOFTWARE

Gameplay enhancements
authorfred-boy <fred-boy@protonmail.com>
Thu, 19 Apr 2018 11:33:32 +0000 (18:33 +0700)
committerfred-boy <fred-boy@protonmail.com>
Thu, 19 Apr 2018 11:33:32 +0000 (18:33 +0700)
android/assets/gui.png
core/src/ru/deadsoftware/cavecraft/Assets.java
core/src/ru/deadsoftware/cavecraft/CaveGame.java
core/src/ru/deadsoftware/cavecraft/GameState.java [new file with mode: 0644]
core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java
core/src/ru/deadsoftware/cavecraft/game/GameProc.java
core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
core/src/ru/deadsoftware/cavecraft/game/WorldGen.java

index ef76dc04938b993da01fec7e5c2771c7cf56e607..6542140a28333c67aa397c6bfea79ba760122510 100644 (file)
Binary files a/android/assets/gui.png and b/android/assets/gui.png differ
index e1fd5c94a1c44923c39ad4fb0ff97462453ad1d4..593a2c05fb834a923ca05642cb9d09bd25f7fc1a 100644 (file)
@@ -2,7 +2,6 @@ package ru.deadsoftware.cavecraft;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g2d.Animation;
 import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.g2d.Sprite;
 import com.badlogic.gdx.graphics.g2d.TextureRegion;
@@ -23,7 +22,8 @@ public class Assets {
 
     public static Texture gui;
     public static TextureRegion invBar;
-    public static TextureRegion invCur;
+    public static TextureRegion invBarCur;
+    public static TextureRegion guiCur;
 
     public static Texture creativeTexture;
     public static TextureRegion creativeInv;
@@ -69,8 +69,9 @@ public class Assets {
         shade = new Sprite(new Texture(Gdx.files.internal("shade.png")));
 
         gui = new Texture(Gdx.files.internal("gui.png"));
-        invBar = new TextureRegion(gui,0,0,182,22);
-        invCur = new TextureRegion(gui,0,22,24,24);
+        guiCur = new TextureRegion(gui,0,0,16,16);
+        invBar = new TextureRegion(gui,0,16,182,22);
+        invBarCur = new TextureRegion(gui,0,38,24,24);
 
         creativeTexture = new Texture(Gdx.files.internal("allitems.png"));
         creativeInv = new TextureRegion(creativeTexture, 0, 0, 176, 208);
index 50d9447f979d9f046041df08643c021c5260a6be..fc6d0bdccfc0d58c684e9af35d257641f18907c4 100644 (file)
@@ -6,6 +6,8 @@ public class CaveGame extends Game {
 
        public static final String VERSION = "alpha 0.0";
 
+       public static GameState STATE;
+
        public static boolean TOUCH;
 
        public CaveGame() {
@@ -14,6 +16,7 @@ public class CaveGame extends Game {
 
        public CaveGame(boolean touch) {
                TOUCH = touch;
+               STATE = GameState.GAME_PLAY;
        }
 
        @Override
diff --git a/core/src/ru/deadsoftware/cavecraft/GameState.java b/core/src/ru/deadsoftware/cavecraft/GameState.java
new file mode 100644 (file)
index 0000000..9de340d
--- /dev/null
@@ -0,0 +1,6 @@
+package ru.deadsoftware.cavecraft;
+
+public enum GameState {
+    GAME_PLAY,
+    GAME_CREATIVE_INV
+}
index 490960b8986efffa5c4a24a81b1ef55136a0b65a..61b52e41cce84814fe03b5e859707abaacb10f2f 100644 (file)
@@ -3,9 +3,7 @@ package ru.deadsoftware.cavecraft.game;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.Input;
 import com.badlogic.gdx.utils.TimeUtils;
-import ru.deadsoftware.cavecraft.Assets;
-import ru.deadsoftware.cavecraft.GameScreen;
-import ru.deadsoftware.cavecraft.Items;
+import ru.deadsoftware.cavecraft.*;
 
 public class GameInputHandler {
 
@@ -19,11 +17,11 @@ public class GameInputHandler {
         if (gameProc.ctrlMode==0) {
             switch (keyCode) {
                 case Input.Keys.A:
-                    gameProc.player.moveX.add(-GamePhysics.PL_SPEED, 0);
+                    gameProc.player.moveX.x = -GamePhysics.PL_SPEED;
                     gameProc.player.dir = 0;
                     break;
                 case Input.Keys.D:
-                    gameProc.player.moveX.add(GamePhysics.PL_SPEED, 0);
+                    gameProc.player.moveX.x = GamePhysics.PL_SPEED;
                     gameProc.player.dir = 1;
                     break;
             }
@@ -42,14 +40,10 @@ public class GameInputHandler {
                     gameProc.cursorY++;
                     break;
             }
-            if (gameProc.cursorX < 0)
-                gameProc.cursorX = 0;
-            if (gameProc.cursorX >= gameProc.world.getWidth())
-                gameProc.cursorX = gameProc.world.getWidth()-1;
-            if (gameProc.cursorY < 0)
-                gameProc.cursorY = 0;
-            if (gameProc.cursorY >= gameProc.world.getHeight())
-                gameProc.cursorY = gameProc.world.getHeight()-1;
+            if (gameProc.cursorX<(gameProc.player.position.x+gameProc.player.texWidth/2)/16)
+                gameProc.player.dir=0;
+            if (gameProc.cursorX>(gameProc.player.position.x+gameProc.player.texWidth/2)/16)
+                gameProc.player.dir=1;
         }
     }
 
@@ -60,8 +54,6 @@ public class GameInputHandler {
         } else switch (keyCode) {
             case Input.Keys.ALT_LEFT:
                 gameProc.ctrlMode++;
-                gameProc.cursorX = (int)(gameProc.player.position.x/16);
-                gameProc.cursorY = (int)(gameProc.player.position.y/16);
                 if (gameProc.ctrlMode > 1) gameProc.ctrlMode = 0;
                 break;
 
@@ -81,7 +73,8 @@ public class GameInputHandler {
                 break;
 
             case Input.Keys.E:
-                gameProc.renderer.showCreative = !gameProc.renderer.showCreative;
+                if (CaveGame.STATE == GameState.GAME_PLAY) CaveGame.STATE = GameState.GAME_CREATIVE_INV;
+                    else CaveGame.STATE = GameState.GAME_PLAY;
                 break;
         }
     }
@@ -102,7 +95,7 @@ public class GameInputHandler {
     }
 
     public void touchDown(int screenX, int screenY, int button) {
-        if (gameProc.renderer.showCreative &&
+        if (CaveGame.STATE == GameState.GAME_CREATIVE_INV &&
                 screenX>gameProc.renderer.camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2 &&
                 screenX<gameProc.renderer.camera.viewportWidth/2+Assets.creativeInv.getRegionWidth()/2 &&
                 screenY>gameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 &&
@@ -118,8 +111,12 @@ public class GameInputHandler {
             } catch (Exception e) {
                 Gdx.app.error("GameInputHandler", e.toString());
             }
-        } else if (gameProc.renderer.showCreative) {
-            gameProc.renderer.showCreative = !gameProc.renderer.showCreative;
+        } else if (CaveGame.STATE == GameState.GAME_CREATIVE_INV) {
+            CaveGame.STATE = GameState.GAME_PLAY;
+        } else if (button == Input.Buttons.RIGHT &&
+                !gameProc.player.canJump && !gameProc.player.flyMode) {
+            gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY,
+                    gameProc.player.inventory[gameProc.invSlot]);
         } else {
             gameProc.touchDownX = screenX;
             gameProc.touchDownY = screenY;
@@ -132,24 +129,19 @@ public class GameInputHandler {
     public void touchUp(int screenX, int screenY, int button) {
         if (gameProc.isTouchDown) {
             if (button == Input.Buttons.RIGHT){
-                if (gameProc.ctrlMode==1) {
-                    gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY,
+                gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY,
                             gameProc.player.inventory[gameProc.invSlot]);
-                }
             } else if (button == Input.Buttons.LEFT) {
-                if (gameProc.ctrlMode==1) {
-                    if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY) > 0) {
-                        gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 0);
-                    } else if (gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY) > 0) {
-                        gameProc.world.placeToBackground(gameProc.cursorX, gameProc.cursorY, 0);
-                    }
-                } else {
-                    if (screenY<Assets.invBar.getRegionHeight() &&
-                            screenX>gameProc.renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
-                            screenX<gameProc.renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
-                        gameProc.invSlot = (int)((screenX-(gameProc.renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2))/20);
-                    }
+                if (screenY<Assets.invBar.getRegionHeight() &&
+                        screenX>gameProc.renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
+                        screenX<gameProc.renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
+                    gameProc.invSlot = (int)((screenX-(gameProc.renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2))/20);
+                } else if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY) > 0) {
+                    gameProc.world.placeToForeground(gameProc.cursorX, gameProc.cursorY, 0);
+                } else if (gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY) > 0) {
+                    gameProc.world.placeToBackground(gameProc.cursorX, gameProc.cursorY, 0);
                 }
+
             }
         }
         gameProc.isTouchDown = false;
index d6378d3d028ea2e98a240ec74847cc22d7741ed4..e49a40588fd47641eadeea136b65354a9929d5e9 100644 (file)
@@ -5,6 +5,9 @@ import com.badlogic.gdx.math.RandomXS128;
 import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.TimeUtils;
 import ru.deadsoftware.cavecraft.Assets;
+import ru.deadsoftware.cavecraft.CaveGame;
+import ru.deadsoftware.cavecraft.GameState;
+import ru.deadsoftware.cavecraft.Items;
 import ru.deadsoftware.cavecraft.game.mobs.Human;
 import ru.deadsoftware.cavecraft.game.mobs.Mob;
 import ru.deadsoftware.cavecraft.game.objects.Player;
@@ -31,7 +34,7 @@ public class GameProc {
     public long touchDownTime;
 
     public GameProc() {
-        world = new GameWorld(4096,256);
+        world = new GameWorld(1024,256);
         renderer = new GameRenderer(this);
         physics = new GamePhysics(this);
         player = new Player(world.getSpawnPoint());
@@ -43,10 +46,46 @@ public class GameProc {
         renderer = new GameRenderer(this);
     }
 
+    private boolean isAutoselectable(int x, int y) {
+        return (world.getForeMap(x,y)>0 &&
+                Items.BLOCKS.getValueAt(world.getForeMap(x,y)).collision);
+    }
+
+    private void moveCursor() {
+        if (player.canJump) {
+            cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
+            if (player.dir == 0) cursorX--;
+            else cursorX++;
+            cursorY = (int) (player.position.y + player.texWidth) / 16;
+            if (!isAutoselectable(cursorX, cursorY)) {
+                cursorY++;
+            }
+            if (!isAutoselectable(cursorX, cursorY)) {
+                cursorY++;
+            }
+            if (!isAutoselectable(cursorX, cursorY)) {
+                if (player.dir == 0) cursorX++;
+                else cursorX--;
+            }
+        } else {
+            cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
+            cursorY = (int) (player.position.y + player.height+8)/16;
+        }
+    }
+
+    private void checkCursorBounds() {
+        if (cursorX < 0) cursorX = 0;
+        if (cursorX >= world.getWidth()) cursorX = world.getWidth()-1;
+        if (cursorY < 0) cursorY = 0;
+        if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1;
+    }
+
     public void update(float delta) {
         RUN_TIME += delta;
 
         physics.update(delta);
+        if (ctrlMode==0) moveCursor();
+        checkCursorBounds();
 
         if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) {
             if (touchDownButton== Input.Buttons.RIGHT) {
@@ -56,7 +95,7 @@ public class GameProc {
                     touchDownY< Assets.invBar.getRegionHeight() &&
                     touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
                     touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
-                renderer.showCreative = !renderer.showCreative;
+                CaveGame.STATE = GameState.GAME_CREATIVE_INV;
             }
             isTouchDown = false;
         }
index 682984a5611adc334464374b8aad5fa46223746f..f1e830d61586e77267c6ca88b8494f8e84aeff6d 100644 (file)
@@ -5,9 +5,8 @@ import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.graphics.OrthographicCamera;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
-import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.math.MathUtils;
 import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.math.Vector3;
 import ru.deadsoftware.cavecraft.Assets;
 import ru.deadsoftware.cavecraft.CaveGame;
 import ru.deadsoftware.cavecraft.Items;
@@ -19,8 +18,6 @@ public class GameRenderer {
 
     private GameProc gameProc;
 
-    public boolean showCreative = false;
-
     public OrthographicCamera camera, fontCam, touchCam;
     ShapeRenderer shapeRenderer;
     SpriteBatch spriteBatch, fontBatch, touchBatch;
@@ -29,9 +26,13 @@ public class GameRenderer {
         Gdx.gl.glClearColor(0f,.6f,.6f,1f);
         this.gameProc = gameProc;
         camera = new OrthographicCamera();
-        camera.setToOrtho(true, 480,
-                480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
-
+        if (!CaveGame.TOUCH) {
+            camera.setToOrtho(true, 480,
+                    480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
+        } else {
+            camera.setToOrtho(true, 240,
+                    240 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
+        }
         shapeRenderer = new ShapeRenderer();
         shapeRenderer.setProjectionMatrix(camera.combined);
         shapeRenderer.setAutoShapeType(true);
@@ -68,11 +69,11 @@ public class GameRenderer {
         if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
         for (int y=minY; y<maxY; y++) {
             for (int x=minX; x<maxX; x++) {
-                if (gameProc.world.getForeMap(x,y)>0 &&
+                if (gameProc.world.getForeMap(x,y)>0){/* &&
                         !Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).foreground) {
                     spriteBatch.draw(
                             Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture(),
-                            x * 16 - camera.position.x,y * 16 - camera.position.y);
+                            x * 16 - camera.position.x,y * 16 - camera.position.y);*/
                 } else if (gameProc.world.getBackMap(x,y)>0) {
                     spriteBatch.draw(
                             Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x,y)).getTexture(),
@@ -95,8 +96,8 @@ public class GameRenderer {
         if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
         for (int y=minY; y<maxY; y++) {
             for (int x=minX; x<maxX; x++) {
-                if (gameProc.world.getForeMap(x,y)>0 &&
-                        Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).foreground) {
+                if (gameProc.world.getForeMap(x,y)>0) { /*&&
+                        Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).foreground) {*/
                     spriteBatch.draw(
                             Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture(),
                             x * 16 - camera.position.x,y * 16 - camera.position.y);
@@ -124,24 +125,30 @@ public class GameRenderer {
         }
         if (Assets.playerSkin[0][2].getRotation()>=60 || Assets.playerSkin[0][2].getRotation()<=-60)
             Mob.ANIM_SPEED = -Mob.ANIM_SPEED;
+
+        //back hand
         Assets.playerSkin[1][2].setPosition(
                 pl.position.x - camera.position.x - 6,
                 pl.position.y - camera.position.y);
         Assets.playerSkin[1][2].draw(spriteBatch);
+        //back leg
         Assets.playerSkin[1][3].setPosition(
                 pl.position.x - camera.position.x - 6,
                 pl.position.y - camera.position.y + 10);
         Assets.playerSkin[1][3].draw(spriteBatch);
+        //front leg
         Assets.playerSkin[0][3].setPosition(
                 pl.position.x - camera.position.x - 6,
                 pl.position.y - camera.position.y + 10);
         Assets.playerSkin[0][3].draw(spriteBatch);
-
+        //head
         spriteBatch.draw(Assets.playerSkin[pl.dir][0],
-                pl.position.x - camera.position.x - 2, pl.position.y - camera.position.y - 2);
+                pl.position.x - camera.position.x - 2,
+                pl.position.y - camera.position.y - 2);
+        //body
         spriteBatch.draw(Assets.playerSkin[pl.dir][1],
                 pl.position.x - camera.position.x - 2, pl.position.y - camera.position.y + 8);
-
+        //front hand
         Assets.playerSkin[0][2].setPosition(
                 pl.position.x - camera.position.x - 6,
                 pl.position.y - camera.position.y);
@@ -165,6 +172,12 @@ public class GameRenderer {
     }
 
     private void drawGUI() {
+        if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)>0 ||
+                gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY)>0 ||
+                gameProc.ctrlMode==1)
+            spriteBatch.draw(Assets.guiCur,
+                    gameProc.cursorX*16-camera.position.x,
+                    gameProc.cursorY*16-camera.position.y);
         spriteBatch.draw(Assets.invBar, camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2, 0);
         for (int i=0; i<9; i++) {
             if (gameProc.player.inventory[i]>0) {
@@ -173,11 +186,9 @@ public class GameRenderer {
                         3);
             }
         }
-        spriteBatch.draw(Assets.invCur,
+        spriteBatch.draw(Assets.invBarCur,
                 camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2 - 1 + 20*gameProc.invSlot,
                 -1);
-
-        if (showCreative) drawCreative();
     }
 
     private void drawTouchGui() {
@@ -185,21 +196,32 @@ public class GameRenderer {
         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() {
-        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
-
-        spriteBatch.begin();
+    private void drawGamePlay() {
         drawWorld();
         for (Mob mob : gameProc.mobs) drawMob(mob);
         drawPlayer(gameProc.player);
         drawWorldForeground();
         drawGUI();
+    }
+
+    public void render() {
+        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
+
+        spriteBatch.begin();
+        switch (CaveGame.STATE) {
+            case GAME_PLAY:
+                drawGamePlay();
+                break;
+            case GAME_CREATIVE_INV:
+                drawGamePlay();
+                drawCreative();
+                break;
+        }
         spriteBatch.end();
 
         if (CaveGame.TOUCH) {
@@ -208,26 +230,12 @@ public class GameRenderer {
             touchBatch.end();
         }
 
-        if (gameProc.ctrlMode==1) {
-            shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
-            shapeRenderer.setColor(Color.ORANGE);
-            shapeRenderer.set(ShapeRenderer.ShapeType.Line);
-            shapeRenderer.rect(gameProc.cursorX * 16 - camera.position.x,
-                    gameProc.cursorY * 16 - camera.position.y, 16, 16);
-            shapeRenderer.end();
-        }
-
         fontBatch.begin();
         setFontColor(255,255,255);
         drawString("CaveCraft "+CaveGame.VERSION, 0, 0);
         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("Block: "+
-                Items.BLOCKS.keys().toArray().get(gameProc.world.getForeMap(
-                        (int)((gameProc.player.position.x+gameProc.player.texWidth/2)/16),
-                        (int)(gameProc.player.position.y/16+2))),
-                0, 80);
         fontBatch.end();
     }
 
index 97d05cb2d41f5767cd88482f27c238453da61f41..c4655bf157c732368ec685c085af2be42ba9f819 100644 (file)
@@ -2,11 +2,13 @@ package ru.deadsoftware.cavecraft.game;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.utils.ArrayMap;
 import ru.deadsoftware.cavecraft.Items;
 
 public class GameWorld {
 
     private final int WIDTH, HEIGHT;
+
     private int[][] foreMap;
     private int[][] backMap;
 
@@ -64,12 +66,15 @@ public class GameWorld {
     }
 
     public void placeToForeground(int x, int y, int value) {
-        if (getForeMap(x,y) == 0 || value == 0) setForeMap(x,y,value);
+        if (getForeMap(x,y) == 0 || value == 0) {
+            setForeMap(x,y,value);
+        }
     }
 
     public void placeToBackground(int x, int y, int value) {
-        if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).foreground))
-               setBackMap(x,y,value);
+        if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).foreground)) {
+            setBackMap(x,y,value);
+        }
     }
 
     public Vector2 getSpawnPoint() {
index d4635fd158f989307afa57ecd1127fbb94b0dcc6..8b1b69960a1ac95589a1fb8abaee393302d9f510 100644 (file)
@@ -1,7 +1,7 @@
 package ru.deadsoftware.cavecraft.game;
 
-import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.math.RandomXS128;
+import com.badlogic.gdx.utils.ArrayMap;
 import com.badlogic.gdx.utils.TimeUtils;
 
 public class WorldGen {
@@ -61,6 +61,8 @@ public class WorldGen {
         backMap = new int[width][height];
         hMap = genLandscape(width, height/2, height/4, height/4*3);
         for (int x=0; x<width; x++) {
+            for (int y=0; y<height; y++) {
+            }
             dirtH = 4+rand.nextInt(2);
             for (int y = height- hMap[x]; y<height; y++) {
                 if (y==height- hMap[x]) {
@@ -83,7 +85,9 @@ public class WorldGen {
                     backMap[x][y] = 8;
                 }
             }
-            if (x>2 && x<width-2 && rand.nextInt(100)<5) genOak(x,height-hMap[x]-1);
+            if (x>2 && x<width-2 && rand.nextInt(100)<5){
+                genOak(x,height-hMap[x]-1);
+            }
         }
     }