DEADSOFTWARE

Fix code style
authorfred-boy <fred-boy@protonmail.com>
Sun, 30 Sep 2018 07:11:19 +0000 (14:11 +0700)
committerfred-boy <fred-boy@protonmail.com>
Sun, 30 Sep 2018 07:11:19 +0000 (14:11 +0700)
24 files changed:
android/build.gradle
build.gradle
core/src/ru/deadsoftware/cavecraft/CaveGame.java
core/src/ru/deadsoftware/cavecraft/GameScreen.java
core/src/ru/deadsoftware/cavecraft/game/GameInput.java
core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
core/src/ru/deadsoftware/cavecraft/game/GameProc.java
core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
core/src/ru/deadsoftware/cavecraft/game/GameSaver.java
core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
core/src/ru/deadsoftware/cavecraft/game/Items.java
core/src/ru/deadsoftware/cavecraft/game/WorldGen.java
core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java
core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java
core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java
core/src/ru/deadsoftware/cavecraft/game/mobs/Pig.java
core/src/ru/deadsoftware/cavecraft/game/objects/Block.java
core/src/ru/deadsoftware/cavecraft/game/objects/Item.java
core/src/ru/deadsoftware/cavecraft/game/objects/Player.java
core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java
core/src/ru/deadsoftware/cavecraft/misc/Assets.java
core/src/ru/deadsoftware/cavecraft/misc/InputHandlerGame.java
core/src/ru/deadsoftware/cavecraft/misc/InputHandlerMenu.java
core/src/ru/deadsoftware/cavecraft/misc/Renderer.java

index 23d84e2d24ab0bf9c3942da07fdfc3a511c822d2..e917a5fd80b1271395d8917bd4ad6f9f09a91bfd 100644 (file)
@@ -24,7 +24,7 @@ android {
         minSdkVersion 9
         targetSdkVersion 20
         versionCode 5
-        versionName "alpha0.4-dev"
+        versionName "alpha0.4"
     }
     buildTypes {
         release {
index 76faca8873c4583f15e75357b06d0f8b4d604093..c413ee9e6136abd4059bfa55318543a2c25ae309 100644 (file)
@@ -18,7 +18,7 @@ allprojects {
     apply plugin: "eclipse"
     apply plugin: "idea"
 
-    version = 'alpha0.4-dev'
+    version = 'alpha0.4'
     ext {
         appName = "CaveCraft"
         gdxVersion = '1.9.7'
index d95c4774ab3587a8f852fa1f7245f146bd2e8d32..37fd2e109498b1ddddd218045e7e215feddf0f47 100644 (file)
@@ -6,37 +6,37 @@ import ru.deadsoftware.cavecraft.misc.AppState;
 
 public class CaveGame extends Game {
 
-       public static final String VERSION = "alpha 0.4-dev";
-       public static String GAME_FOLDER;
-
-       public static AppState STATE;
-
-       public static boolean TOUCH;
-
-       public CaveGame() {
-               this(false);
-       }
-
-       public CaveGame(boolean touch) {
-               TOUCH = touch;
-               STATE = AppState.MENU_MAIN;
-       }
-
-       @Override
-       public void create () {
-               switch (Gdx.app.getType()) {
-                       case Desktop:
-                               GAME_FOLDER = System.getProperty("user.home")+"/.cavecraft";
-                               break;
-                       case Android:
-                               GAME_FOLDER = "/sdcard/cavecraft";
-                               break;
-                       default:
-                               Gdx.app.exit();
-               }
-               Gdx.app.log("CaveGame", GAME_FOLDER);
-               Gdx.files.absolute(GAME_FOLDER).mkdirs();
-               setScreen(new GameScreen());
-       }
+    public static final String VERSION = "alpha 0.4";
+    public static String GAME_FOLDER;
+
+    public static AppState STATE;
+
+    public static boolean TOUCH;
+
+    public CaveGame() {
+        this(false);
+    }
+
+    public CaveGame(boolean touch) {
+        TOUCH = touch;
+        STATE = AppState.MENU_MAIN;
+    }
+
+    @Override
+    public void create() {
+        switch (Gdx.app.getType()) {
+            case Desktop:
+                GAME_FOLDER = System.getProperty("user.home") + "/.cavecraft";
+                break;
+            case Android:
+                GAME_FOLDER = "/sdcard/cavecraft";
+                break;
+            default:
+                Gdx.app.exit();
+        }
+        Gdx.app.log("CaveGame", GAME_FOLDER);
+        Gdx.files.absolute(GAME_FOLDER).mkdirs();
+        setScreen(new GameScreen());
+    }
 
 }
index dc7bb60c9cb746795b3ce40245dde99c6705252c..2704dbc4e68277ffb5eb44db0cb57b01baa22786 100644 (file)
@@ -20,7 +20,7 @@ public class GameScreen implements Screen {
     public GameScreen() {
         Assets.load();
         Items.load();
-        menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480);
+        menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
         renderer = menuRenderer;
         Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
     }
@@ -46,9 +46,10 @@ public class GameScreen implements Screen {
 
     @Override
     public void render(float delta) {
-        FPS = (int)(1/delta);
+        FPS = (int) (1 / delta);
         switch (CaveGame.STATE) {
-            case GAME_PLAY: case GAME_CREATIVE_INV:
+            case GAME_PLAY:
+            case GAME_CREATIVE_INV:
                 game(delta);
                 break;
 
@@ -76,7 +77,7 @@ public class GameScreen implements Screen {
                 break;
 
             case GOTO_MENU:
-                menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480);
+                menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
                 renderer = menuRenderer;
                 Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
                 break;
@@ -88,10 +89,11 @@ public class GameScreen implements Screen {
     public void resize(int width, int height) {
         switch (CaveGame.STATE) {
             case MENU_MAIN:
-                menuRenderer = new MenuRenderer(CaveGame.TOUCH?320:480);
+                menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
                 renderer = menuRenderer;
                 break;
-            case GAME_PLAY: case GAME_CREATIVE_INV:
+            case GAME_PLAY:
+            case GAME_CREATIVE_INV:
                 gameProc.resetRenderer();
                 renderer = gameProc.renderer;
                 break;
index 0f6c399c2ff60668c412fb0bdd1062964537b1e4..63cf93debf25046cb21e4345f1a75a532b43e325 100644 (file)
@@ -4,7 +4,6 @@ import com.badlogic.gdx.Input;
 import com.badlogic.gdx.utils.TimeUtils;
 import ru.deadsoftware.cavecraft.CaveGame;
 import ru.deadsoftware.cavecraft.GameScreen;
-import ru.deadsoftware.cavecraft.game.mobs.FallingSand;
 import ru.deadsoftware.cavecraft.game.mobs.Pig;
 import ru.deadsoftware.cavecraft.misc.AppState;
 import ru.deadsoftware.cavecraft.misc.Assets;
@@ -18,12 +17,12 @@ public class GameInput {
     }
 
     private boolean checkSwim() {
-        return (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16,
-                (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16)));
+        return (Items.isFluid(gameProc.world.getForeMap((int) (gameProc.player.position.x + gameProc.player.width / 2) / 16,
+                (int) (gameProc.player.position.y + gameProc.player.height / 4 * 3) / 16)));
     }
 
     private void wasdPressed(int keycode) {
-        if (gameProc.ctrlMode==0 || !CaveGame.TOUCH) {
+        if (gameProc.ctrlMode == 0 || !CaveGame.TOUCH) {
             switch (keycode) {
                 case Input.Keys.A:
                     gameProc.player.moveX.x = -GamePhysics.PL_SPEED;
@@ -36,7 +35,7 @@ public class GameInput {
                     if (CaveGame.TOUCH && checkSwim()) gameProc.swim = true;
                     break;
             }
-        } else if (CaveGame.TOUCH){
+        } else if (CaveGame.TOUCH) {
             switch (keycode) {
                 case Input.Keys.A:
                     gameProc.cursorX--;
@@ -55,7 +54,7 @@ public class GameInput {
         }
     }
 
-    public void  keyDown(int keycode) {
+    public void keyDown(int keycode) {
         gameProc.isKeyDown = true;
         gameProc.keyDownCode = keycode;
         if (keycode == Input.Keys.W || keycode == Input.Keys.A ||
@@ -88,14 +87,15 @@ public class GameInput {
 
             case Input.Keys.E:
                 if (CaveGame.STATE == AppState.GAME_PLAY) CaveGame.STATE = AppState.GAME_CREATIVE_INV;
-                    else CaveGame.STATE = AppState.GAME_PLAY;
+                else CaveGame.STATE = AppState.GAME_PLAY;
                 break;
 
             case Input.Keys.G:
-                gameProc.mobs.add(new Pig(gameProc.cursorX*16, gameProc.cursorY*16));
+                gameProc.mobs.add(new Pig(gameProc.cursorX * 16, gameProc.cursorY * 16));
                 break;
 
-            case Input.Keys.ESCAPE: case Input.Keys.BACK:
+            case Input.Keys.ESCAPE:
+            case Input.Keys.BACK:
                 CaveGame.STATE = AppState.GOTO_MENU;
                 break;
 
@@ -107,12 +107,14 @@ public class GameInput {
 
     public void keyUp(int keycode) {
         switch (keycode) {
-            case Input.Keys.A: case Input.Keys.D:
+            case Input.Keys.A:
+            case Input.Keys.D:
                 gameProc.player.moveX.x = 0;
                 if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false;
                 break;
 
-            case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT:
+            case Input.Keys.SPACE:
+            case Input.Keys.CONTROL_LEFT:
                 if (gameProc.player.flyMode) gameProc.player.moveY.setZero();
                 if (gameProc.swim) gameProc.swim = false;
                 break;
@@ -137,14 +139,14 @@ public class GameInput {
         }
         if (gameProc.isTouchDown) {
             if (CaveGame.STATE == AppState.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 &&
-                    screenY<gameProc.renderer.camera.viewportHeight/2+Assets.creativeInv.getRegionHeight()/2) {
+                    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 &&
+                    screenY < gameProc.renderer.camera.viewportHeight / 2 + Assets.creativeInv.getRegionHeight() / 2) {
                 int ix = (int) (screenX - (gameProc.renderer.camera.viewportWidth / 2 - Assets.creativeInv.getRegionWidth() / 2 + 8)) / 18;
                 int iy = (int) (screenY - (gameProc.renderer.camera.viewportHeight / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18;
-                int item = gameProc.creativeScroll*8+(ix + iy * 8);
-                if (ix>=8 || ix<0 || iy<0 || iy>=5) item=-1;
+                int item = gameProc.creativeScroll * 8 + (ix + iy * 8);
+                if (ix >= 8 || ix < 0 || iy < 0 || iy >= 5) item = -1;
                 if (item >= 0 && item < Items.ITEMS.size()) {
                     for (int i = 8; i > 0; i--) {
                         gameProc.player.inventory[i] = gameProc.player.inventory[i - 1];
@@ -153,13 +155,13 @@ public class GameInput {
                 }
             } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) {
                 CaveGame.STATE = AppState.GAME_PLAY;
-            } 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);
-            } else if (button == Input.Buttons.RIGHT){
+            } 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);
+            } else if (button == Input.Buttons.RIGHT) {
                 gameProc.useItem(gameProc.cursorX, gameProc.cursorY,
-                            gameProc.player.inventory[gameProc.invSlot], false);
+                        gameProc.player.inventory[gameProc.invSlot], false);
             } else if (button == Input.Buttons.LEFT) {
                 gameProc.blockDmg = 0;
             }
@@ -168,11 +170,11 @@ public class GameInput {
     }
 
     public void touchDragged(int screenX, int screenY) {
-        if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY-gameProc.touchDownY)>16) {
-            if (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 &&
-                    screenY<gameProc.renderer.camera.viewportHeight/2+Assets.creativeInv.getRegionHeight()/2) {
+        if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && Math.abs(screenY - gameProc.touchDownY) > 16) {
+            if (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 &&
+                    screenY < gameProc.renderer.camera.viewportHeight / 2 + Assets.creativeInv.getRegionHeight() / 2) {
                 gameProc.creativeScroll -= (screenY - gameProc.touchDownY) / 16;
                 gameProc.touchDownX = screenX;
                 gameProc.touchDownY = screenY;
@@ -191,10 +193,10 @@ public class GameInput {
                 if (gameProc.invSlot > 8) gameProc.invSlot = 0;
                 break;
             case GAME_CREATIVE_INV:
-                gameProc.creativeScroll+=amount;
-                if (gameProc.creativeScroll<0) gameProc.creativeScroll=0;
-                if (gameProc.creativeScroll>gameProc.maxCreativeScroll)
-                    gameProc.creativeScroll=gameProc.maxCreativeScroll;
+                gameProc.creativeScroll += amount;
+                if (gameProc.creativeScroll < 0) gameProc.creativeScroll = 0;
+                if (gameProc.creativeScroll > gameProc.maxCreativeScroll)
+                    gameProc.creativeScroll = gameProc.maxCreativeScroll;
                 break;
         }
     }
index e38e3b0b3ef12e858795cb204a4d93cd9e271744..66f4236924db1e93f5612c25190492e861d74e6a 100644 (file)
@@ -21,40 +21,40 @@ public class GamePhysics {
 
     public GamePhysics(GameProc gameProc) {
         this.gameProc = gameProc;
-        gravity = new Vector2(0,.9f);
+        gravity = new Vector2(0, .9f);
     }
 
     private boolean checkJump(Rectangle rect, int dir) {
         int bl;
         switch (dir) {
             case 0:
-                bl = gameProc.world.getForeMap((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16));
-                if (checkColl(new Rectangle(rect.x-8, rect.y-18, rect.width, rect.height))) bl=0;
+                bl = gameProc.world.getForeMap((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16));
+                if (checkColl(new Rectangle(rect.x - 8, rect.y - 18, rect.width, rect.height))) bl = 0;
                 break;
             case 1:
-                bl = gameProc.world.getForeMap((int)((rect.x+rect.width+8)/16),(int)((rect.y+rect.height-8)/16));
-                if (checkColl(new Rectangle(rect.x+rect.width+8, rect.y-18, rect.width, rect.height))) bl=0;
+                bl = gameProc.world.getForeMap((int) ((rect.x + rect.width + 8) / 16), (int) ((rect.y + rect.height - 8) / 16));
+                if (checkColl(new Rectangle(rect.x + rect.width + 8, rect.y - 18, rect.width, rect.height))) bl = 0;
                 break;
             default:
-                bl=0;
+                bl = 0;
         }
-        return (bl>0 && Items.BLOCKS.getValueAt(bl).toJump() &&
-                (rect.y+rect.height)-Items.BLOCKS.getValueAt(bl).getRect((int)((rect.x-8)/16),(int)((rect.y+rect.height-8)/16)).y>8);
+        return (bl > 0 && Items.BLOCKS.getValueAt(bl).toJump() &&
+                (rect.y + rect.height) - Items.BLOCKS.getValueAt(bl).getRect((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16)).y > 8);
     }
 
     private boolean checkColl(Rectangle rect) {
         int bl;
-        int minX = (int) ((rect.x+rect.width/2)/16)-4;
-        int minY = (int) ((rect.y+rect.height/2)/16)-4;
-        int maxX = (int) ((rect.x+rect.width/2)/16)+4;
-        int maxY = (int) ((rect.y+rect.height/2)/16)+4;
-        if (minY<0) minY=0;
-        if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
-        for (int y=minY; y<maxY; y++) {
-            for (int x=minX; x<maxX; x++) {
-                bl = gameProc.world.getForeMap(x,y);
-                if (bl>0 && Items.BLOCKS.getValueAt(bl).collision){
-                    if (Intersector.overlaps(rect, Items.BLOCKS.getValueAt(bl).getRect(x,y))){
+        int minX = (int) ((rect.x + rect.width / 2) / 16) - 4;
+        int minY = (int) ((rect.y + rect.height / 2) / 16) - 4;
+        int maxX = (int) ((rect.x + rect.width / 2) / 16) + 4;
+        int maxY = (int) ((rect.y + rect.height / 2) / 16) + 4;
+        if (minY < 0) minY = 0;
+        if (maxY > gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
+        for (int y = minY; y < maxY; y++) {
+            for (int x = minX; x < maxX; x++) {
+                bl = gameProc.world.getForeMap(x, y);
+                if (bl > 0 && Items.BLOCKS.getValueAt(bl).collision) {
+                    if (Intersector.overlaps(rect, Items.BLOCKS.getValueAt(bl).getRect(x, y))) {
                         return true;
                     }
                 }
@@ -64,11 +64,11 @@ public class GamePhysics {
     }
 
     private int getBlock(Rectangle rect) {
-        return gameProc.world.getForeMap((int)(rect.x+rect.width/2)/16, (int)(rect.y+rect.height/8*7)/16);
+        return gameProc.world.getForeMap((int) (rect.x + rect.width / 2) / 16, (int) (rect.y + rect.height / 8 * 7) / 16);
     }
 
     private void dropPhy(Drop drop) {
-        if (drop.move.y < 9) drop.move.y += gravity.y/4;
+        if (drop.move.y < 9) drop.move.y += gravity.y / 4;
         drop.position.add(drop.move);
         drop.position.y = MathUtils.round(drop.position.y);
         while (checkColl(drop.getRect())) {
@@ -81,36 +81,36 @@ public class GamePhysics {
         pl.position.add(pl.moveY);
         if (checkColl(pl.getRect())) {
             int d = -1;
-            if (pl.moveY.y<0) d=1;
-            if (d==-1) {
+            if (pl.moveY.y < 0) d = 1;
+            if (d == -1) {
                 pl.flyMode = false;
                 pl.canJump = true;
             }
             pl.position.y = MathUtils.round(pl.position.y);
-            while (checkColl(pl.getRect())) pl.position.y+=d;
+            while (checkColl(pl.getRect())) pl.position.y += d;
             pl.moveY.setZero();
         } else {
             pl.canJump = false;
         }
 
         if (Items.isFluid(getBlock(pl.getRect()))) {
-            if (CaveGame.TOUCH && pl.moveX.x!=0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true;
+            if (CaveGame.TOUCH && pl.moveX.x != 0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true;
             if (!gameProc.swim) {
                 if (!pl.flyMode && pl.moveY.y < 4.5f) pl.moveY.add(gravity.x / 4, gravity.y / 4);
                 if (!pl.flyMode && pl.moveY.y > 4.5f) pl.moveY.add(0, -1f);
             } else {
                 pl.moveY.add(0, -.5f);
-                if (pl.moveY.y<-3) pl.moveY.y = -3;
+                if (pl.moveY.y < -3) pl.moveY.y = -3;
             }
         } else {
-            if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity);
+            if (!pl.flyMode && pl.moveY.y < 18) pl.moveY.add(gravity);
         }
 
         pl.position.add(pl.moveX);
         if (checkColl(pl.getRect())) {
-            if (pl.canJump && !pl.flyMode) pl.position.y-=8;
+            if (pl.canJump && !pl.flyMode) pl.position.y -= 8;
             if (checkColl(pl.getRect())) {
-                if (pl.canJump && !pl.flyMode) pl.position.y+=8;
+                if (pl.canJump && !pl.flyMode) pl.position.y += 8;
                 int d = 0;
                 if (pl.moveX.x < 0) d = 1;
                 else if (pl.moveX.x > 0) d = -1;
@@ -118,9 +118,10 @@ public class GamePhysics {
                 while (checkColl(pl.getRect())) pl.position.x += d;
             }
         }
-        if (pl.position.x+pl.texWidth/2<0) pl.position.x+=gameProc.world.getWidth()*16;
-        if (pl.position.x+pl.texWidth/2>gameProc.world.getWidth()*16) pl.position.x-=gameProc.world.getWidth()*16;
-        if (pl.position.y > gameProc.world.getHeight()*16) {
+        if (pl.position.x + pl.texWidth / 2 < 0) pl.position.x += gameProc.world.getWidth() * 16;
+        if (pl.position.x + pl.texWidth / 2 > gameProc.world.getWidth() * 16)
+            pl.position.x -= gameProc.world.getWidth() * 16;
+        if (pl.position.y > gameProc.world.getHeight() * 16) {
             pl.position = gameProc.world.getSpawnPoint().cpy();
         }
         if (CaveGame.TOUCH && checkJump(pl.getRect(), pl.dir) && !pl.flyMode && pl.canJump && !pl.moveX.equals(Vector2.Zero)) {
@@ -133,13 +134,13 @@ public class GamePhysics {
         mob.position.add(mob.moveY);
         if (checkColl(mob.getRect())) {
             int d = -1;
-            if (mob.moveY.y<0) d=1;
-            if (d==-1) mob.canJump = true;
+            if (mob.moveY.y < 0) d = 1;
+            if (d == -1) mob.canJump = true;
             mob.position.y = MathUtils.round(mob.position.y);
-            while (checkColl(mob.getRect())) mob.position.y+=d;
+            while (checkColl(mob.getRect())) mob.position.y += d;
             mob.moveY.setZero();
             if (mob.getType() > 0) {
-                gameProc.world.setForeMap((int)mob.position.x/16, (int)mob.position.y/16, mob.getType());
+                gameProc.world.setForeMap((int) mob.position.x / 16, (int) mob.position.y / 16, mob.getType());
                 mob.position.y = -1;
                 mob.dead = true;
             }
@@ -147,19 +148,19 @@ public class GamePhysics {
             mob.canJump = false;
         }
 
-        if (mob.getType()==0 && Items.isFluid(getBlock(mob.getRect()))) {
+        if (mob.getType() == 0 && Items.isFluid(getBlock(mob.getRect()))) {
             if (mob.moveY.y > 9) mob.moveY.add(0, -.9f);
             mob.moveY.add(0, -.5f);
-            if (mob.moveY.y<-3) mob.moveY.y = -3;
-        } else if (mob.moveY.y<18) mob.moveY.add(gravity);
+            if (mob.moveY.y < -3) mob.moveY.y = -3;
+        } else if (mob.moveY.y < 18) mob.moveY.add(gravity);
 
         mob.position.add(mob.moveX);
         if (checkColl(mob.getRect())) {
             if (mob.canJump) {
-                mob.position.y-=8;
+                mob.position.y -= 8;
             }
             if (checkColl(mob.getRect())) {
-                if (mob.canJump) mob.position.y+=8;
+                if (mob.canJump) mob.position.y += 8;
                 int d = 0;
                 if (mob.moveX.x < 0) d = 1;
                 else if (mob.moveX.x > 0) d = -1;
@@ -168,16 +169,17 @@ public class GamePhysics {
                 if (mob.canJump) mob.changeDir();
             }
         }
-        if (mob.position.x+mob.width/2<0) mob.position.x+=gameProc.world.getWidth()*16;
-        if (mob.position.x+mob.width/2>gameProc.world.getWidth()*16) mob.position.x-=gameProc.world.getWidth()*16;
-        if (mob.position.y > gameProc.world.getHeight()*16) {
+        if (mob.position.x + mob.width / 2 < 0) mob.position.x += gameProc.world.getWidth() * 16;
+        if (mob.position.x + mob.width / 2 > gameProc.world.getWidth() * 16)
+            mob.position.x -= gameProc.world.getWidth() * 16;
+        if (mob.position.y > gameProc.world.getHeight() * 16) {
             mob.position.y = 0;
         }
         if (checkJump(mob.getRect(), mob.dir) && mob.canJump && !mob.moveX.equals(Vector2.Zero)) {
             mob.moveY.add(0, -8);
             mob.canJump = false;
         }
-}
+    }
 
     public void update(float delta) {
         for (Iterator<Drop> it = gameProc.drops.iterator(); it.hasNext(); ) {
@@ -188,7 +190,7 @@ public class GamePhysics {
             if (drop.pickedUp) it.remove();
         }
 
-        for (Iterator<Mob> it = gameProc.mobs.iterator(); it.hasNext();) {
+        for (Iterator<Mob> it = gameProc.mobs.iterator(); it.hasNext(); ) {
             Mob mob = it.next();
             mob.ai();
             mobPhy(mob);
@@ -199,8 +201,8 @@ public class GamePhysics {
         playerPhy(gameProc.player);
 
         gameProc.renderer.camera.position.set(
-                gameProc.player.position.x+gameProc.player.texWidth/2 - gameProc.renderer.camera.viewportWidth/2,
-                gameProc.player.position.y+gameProc.player.height/2-gameProc.renderer.camera.viewportHeight/2,
+                gameProc.player.position.x + gameProc.player.texWidth / 2 - gameProc.renderer.camera.viewportWidth / 2,
+                gameProc.player.position.y + gameProc.player.height / 2 - gameProc.renderer.camera.viewportHeight / 2,
                 0
         );
     }
index 25658c165421870f9d3868e08f16f4bd96a2e847..e4d12b285c025e31233b09217875c32567f1a09e 100644 (file)
@@ -17,7 +17,7 @@ import ru.deadsoftware.cavecraft.misc.Assets;
 import java.io.Serializable;
 import java.util.ArrayList;
 
-public class GameProc implements Serializable{
+public class GameProc implements Serializable {
 
     public static double RUN_TIME = 0;
 
@@ -46,39 +46,39 @@ public class GameProc implements Serializable{
 
     public GameProc() {
         world = new GameWorld();
-        world.generate(1024,256);
+        world.generate(1024, 256);
         player = new Player(world.getSpawnPoint());
         drops = new ArrayList<Drop>();
         mobs = new ArrayList<Mob>();
-        for (int i=0; i<16; i++) {
-            mobs.add(new Pig(i*256, 196*16));
+        for (int i = 0; i < 16; i++) {
+            mobs.add(new Pig(i * 256, 196 * 16));
         }
         physics = new GamePhysics(this);
         if (CaveGame.TOUCH) {
-            renderer = new GameRenderer(this,320,
-                    320*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+            renderer = new GameRenderer(this, 320,
+                    320 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         } else {
             ctrlMode = 1;
-            renderer = new GameRenderer(this,480,
-                    480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+            renderer = new GameRenderer(this, 480,
+                    480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         }
-        maxCreativeScroll = Items.ITEMS.size()/8;
+        maxCreativeScroll = Items.ITEMS.size() / 8;
         GameSaver.save(this);
     }
 
     public void resetRenderer() {
         if (CaveGame.TOUCH) {
-            renderer = new GameRenderer(this,320,
-                    320*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+            renderer = new GameRenderer(this, 320,
+                    320 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         } else {
-            renderer = new GameRenderer(this,480,
-                    480*((float)GameScreen.getHeight()/GameScreen.getWidth()));
+            renderer = new GameRenderer(this, 480,
+                    480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         }
     }
 
     private boolean isAutoselectable(int x, int y) {
-        return (world.getForeMap(x,y)>0 &&
-                Items.BLOCKS.getValueAt(world.getForeMap(x,y)).collision);
+        return (world.getForeMap(x, y) > 0 &&
+                Items.BLOCKS.getValueAt(world.getForeMap(x, y)).collision);
     }
 
     private void moveCursor() {
@@ -86,7 +86,7 @@ public class GameProc implements Serializable{
         if (ctrlMode == 0 && CaveGame.TOUCH) {
             cursorX = (int) (player.position.x + player.texWidth / 2) / 16;
             if (player.dir == 0) cursorX--;
-                else cursorX++;
+            else cursorX++;
             cursorY = (int) (player.position.y + player.texWidth) / 16;
             if (!isAutoselectable(cursorX, cursorY)) {
                 cursorY++;
@@ -98,249 +98,251 @@ public class GameProc implements Serializable{
                 if (player.dir == 0) cursorX++;
                 else cursorX--;
             }
-        } else if (!CaveGame.TOUCH){
-            cursorX = (int)(Gdx.input.getX()*
-                    (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)/16;
-            cursorY = (int)(Gdx.input.getY()*
-                    (renderer.camera.viewportHeight/GameScreen.getHeight())+renderer.camera.position.y)/16;
-            if ((Gdx.input.getX()*
-                    (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)<0)
+        } else if (!CaveGame.TOUCH) {
+            cursorX = (int) (Gdx.input.getX() *
+                    (renderer.camera.viewportWidth / GameScreen.getWidth()) + renderer.camera.position.x) / 16;
+            cursorY = (int) (Gdx.input.getY() *
+                    (renderer.camera.viewportHeight / GameScreen.getHeight()) + renderer.camera.position.y) / 16;
+            if ((Gdx.input.getX() *
+                    (renderer.camera.viewportWidth / GameScreen.getWidth()) + renderer.camera.position.x) < 0)
                 cursorX--;
         }
-        if (pastX!=cursorX || pastY!=cursorY) blockDmg = 0;
+        if (pastX != cursorX || pastY != cursorY) blockDmg = 0;
     }
 
     private void checkCursorBounds() {
         if (cursorY < 0) cursorY = 0;
-        if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1;
-        if (ctrlMode==1) {
-            if (cursorX*16+8<player.position.x+player.texWidth/2)
-                player.dir=0;
-            if (cursorX*16+8>player.position.x+player.texWidth/2)
-                player.dir=1;
+        if (cursorY >= world.getHeight()) cursorY = world.getHeight() - 1;
+        if (ctrlMode == 1) {
+            if (cursorX * 16 + 8 < player.position.x + player.texWidth / 2)
+                player.dir = 0;
+            if (cursorX * 16 + 8 > player.position.x + player.texWidth / 2)
+                player.dir = 1;
         }
     }
 
     private void updateFluids(int x, int y) {
-        if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y)!=8) {
-            if (world.getForeMap(x, y)==60) {
+        if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y) != 8) {
+            if (world.getForeMap(x, y) == 60) {
                 if (!Items.isWater(world.getForeMap(x, y - 1)))
                     world.setForeMap(x, y, world.getForeMap(x, y) + 1);
-            } else if ((!Items.isWater(world.getForeMap(x-1,y)) ||
-                    (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) &&
-                    (!Items.isWater(world.getForeMap(x+1,y)) ||
-                            (Items.isWater(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){
-                world.setForeMap(x, y, world.getForeMap(x, y)+1);
+            } else if ((!Items.isWater(world.getForeMap(x - 1, y)) ||
+                    (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) &&
+                    (!Items.isWater(world.getForeMap(x + 1, y)) ||
+                            (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x + 1, y) >= world.getForeMap(x, y)))) {
+                world.setForeMap(x, y, world.getForeMap(x, y) + 1);
             }
-            if (world.getForeMap(x, y)>63) world.setForeMap(x, y, 0);
+            if (world.getForeMap(x, y) > 63) world.setForeMap(x, y, 0);
         }
 
         if (world.getForeMap(x, y) == 8 || world.getForeMap(x, y) == 60) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,60);
-                updateBlock(x, y+2);
-            } else if (Items.isLava(world.getForeMap(x, y+1))) {
-                if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4);
-                else world.setForeMap(x, y+1, 68);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ||
-                        (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>61)) {
-                    world.setForeMap(x+1,y,61);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isLava(world.getForeMap(x+1, y))) {
-                    if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4);
-                    else world.setForeMap(x+1, y, 68);
-                } else if (world.getForeMap(x+1, y)==61 && (world.getForeMap(x+2, y)==8 || world.getForeMap(x+2, y)==60)) world.setForeMap(x+1, y, 8);
-
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ||
-                        (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>61)) {
-                    world.setForeMap(x-1,y,61);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isLava(world.getForeMap(x-1, y))) {
-                    if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4);
-                    else world.setForeMap(x-1, y, 68);
-                } else if (world.getForeMap(x-1, y)==61 && (world.getForeMap(x-2, y)==8 || world.getForeMap(x-2, y)==60)) world.setForeMap(x-1, y, 8);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 60);
+                updateBlock(x, y + 2);
+            } else if (Items.isLava(world.getForeMap(x, y + 1))) {
+                if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4);
+                else world.setForeMap(x, y + 1, 68);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) ||
+                        (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 61)) {
+                    world.setForeMap(x + 1, y, 61);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x + 1, y))) {
+                    if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4);
+                    else world.setForeMap(x + 1, y, 68);
+                } else if (world.getForeMap(x + 1, y) == 61 && (world.getForeMap(x + 2, y) == 8 || world.getForeMap(x + 2, y) == 60))
+                    world.setForeMap(x + 1, y, 8);
+
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) ||
+                        (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 61)) {
+                    world.setForeMap(x - 1, y, 61);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x - 1, y))) {
+                    if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4);
+                    else world.setForeMap(x - 1, y, 68);
+                } else if (world.getForeMap(x - 1, y) == 61 && (world.getForeMap(x - 2, y) == 8 || world.getForeMap(x - 2, y) == 60))
+                    world.setForeMap(x - 1, y, 8);
             }
             return;
         }
         if (world.getForeMap(x, y) == 61) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,60);
-                updateBlock(x, y+2);
-            } else if (Items.isLava(world.getForeMap(x, y+1))) {
-                if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4);
-                else world.setForeMap(x, y+1, 68);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ||
-                        (Items.isWater(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>62)){
-                    world.setForeMap(x+1,y,62);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isLava(world.getForeMap(x+1, y))) {
-                    if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4);
-                    else world.setForeMap(x+1, y, 68);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 60);
+                updateBlock(x, y + 2);
+            } else if (Items.isLava(world.getForeMap(x, y + 1))) {
+                if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4);
+                else world.setForeMap(x, y + 1, 68);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) ||
+                        (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 62)) {
+                    world.setForeMap(x + 1, y, 62);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x + 1, y))) {
+                    if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4);
+                    else world.setForeMap(x + 1, y, 68);
                 }
 
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ||
-                        (Items.isWater(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>62)){
-                    world.setForeMap(x-1,y,62);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isLava(world.getForeMap(x-1, y))) {
-                    if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4);
-                    else world.setForeMap(x-1, y, 68);
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) ||
+                        (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 62)) {
+                    world.setForeMap(x - 1, y, 62);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x - 1, y))) {
+                    if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4);
+                    else world.setForeMap(x - 1, y, 68);
                 }
             }
             return;
         }
         if (world.getForeMap(x, y) == 62) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,60);
-                updateBlock(x, y+2);
-            } else if (Items.isLava(world.getForeMap(x, y+1))) {
-                if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4);
-                else world.setForeMap(x, y+1, 68);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){
-                    world.setForeMap(x+1,y,63);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isLava(world.getForeMap(x+1, y))) {
-                    if (world.getForeMap(x+1, y)>9) world.setForeMap(x+1, y, 4);
-                    else world.setForeMap(x+1, y, 68);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 60);
+                updateBlock(x, y + 2);
+            } else if (Items.isLava(world.getForeMap(x, y + 1))) {
+                if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4);
+                else world.setForeMap(x, y + 1, 68);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y)))) {
+                    world.setForeMap(x + 1, y, 63);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x + 1, y))) {
+                    if (world.getForeMap(x + 1, y) > 9) world.setForeMap(x + 1, y, 4);
+                    else world.setForeMap(x + 1, y, 68);
                 }
 
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){
-                    world.setForeMap(x-1,y,63);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isLava(world.getForeMap(x-1, y))) {
-                    if (world.getForeMap(x-1, y)>9) world.setForeMap(x-1, y, 4);
-                    else world.setForeMap(x-1, y, 68);
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y)))) {
+                    world.setForeMap(x - 1, y, 63);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isLava(world.getForeMap(x - 1, y))) {
+                    if (world.getForeMap(x - 1, y) > 9) world.setForeMap(x - 1, y, 4);
+                    else world.setForeMap(x - 1, y, 68);
                 }
             }
             return;
         }
         if (world.getForeMap(x, y) == 63) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=61 && world.getForeMap(x, y+1)<=63) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,60);
-                updateBlock(x, y+2);
-            } else if (Items.isLava(world.getForeMap(x, y+1))) {
-                if (world.getForeMap(x, y+1)>9) world.setForeMap(x, y+1, 4);
-                else world.setForeMap(x, y+1, 68);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 61 && world.getForeMap(x, y + 1) <= 63) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 60);
+                updateBlock(x, y + 2);
+            } else if (Items.isLava(world.getForeMap(x, y + 1))) {
+                if (world.getForeMap(x, y + 1) > 9) world.setForeMap(x, y + 1, 4);
+                else world.setForeMap(x, y + 1, 68);
             }
             return;
         }
 
-        if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y)!=9) {
-            if (world.getForeMap(x, y)==64) {
+        if (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y) != 9) {
+            if (world.getForeMap(x, y) == 64) {
                 if (!Items.isLava(world.getForeMap(x, y - 1)))
                     world.setForeMap(x, y, world.getForeMap(x, y) + 1);
-            } else if ((!Items.isLava(world.getForeMap(x,y-1))) &&
-                    (!Items.isLava(world.getForeMap(x-1,y)) ||
-                    (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x-1, y)>=world.getForeMap(x, y))) &&
-                    (!Items.isLava(world.getForeMap(x+1,y)) ||
-                            (Items.isLava(world.getForeMap(x,y)) && world.getForeMap(x+1, y)>=world.getForeMap(x, y)))){
-                world.setForeMap(x, y, world.getForeMap(x, y)+1);
+            } else if ((!Items.isLava(world.getForeMap(x, y - 1))) &&
+                    (!Items.isLava(world.getForeMap(x - 1, y)) ||
+                            (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) &&
+                    (!Items.isLava(world.getForeMap(x + 1, y)) ||
+                            (Items.isLava(world.getForeMap(x, y)) && world.getForeMap(x + 1, y) >= world.getForeMap(x, y)))) {
+                world.setForeMap(x, y, world.getForeMap(x, y) + 1);
             }
-            if (world.getForeMap(x, y)>67) world.setForeMap(x, y, 0);
+            if (world.getForeMap(x, y) > 67) world.setForeMap(x, y, 0);
         }
 
         if (world.getForeMap(x, y) == 9 || world.getForeMap(x, y) == 64) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,64);
-                updateBlock(x, y+2);
-            } else if (Items.isWater(world.getForeMap(x, y+1))) {
-                world.setForeMap(x, y+1, 1);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ||
-                        (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>65)) {
-                    world.setForeMap(x+1,y,65);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isWater(world.getForeMap(x+1, y))) {
-                    world.setForeMap(x+1, y, 1);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 64);
+                updateBlock(x, y + 2);
+            } else if (Items.isWater(world.getForeMap(x, y + 1))) {
+                world.setForeMap(x, y + 1, 1);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) ||
+                        (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 65)) {
+                    world.setForeMap(x + 1, y, 65);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x + 1, y))) {
+                    world.setForeMap(x + 1, y, 1);
                 }
 
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ||
-                        (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>65)) {
-                    world.setForeMap(x-1,y,65);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isWater(world.getForeMap(x-1, y))) {
-                    world.setForeMap(x-1, y, 1);
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) ||
+                        (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 65)) {
+                    world.setForeMap(x - 1, y, 65);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x - 1, y))) {
+                    world.setForeMap(x - 1, y, 1);
                 }
             }
             return;
         }
         if (world.getForeMap(x, y) == 65) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,64);
-                updateBlock(x, y+2);
-            } else if (Items.isWater(world.getForeMap(x, y+1))) {
-                world.setForeMap(x, y+1, 1);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ||
-                        (Items.isLava(world.getForeMap(x+1, y)) && world.getForeMap(x+1, y)>66)){
-                    world.setForeMap(x+1,y,66);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isWater(world.getForeMap(x+1, y))) {
-                    world.setForeMap(x+1, y, 1);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 64);
+                updateBlock(x, y + 2);
+            } else if (Items.isWater(world.getForeMap(x, y + 1))) {
+                world.setForeMap(x, y + 1, 1);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y))) ||
+                        (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 66)) {
+                    world.setForeMap(x + 1, y, 66);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x + 1, y))) {
+                    world.setForeMap(x + 1, y, 1);
                 }
 
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ||
-                        (Items.isLava(world.getForeMap(x-1, y)) && world.getForeMap(x-1, y)>66)){
-                    world.setForeMap(x-1,y,66);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isWater(world.getForeMap(x-1, y))) {
-                    world.setForeMap(x-1, y, 1);
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y))) ||
+                        (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 66)) {
+                    world.setForeMap(x - 1, y, 66);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x - 1, y))) {
+                    world.setForeMap(x - 1, y, 1);
                 }
             }
             return;
         }
         if (world.getForeMap(x, y) == 66) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,64);
-                updateBlock(x, y+2);
-            } else if (Items.isWater(world.getForeMap(x, y+1))) {
-                world.setForeMap(x, y+1, 1);
-            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                if (world.getForeMap(x+1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x+1, y)).collision && !Items.isFluid(world.getForeMap(x+1, y))) ){
-                    world.setForeMap(x+1,y,67);
-                    updateBlock(x+1, y+1);
-                } else if (Items.isWater(world.getForeMap(x+1, y))) {
-                    world.setForeMap(x+1, y, 1);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 64);
+                updateBlock(x, y + 2);
+            } else if (Items.isWater(world.getForeMap(x, y + 1))) {
+                world.setForeMap(x, y + 1, 1);
+            } else if (Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                if (world.getForeMap(x + 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x + 1, y)).collision && !Items.isFluid(world.getForeMap(x + 1, y)))) {
+                    world.setForeMap(x + 1, y, 67);
+                    updateBlock(x + 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x + 1, y))) {
+                    world.setForeMap(x + 1, y, 1);
                 }
 
-                if (world.getForeMap(x-1, y)==0 ||
-                        (!Items.BLOCKS.getValueAt(world.getForeMap(x-1, y)).collision && !Items.isFluid(world.getForeMap(x-1, y))) ){
-                    world.setForeMap(x-1,y,67);
-                    updateBlock(x-1, y+1);
-                } else if (Items.isWater(world.getForeMap(x-1, y))) {
-                    world.setForeMap(x-1, y, 1);
+                if (world.getForeMap(x - 1, y) == 0 ||
+                        (!Items.BLOCKS.getValueAt(world.getForeMap(x - 1, y)).collision && !Items.isFluid(world.getForeMap(x - 1, y)))) {
+                    world.setForeMap(x - 1, y, 67);
+                    updateBlock(x - 1, y + 1);
+                } else if (Items.isWater(world.getForeMap(x - 1, y))) {
+                    world.setForeMap(x - 1, y, 1);
                 }
             }
             return;
         }
         if (world.getForeMap(x, y) == 67) {
-            if (world.getForeMap(x, y+1)==0 || (world.getForeMap(x, y+1)>=65 && world.getForeMap(x, y+1)<=67) ||
-                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision && !Items.isFluid(world.getForeMap(x, y+1)))) {
-                world.setForeMap(x,y+1,64);
-                updateBlock(x, y+2);
-            } else if (Items.isWater(world.getForeMap(x, y+1))) {
-                world.setForeMap(x, y+1, 1);
+            if (world.getForeMap(x, y + 1) == 0 || (world.getForeMap(x, y + 1) >= 65 && world.getForeMap(x, y + 1) <= 67) ||
+                    (!Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+                world.setForeMap(x, y + 1, 64);
+                updateBlock(x, y + 2);
+            } else if (Items.isWater(world.getForeMap(x, y + 1))) {
+                world.setForeMap(x, y + 1, 1);
             }
             return;
         }
@@ -348,40 +350,40 @@ public class GameProc implements Serializable{
 
     private void updateBlock(int x, int y) {
         if (world.getForeMap(x, y) == 10) {
-            if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) {
+            if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
                 world.setForeMap(x, y, 0);
-                mobs.add(new FallingSand(x*16, y*16));
-                updateBlock(x, y-1);
+                mobs.add(new FallingSand(x * 16, y * 16));
+                updateBlock(x, y - 1);
             }
         }
 
         if (world.getForeMap(x, y) == 11) {
-            if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x,y+1)).collision) {
+            if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
                 world.setForeMap(x, y, 0);
-                mobs.add(new FallingGravel(x*16, y*16));
-                updateBlock(x, y-1);
+                mobs.add(new FallingGravel(x * 16, y * 16));
+                updateBlock(x, y - 1);
             }
         }
 
         if (world.getForeMap(x, y) == 59) {
-            if (world.getForeMap(x, y+1)==0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y+1)).collision) {
-                world.setForeMap(x,y,0);
-                updateBlock(x, y-1);
+            if (world.getForeMap(x, y + 1) == 0 || !Items.BLOCKS.getValueAt(world.getForeMap(x, y + 1)).collision) {
+                world.setForeMap(x, y, 0);
+                updateBlock(x, y - 1);
             }
         }
 
         if (world.getForeMap(x, y) == 2) {
-            if (world.getForeMap(x, y-1)>0 && (Items.BLOCKS.getValueAt(world.getForeMap(x, y-1)).collision ||
-                    Items.isFluid(world.getForeMap(x, y-1)))) {
+            if (world.getForeMap(x, y - 1) > 0 && (Items.BLOCKS.getValueAt(world.getForeMap(x, y - 1)).collision ||
+                    Items.isFluid(world.getForeMap(x, y - 1)))) {
                 world.setForeMap(x, y, 3);
             }
         }
     }
 
     public void useItem(int x, int y, int id, boolean bg) {
-        if (id>0 && Items.ITEMS.get(id).getType()==0) {
+        if (id > 0 && Items.ITEMS.get(id).getType() == 0) {
             if (!bg) world.placeToForeground(x, y, Items.ITEMS.get(id).getBlock());
-            else world.placeToBackground(x, y,  Items.ITEMS.get(id).getBlock());
+            else world.placeToBackground(x, y, Items.ITEMS.get(id).getBlock());
         }
     }
 
@@ -389,15 +391,15 @@ public class GameProc implements Serializable{
         RUN_TIME += delta;
 
         if (DO_UPD) {
-            for (int y=UPD_Y; y<UPD_Y+16; y++)
-                for (int x=UPD_X; x<UPD_X+16; x++) {
+            for (int y = UPD_Y; y < UPD_Y + 16; y++)
+                for (int x = UPD_X; x < UPD_X + 16; x++) {
                     updateBlock(x, y);
                 }
             DO_UPD = false;
         }
 
-        for (int y=0; y<world.getHeight(); y++) {
-            for (int x=(int)renderer.camera.position.x/16-1; x<(int)(renderer.camera.position.x+renderer.camera.viewportWidth)/16+1; x++) {
+        for (int y = 0; y < world.getHeight(); y++) {
+            for (int x = (int) renderer.camera.position.x / 16 - 1; x < (int) (renderer.camera.position.x + renderer.camera.viewportWidth) / 16 + 1; x++) {
                 updateFluids(x, y);
             }
         }
@@ -406,26 +408,26 @@ public class GameProc implements Serializable{
         moveCursor();
         checkCursorBounds();
 
-        if (isTouchDown && touchDownButton==Input.Buttons.LEFT) {
+        if (isTouchDown && touchDownButton == Input.Buttons.LEFT) {
             if (world.getForeMap(cursorX, cursorY) > 0 &&
-                    Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()>=0){// || world.getBackMap(cursorX, cursorY) > 0) {
+                    Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp() >= 0) {// || world.getBackMap(cursorX, cursorY) > 0) {
                 blockDmg++;
-                if (blockDmg>=Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()) {
-                    if (Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop()>0)
-                        drops.add(new Drop(cursorX*16+4, cursorY*16+4, Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop()));
+                if (blockDmg >= Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getHp()) {
+                    if (Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop() > 0)
+                        drops.add(new Drop(cursorX * 16 + 4, cursorY * 16 + 4, Items.BLOCKS.getValueAt(world.getForeMap(cursorX, cursorY)).getDrop()));
                     world.placeToForeground(cursorX, cursorY, 0);
-                    blockDmg=0;
+                    blockDmg = 0;
                 }
             }
         }
 
         if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) {
-            if (touchDownButton== Input.Buttons.RIGHT) {
+            if (touchDownButton == Input.Buttons.RIGHT) {
                 useItem(cursorX, cursorY, player.inventory[invSlot], true);
                 isTouchDown = false;
-            } else if (touchDownY< Assets.invBar.getRegionHeight() &&
-                    touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
-                    touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
+            } else if (touchDownY < Assets.invBar.getRegionHeight() &&
+                    touchDownX > renderer.camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 &&
+                    touchDownX < renderer.camera.viewportWidth / 2 + Assets.invBar.getRegionWidth() / 2) {
                 CaveGame.STATE = AppState.GAME_CREATIVE_INV;
                 isTouchDown = false;
             }
index 3d3a8f60b8a67b6999e81a097bdacb5dcf939d44..5a8ab943a1b5c18691497a2f6523f1e9d47d45b7 100644 (file)
@@ -1,9 +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.glutils.ShapeRenderer;
 import com.badlogic.gdx.math.MathUtils;
 import com.badlogic.gdx.math.Vector2;
 import ru.deadsoftware.cavecraft.CaveGame;
@@ -18,51 +16,51 @@ public class GameRenderer extends Renderer {
 
     private GameProc gameProc;
 
-    public GameRenderer(GameProc gameProc,float width, float heigth) {
-        super(width,heigth);
-        Gdx.gl.glClearColor(0f,.6f,.6f,1f);
+    public GameRenderer(GameProc gameProc, float width, float heigth) {
+        super(width, heigth);
+        Gdx.gl.glClearColor(0f, .6f, .6f, 1f);
         this.gameProc = gameProc;
     }
 
     private void drawWorldBackground() {
-        int minX = (int) (camera.position.x/16)-1;
-        int minY = (int) (camera.position.y/16)-1;
-        int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1;
-        int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1;
-        if (minY<0) minY=0;
-        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)).transparent)
-                        && gameProc.world.getBackMap(x,y)>0) {
+        int minX = (int) (camera.position.x / 16) - 1;
+        int minY = (int) (camera.position.y / 16) - 1;
+        int maxX = (int) ((camera.position.x + camera.viewportWidth) / 16) + 1;
+        int maxY = (int) ((camera.position.y + camera.viewportHeight) / 16) + 1;
+        if (minY < 0) minY = 0;
+        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)).transparent)
+                        && gameProc.world.getBackMap(x, y) > 0) {
                     spriteBatch.draw(
-                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x,y)).getTexture()],
-                            x * 16 - camera.position.x,y * 16 - camera.position.y);
-                    Assets.shade.setPosition(x * 16 - camera.position.x,y * 16 - camera.position.y);
+                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x, y)).getTexture()],
+                            x * 16 - camera.position.x, y * 16 - camera.position.y);
+                    Assets.shade.setPosition(x * 16 - camera.position.x, y * 16 - camera.position.y);
                     Assets.shade.draw(spriteBatch);
                 }
-                if (gameProc.world.getForeMap(x,y)>0 && Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).background) {
+                if (gameProc.world.getForeMap(x, y) > 0 && Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).background) {
                     spriteBatch.draw(
-                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()],
-                            x * 16 - camera.position.x,y * 16 - camera.position.y);
+                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).getTexture()],
+                            x * 16 - camera.position.x, y * 16 - camera.position.y);
                 }
             }
         }
     }
 
-    private void drawWorldForeground(){
-        int minX = (int) (camera.position.x/16)-1;
-        int minY = (int) (camera.position.y/16)-1;
-        int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1;
-        int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1;
-        if (minY<0) minY=0;
-        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)).background) {
+    private void drawWorldForeground() {
+        int minX = (int) (camera.position.x / 16) - 1;
+        int minY = (int) (camera.position.y / 16) - 1;
+        int maxX = (int) ((camera.position.x + camera.viewportWidth) / 16) + 1;
+        int maxY = (int) ((camera.position.y + camera.viewportHeight) / 16) + 1;
+        if (minY < 0) minY = 0;
+        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)).background) {
                     spriteBatch.draw(
-                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()],
-                            x * 16 - camera.position.x,y * 16 - camera.position.y);
+                            Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x, y)).getTexture()],
+                            x * 16 - camera.position.x, y * 16 - camera.position.y);
                 }
             }
         }
@@ -70,27 +68,27 @@ public class GameRenderer extends Renderer {
 
     private void drawMob(Mob mob) {
         mob.draw(spriteBatch,
-                mob.position.x-camera.position.x-gameProc.world.getWidth()*16, mob.position.y-camera.position.y);
+                mob.position.x - camera.position.x - gameProc.world.getWidth() * 16, mob.position.y - camera.position.y);
         mob.draw(spriteBatch,
-                mob.position.x-camera.position.x, mob.position.y-camera.position.y);
+                mob.position.x - camera.position.x, mob.position.y - camera.position.y);
         mob.draw(spriteBatch,
-                mob.position.x-camera.position.x+gameProc.world.getWidth()*16, mob.position.y-camera.position.y);
+                mob.position.x - camera.position.x + gameProc.world.getWidth() * 16, mob.position.y - camera.position.y);
     }
 
     private void drawDrop(Drop drop) {
         switch (Items.ITEMS.get(drop.getId()).getType()) {
             case 0:
-                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x-gameProc.world.getWidth()*16, drop.position.y-camera.position.y);
+                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x - gameProc.world.getWidth() * 16, drop.position.y - camera.position.y);
                 Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch);
-                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x, drop.position.y-camera.position.y);
+                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x, drop.position.y - camera.position.y);
                 Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch);
-                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x-camera.position.x+gameProc.world.getWidth()*16, drop.position.y-camera.position.y);
+                Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].setPosition(drop.position.x - camera.position.x + gameProc.world.getWidth() * 16, drop.position.y - camera.position.y);
                 Assets.blockTextures[Items.ITEMS.get(drop.getId()).getTexture()].draw(spriteBatch);
         }
     }
 
     private void drawPlayer(Player pl) {
-        if (!pl.moveX.equals(Vector2.Zero) || Assets.playerSprite[0][2].getRotation()!=0) {
+        if (!pl.moveX.equals(Vector2.Zero) || Assets.playerSprite[0][2].getRotation() != 0) {
             Assets.playerSprite[0][2].rotate(Player.ANIM_SPEED);
             Assets.playerSprite[1][2].rotate(-Player.ANIM_SPEED);
             Assets.playerSprite[0][3].rotate(-Player.ANIM_SPEED);
@@ -101,7 +99,7 @@ public class GameRenderer extends Renderer {
             Assets.playerSprite[0][3].setRotation(0);
             Assets.playerSprite[1][3].setRotation(0);
         }
-        if (Assets.playerSprite[0][2].getRotation()>=60 || Assets.playerSprite[0][2].getRotation()<=-60)
+        if (Assets.playerSprite[0][2].getRotation() >= 60 || Assets.playerSprite[0][2].getRotation() <= -60)
             Player.ANIM_SPEED = -Player.ANIM_SPEED;
 
         //back hand
@@ -127,23 +125,23 @@ public class GameRenderer extends Renderer {
         spriteBatch.draw(Assets.playerSprite[pl.dir][1],
                 pl.position.x - camera.position.x - 2, pl.position.y - camera.position.y + 8);
         //item in hand
-        if (pl.inventory[gameProc.invSlot]>0)
+        if (pl.inventory[gameProc.invSlot] > 0)
             switch (Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getType()) {
                 case 0:
                     Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition(
-                            pl.position.x - camera.position.x - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()),
-                            pl.position.y - camera.position.y + 6 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()));
+                            pl.position.x - camera.position.x - 8 * MathUtils.sin(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()),
+                            pl.position.y - camera.position.y + 6 + 8 * MathUtils.cos(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()));
                     Assets.blockTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch);
                     break;
                 default:
-                    Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false);
+                    Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir == 0), false);
                     Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setRotation(
-                            -45+pl.dir*90+Assets.playerSprite[0][2].getRotation());
+                            -45 + pl.dir * 90 + Assets.playerSprite[0][2].getRotation());
                     Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].setPosition(
-                            pl.position.x - camera.position.x -10+(12*pl.dir) - 8*MathUtils.sin(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()),
-                            pl.position.y - camera.position.y + 2 + 8*MathUtils.cos(MathUtils.degRad*Assets.playerSprite[0][2].getRotation()));
+                            pl.position.x - camera.position.x - 10 + (12 * pl.dir) - 8 * MathUtils.sin(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()),
+                            pl.position.y - camera.position.y + 2 + 8 * MathUtils.cos(MathUtils.degRad * Assets.playerSprite[0][2].getRotation()));
                     Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].draw(spriteBatch);
-                    Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir==0), false);
+                    Assets.itemTextures[Items.ITEMS.get(pl.inventory[gameProc.invSlot]).getTexture()].flip((pl.dir == 0), false);
                     break;
             }
         //front hand
@@ -154,18 +152,18 @@ public class GameRenderer extends Renderer {
     }
 
     private void drawCreative() {
-        float x = camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2;
-        float y = camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2;
+        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+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll)));
-        for (int i=gameProc.creativeScroll*8; i<gameProc.creativeScroll*8+40; i++) {
-            if (i>0 && i<Items.ITEMS.size())
+        spriteBatch.draw(Assets.creativeScroll, x + 156,
+                y + 18 + (gameProc.creativeScroll * (72 / gameProc.maxCreativeScroll)));
+        for (int i = gameProc.creativeScroll * 8; i < gameProc.creativeScroll * 8 + 40; i++) {
+            if (i > 0 && i < Items.ITEMS.size())
                 switch (Items.ITEMS.get(i).getType()) {
                     case 0:
                         spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(i).getTexture()],
-                            x + 8 + ((i - gameProc.creativeScroll * 8) % 8) * 18,
-                            y + 18 + ((i - gameProc.creativeScroll * 8) / 8) * 18);
+                                x + 8 + ((i - gameProc.creativeScroll * 8) % 8) * 18,
+                                y + 18 + ((i - gameProc.creativeScroll * 8) / 8) * 18);
                         break;
                     case 1:
                         spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(i).getTexture()],
@@ -174,12 +172,12 @@ public class GameRenderer extends Renderer {
                         break;
                 }
         }
-        for (int i=0; i<9; i++) {
-            if (gameProc.player.inventory[i]>0)
+        for (int i = 0; i < 9; i++) {
+            if (gameProc.player.inventory[i] > 0)
                 switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) {
                     case 0:
                         spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()],
-                            x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
+                                x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
                         break;
                     case 1:
                         spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()],
@@ -192,26 +190,26 @@ public class GameRenderer extends Renderer {
     private void drawGUI() {
         if (gameProc.blockDmg > 0) {
             spriteBatch.draw(Assets.wreck[
-                            10*gameProc.blockDmg/
+                            10 * gameProc.blockDmg /
                                     Items.BLOCKS.getValueAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)).getHp()],
-                    gameProc.cursorX*16-camera.position.x,
-                    gameProc.cursorY*16-camera.position.y);
+                    gameProc.cursorX * 16 - camera.position.x,
+                    gameProc.cursorY * 16 - camera.position.y);
         }
-        if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)>0 ||
-                gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY)>0 ||
-                gameProc.ctrlMode==1 ||
+        if (gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY) > 0 ||
+                gameProc.world.getBackMap(gameProc.cursorX, gameProc.cursorY) > 0 ||
+                gameProc.ctrlMode == 1 ||
                 !CaveGame.TOUCH)
             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) {
+                    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) {
                 switch (Items.ITEMS.get(gameProc.player.inventory[i]).getType()) {
                     case 0:
                         spriteBatch.draw(Assets.blockTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()],
-                            camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
-                            3);
+                                camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
+                                3);
                         break;
                     case 1:
                         spriteBatch.draw(Assets.itemTextures[Items.ITEMS.get(gameProc.player.inventory[i]).getTexture()],
@@ -222,20 +220,20 @@ public class GameRenderer extends Renderer {
             }
         }
         spriteBatch.draw(Assets.invBarCur,
-                camera.viewportWidth/2 - Assets.invBar.getRegionWidth()/2 - 1 + 20*gameProc.invSlot,
+                camera.viewportWidth / 2 - Assets.invBar.getRegionWidth() / 2 - 1 + 20 * gameProc.invSlot,
                 -1);
     }
 
     private void drawTouchGui() {
-        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);
-        if (gameProc.ctrlMode==1) {
-            Assets.shade.setPosition(83, camera.viewportHeight-21);
+        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);
+        if (gameProc.ctrlMode == 1) {
+            Assets.shade.setPosition(83, camera.viewportHeight - 21);
             Assets.shade.draw(spriteBatch);
         }
     }
@@ -267,12 +265,12 @@ public class GameRenderer extends Renderer {
         if (CaveGame.TOUCH) drawTouchGui();
 
         if (GameScreen.SHOW_DEBUG) {
-            drawString("FPS: "+GameScreen.FPS,0, 0);
-            drawString("X: "+(int)(gameProc.player.position.x/16),0, 10);
-            drawString("Y: "+(int)(gameProc.player.position.y/16),0, 20);
-            drawString("Mobs: "+gameProc.mobs.size(), 0, 30);
-            drawString("Drops: "+gameProc.drops.size(), 0, 40);
-            drawString("Block: "+Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 50);
+            drawString("FPS: " + GameScreen.FPS, 0, 0);
+            drawString("X: " + (int) (gameProc.player.position.x / 16), 0, 10);
+            drawString("Y: " + (int) (gameProc.player.position.y / 16), 0, 20);
+            drawString("Mobs: " + gameProc.mobs.size(), 0, 30);
+            drawString("Drops: " + gameProc.drops.size(), 0, 40);
+            drawString("Block: " + Items.BLOCKS.getKeyAt(gameProc.world.getForeMap(gameProc.cursorX, gameProc.cursorY)), 0, 50);
         }
 
         spriteBatch.end();
index aab81f54ecb26d101c315e0fbe8c98bd4dab1e8f..a4e314b465273705b1cc404d44918080ef0b7f26 100644 (file)
@@ -15,23 +15,23 @@ public class GameSaver {
         return ByteBuffer.allocate(4).putInt(i).array();
     }
 
-    private static void saveMap(FileHandle file, int[][] map) throws IOException{
-        int rl,bl;
+    private static void saveMap(FileHandle file, int[][] map) throws IOException {
+        int rl, bl;
         int width = map.length;
         int height = map[0].length;
         BufferedOutputStream out = new BufferedOutputStream(file.write(false));
         out.write(intToBytes(VERSION));
         out.write(intToBytes(width));
         out.write(intToBytes(height));
-        for (int y=0; y<map[0].length; y++) {
+        for (int y = 0; y < map[0].length; y++) {
             bl = map[0][y];
-            rl=0;
-            for (int x=0; x<map.length; x++) {
-                if (map[x][y]!=bl) {
+            rl = 0;
+            for (int x = 0; x < map.length; x++) {
+                if (map[x][y] != bl) {
                     out.write(intToBytes(rl));
                     out.write(intToBytes(bl));
-                    rl=0;
-                    bl=map[x][y];
+                    rl = 0;
+                    bl = map[x][y];
                 }
                 rl++;
             }
@@ -45,18 +45,18 @@ public class GameSaver {
     private static int[][] loadMap(FileHandle file) throws Exception {
         int[][] map;
         int ver, width, height;
-        int rl,bl;
+        int rl, bl;
         DataInputStream in = new DataInputStream(file.read());
         ver = in.readInt();
         if (VERSION == ver) {
             width = in.readInt();
             height = in.readInt();
             map = new int[width][height];
-            for (int y=0; y<height; y++) {
-                for (int x=0; x<width; x+=rl) {
+            for (int y = 0; y < height; y++) {
+                for (int x = 0; x < width; x += rl) {
                     rl = in.readInt();
                     bl = in.readInt();
-                    for (int i=x; i<x+rl; i++) map[i][y] = bl;
+                    for (int i = x; i < x + rl; i++) map[i][y] = bl;
                 }
             }
             in.close();
@@ -65,13 +65,13 @@ public class GameSaver {
     }
 
     public static GameProc load() {
-        FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/game.sav");
+        FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/game.sav");
         GameProc gameProc = null;
         try {
             ObjectInputStream in = new ObjectInputStream(file.read());
             int ver = in.readInt();
-            if (VERSION == ver) gameProc = (GameProc)in.readObject();
-                else throw new Exception("version mismatch");
+            if (VERSION == ver) gameProc = (GameProc) in.readObject();
+            else throw new Exception("version mismatch");
             in.close();
             gameProc.world = new GameWorld();
             gameProc.world.setMaps(
@@ -81,32 +81,32 @@ public class GameSaver {
             gameProc.physics = new GamePhysics(gameProc);
             gameProc.resetRenderer();
         } catch (Exception e) {
-            Gdx.app.error("GameSaver",e.getMessage(),e);
+            Gdx.app.error("GameSaver", e.getMessage(), e);
             Gdx.app.exit();
         }
         return gameProc;
     }
 
     public static void save(GameProc gameProc) {
-        FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/");
+        FileHandle file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/");
         file.mkdirs();
-        file = Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/game.sav");
+        file = Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/game.sav");
         try {
             ObjectOutputStream out = new ObjectOutputStream(file.write(false));
             out.writeInt(VERSION);
             out.writeObject(gameProc);
             out.close();
-            saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/foremap.sav"), gameProc.world.getFullForeMap());
-            saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/backmap.sav"), gameProc.world.getFullBackMap());
+            saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav"), gameProc.world.getFullForeMap());
+            saveMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"), gameProc.world.getFullBackMap());
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     public static boolean exists() {
-        return (Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/game.sav").exists() &&
-                Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/foremap.sav").exists() &&
-                Gdx.files.absolute(CaveGame.GAME_FOLDER+"/saves/backmap.sav").exists());
+        return (Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/game.sav").exists() &&
+                Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav").exists() &&
+                Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav").exists());
     }
 
 }
index 88f435b78631f11c1296087bd6b697ca29989d61..62f7274a85a1caead1664626cb3c46b1c42b25a0 100644 (file)
@@ -1,6 +1,5 @@
 package ru.deadsoftware.cavecraft.game;
 
-import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.math.Vector2;
 
 public class GameWorld {
@@ -26,8 +25,8 @@ public class GameWorld {
     }
 
     private int transformX(int x) {
-        x = x%getWidth();
-        if (x<0) x=getWidth()-Math.abs(x);
+        x = x % getWidth();
+        if (x < 0) x = getWidth() - Math.abs(x);
         return x;
     }
 
@@ -95,38 +94,38 @@ public class GameWorld {
     }
 
     public void placeToForeground(int x, int y, int value) {
-        if (getForeMap(x,y) == 0 || value == 0 || !Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) {
+        if (getForeMap(x, y) == 0 || value == 0 || !Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) {
             setForeMap(x, y, value);
         } else if (Items.isSlab(value) && getForeMap(x, y) == value) {
             placeSlab(x, y, value);
         }
-        GameProc.UPD_X = x-8;
-        GameProc.UPD_Y = y-8;
+        GameProc.UPD_X = x - 8;
+        GameProc.UPD_Y = y - 8;
         GameProc.DO_UPD = true;
     }
 
     public void placeToBackground(int x, int y, int value) {
-        if (value==0 || (getBackMap(x,y) == 0 && Items.BLOCKS.getValueAt(value).collision) &&
+        if (value == 0 || (getBackMap(x, y) == 0 && Items.BLOCKS.getValueAt(value).collision) &&
                 (!Items.BLOCKS.getValueAt(value).transparent || value == 18)) {
-            setBackMap(x,y,value);
+            setBackMap(x, y, value);
         }
     }
 
     public Vector2 getSpawnPoint() {
-        int x=0,y=0;
+        int x = 0, y = 0;
         while (true) {
             y++;
-            if (getForeMap(x,y)>0 && Items.BLOCKS.getValueAt(getForeMap(x,y)).collision) break;
+            if (getForeMap(x, y) > 0 && Items.BLOCKS.getValueAt(getForeMap(x, y)).collision) break;
         }
-        x = x*16 + 4;
-        y = y*16 - 32;
-        return new Vector2(x,y);
+        x = x * 16 + 4;
+        y = y * 16 - 32;
+        return new Vector2(x, y);
     }
 
     public void generate(int w, int h) {
         WIDTH = w;
         HEIGHT = h;
-        WorldGen.genWorld(WIDTH,HEIGHT);
+        WorldGen.genWorld(WIDTH, HEIGHT);
         foreMap = WorldGen.getForeMap();
         backMap = WorldGen.getBackMap();
         WorldGen.clear();
index 690d5ac3c99b7e3a50f97dd72f64dc779ca15ca6..2121ae08aa41db2abae2610cbcfc87ffb147eaaf 100644 (file)
@@ -173,131 +173,131 @@ public class Items {
         //5
         BLOCKS.put("planks", new Block(4, 180, 5));
         //6
-        BLOCKS.put("sapling", new Block(5,0,6,false,false,true));
+        BLOCKS.put("sapling", new Block(5, 0, 6, false, false, true));
         //7
-        BLOCKS.put("bedrock", new Block(6,-1,7));
+        BLOCKS.put("bedrock", new Block(6, -1, 7));
         //8
-        BLOCKS.put("water", new Block(7,-1,0,false,false,true));
+        BLOCKS.put("water", new Block(7, -1, 0, false, false, true));
         //9
-        BLOCKS.put("lava", new Block(8,-1,0,false,false,false));
+        BLOCKS.put("lava", new Block(8, -1, 0, false, false, false));
         //10
-        BLOCKS.put("sand", new Block(9, 45,8));
+        BLOCKS.put("sand", new Block(9, 45, 8));
         //11
-        BLOCKS.put("gravel", new Block(10, 54,9));
+        BLOCKS.put("gravel", new Block(10, 54, 9));
         //12
-        BLOCKS.put("gold_ore", new Block(11, 900,10));
+        BLOCKS.put("gold_ore", new Block(11, 900, 10));
         //13
-        BLOCKS.put("iron_ore", new Block(12, 900,11));
+        BLOCKS.put("iron_ore", new Block(12, 900, 11));
         //14
-        BLOCKS.put("coal_ore", new Block(13, 900,0));
+        BLOCKS.put("coal_ore", new Block(13, 900, 0));
         //15
-        BLOCKS.put("log", new Block(14, 180,13));
+        BLOCKS.put("log", new Block(14, 180, 13));
         //16
-        BLOCKS.put("leaves", new Block(15, 21,0));
+        BLOCKS.put("leaves", new Block(15, 21, 0));
         //17
-        BLOCKS.put("sponge", new Block(16, 54,0));
+        BLOCKS.put("sponge", new Block(16, 54, 0));
         //18
-        BLOCKS.put("glass", new Block(17, 27,0,true,false,true));
+        BLOCKS.put("glass", new Block(17, 27, 0, true, false, true));
         //19
-        BLOCKS.put("lapis_ore", new Block(18, 900,0));
+        BLOCKS.put("lapis_ore", new Block(18, 900, 0));
         //20
-        BLOCKS.put("lapis_block", new Block(19, 900,17));
+        BLOCKS.put("lapis_block", new Block(19, 900, 17));
         //21
-        BLOCKS.put("sandstone", new Block(20, 240,18));
+        BLOCKS.put("sandstone", new Block(20, 240, 18));
         //22
-        BLOCKS.put("noteblock", new Block(21, 75,0));
+        BLOCKS.put("noteblock", new Block(21, 75, 0));
         //23
-        BLOCKS.put("bed_l", new Block(22, 21,0,false,true,true));
+        BLOCKS.put("bed_l", new Block(22, 21, 0, false, true, true));
         //24
-        BLOCKS.put("bed_r", new Block(23, 21,0, false,true, true));
+        BLOCKS.put("bed_r", new Block(23, 21, 0, false, true, true));
         //25
-        BLOCKS.put("cobweb", new Block(24, 1200,0,false,false,true));
+        BLOCKS.put("cobweb", new Block(24, 1200, 0, false, false, true));
         //26
-        BLOCKS.put("tallgrass", new Block(25, 0,0,false,false,true));
+        BLOCKS.put("tallgrass", new Block(25, 0, 0, false, false, true));
         //27
-        BLOCKS.put("deadbush", new Block(26, 0,0,false,false,true));
+        BLOCKS.put("deadbush", new Block(26, 0, 0, false, false, true));
         //28
-        BLOCKS.put("brick_block", new Block(27, 600,22));
+        BLOCKS.put("brick_block", new Block(27, 600, 22));
         //29
-        BLOCKS.put("dandelion", new Block(28, 0,23,false,false,true));
+        BLOCKS.put("dandelion", new Block(28, 0, 23, false, false, true));
         //30
-        BLOCKS.put("rose", new Block(29, 0,24,false,false,true));
+        BLOCKS.put("rose", new Block(29, 0, 24, false, false, true));
         //31
-        BLOCKS.put("brown_mushroom", new Block(30, 0,25,false,false,true));
+        BLOCKS.put("brown_mushroom", new Block(30, 0, 25, false, false, true));
         //32
-        BLOCKS.put("red_mushroom", new Block(31, 0,26,false,false,true));
+        BLOCKS.put("red_mushroom", new Block(31, 0, 26, false, false, true));
         //33
-        BLOCKS.put("wool_while", new Block(32, 75,27,true,false,false));
+        BLOCKS.put("wool_while", new Block(32, 75, 27, true, false, false));
         //34
-        BLOCKS.put("wool_orange", new Block(33, 75,28,true,false,false));
+        BLOCKS.put("wool_orange", new Block(33, 75, 28, true, false, false));
         //35
-        BLOCKS.put("wool_magenta", new Block(34, 75,29,true,false,false));
+        BLOCKS.put("wool_magenta", new Block(34, 75, 29, true, false, false));
         //36
-        BLOCKS.put("wool_lightblue", new Block(35, 75,30,true,false,false));
+        BLOCKS.put("wool_lightblue", new Block(35, 75, 30, true, false, false));
         //37
-        BLOCKS.put("wool_yellow", new Block(36, 75,31,true,false,false));
+        BLOCKS.put("wool_yellow", new Block(36, 75, 31, true, false, false));
         //38
-        BLOCKS.put("wool_lime", new Block(37, 75,32,true,false,false));
+        BLOCKS.put("wool_lime", new Block(37, 75, 32, true, false, false));
         //39
-        BLOCKS.put("wool_pink", new Block(38, 75,33,true,false,false));
+        BLOCKS.put("wool_pink", new Block(38, 75, 33, true, false, false));
         //40
-        BLOCKS.put("wool_gray", new Block(39, 75,34,true,false,false));
+        BLOCKS.put("wool_gray", new Block(39, 75, 34, true, false, false));
         //41
-        BLOCKS.put("wool_lightgray", new Block(40, 75,35,true,false,false));
+        BLOCKS.put("wool_lightgray", new Block(40, 75, 35, true, false, false));
         //42
-        BLOCKS.put("wool_cyan", new Block(41, 75,36,true,false,false));
+        BLOCKS.put("wool_cyan", new Block(41, 75, 36, true, false, false));
         //43
-        BLOCKS.put("wool_purple", new Block(42, 75,37,true,false,false));
+        BLOCKS.put("wool_purple", new Block(42, 75, 37, true, false, false));
         //44
-        BLOCKS.put("wool_blue", new Block(43, 75,38,true,false,false));
+        BLOCKS.put("wool_blue", new Block(43, 75, 38, true, false, false));
         //45
-        BLOCKS.put("wool_brown", new Block(44, 75,39,true,false,false));
+        BLOCKS.put("wool_brown", new Block(44, 75, 39, true, false, false));
         //46
-        BLOCKS.put("wool_green", new Block(45, 75,40,true,false,false));
+        BLOCKS.put("wool_green", new Block(45, 75, 40, true, false, false));
         //47
-        BLOCKS.put("wool_red", new Block(46, 75,41,true,false,false));
+        BLOCKS.put("wool_red", new Block(46, 75, 41, true, false, false));
         //48
-        BLOCKS.put("wool_black", new Block(47, 75,42,true,false,false));
+        BLOCKS.put("wool_black", new Block(47, 75, 42, true, false, false));
         //49
-        BLOCKS.put("gold_block", new Block(48, 900,43));
+        BLOCKS.put("gold_block", new Block(48, 900, 43));
         //50
-        BLOCKS.put("iron_block", new Block(49, 1500,44));
+        BLOCKS.put("iron_block", new Block(49, 1500, 44));
         //51
-        BLOCKS.put("stone_slab", new Block(0, 8, 16,8, 50, 600,45, true, false, true));
+        BLOCKS.put("stone_slab", new Block(0, 8, 16, 8, 50, 600, 45, true, false, true));
         //52
-        BLOCKS.put("double_stone_slab", new Block(51, 600,45));
+        BLOCKS.put("double_stone_slab", new Block(51, 600, 45));
         //53
-        BLOCKS.put("sandstone_slab", new Block(0, 8, 16,8, 52, 600,46, true, false, true));
+        BLOCKS.put("sandstone_slab", new Block(0, 8, 16, 8, 52, 600, 46, true, false, true));
         //54
-        BLOCKS.put("wooden_slab", new Block(0, 8, 16,8, 53, 180,47, true, false, true));
+        BLOCKS.put("wooden_slab", new Block(0, 8, 16, 8, 53, 180, 47, true, false, true));
         //55
-        BLOCKS.put("cobblestone_slab", new Block(0, 8, 16,8, 54, 600,48, true, false, true));
+        BLOCKS.put("cobblestone_slab", new Block(0, 8, 16, 8, 54, 600, 48, true, false, true));
         //56
-        BLOCKS.put("brick_slab", new Block(0, 8, 16,8, 55, 600,49, true, false, true));
+        BLOCKS.put("brick_slab", new Block(0, 8, 16, 8, 55, 600, 49, true, false, true));
         //57
-        BLOCKS.put("stonebrick", new Block(64, 450,50));
+        BLOCKS.put("stonebrick", new Block(64, 450, 50));
         //58
-        BLOCKS.put("stone_brick_slab", new Block(0, 8, 16,8, 56, 450,51, true, false, true));
+        BLOCKS.put("stone_brick_slab", new Block(0, 8, 16, 8, 56, 450, 51, true, false, true));
         //59
-        BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, 39,52, true, false, true));
+        BLOCKS.put("cactus", new Block(1, 0, 14, 16, 57, 39, 52, true, false, true));
         //60
-        BLOCKS.put("water_16", new Block(7, -1,0,false,false,true));
+        BLOCKS.put("water_16", new Block(7, -1, 0, false, false, true));
         //61
-        BLOCKS.put("water_12", new Block(58, -1,0,false,false,true));
+        BLOCKS.put("water_12", new Block(58, -1, 0, false, false, true));
         //62
-        BLOCKS.put("water_8", new Block(59, -1,0,false,false,true));
+        BLOCKS.put("water_8", new Block(59, -1, 0, false, false, true));
         //63
-        BLOCKS.put("water_4", new Block(60, -1,0,false,false,true));
+        BLOCKS.put("water_4", new Block(60, -1, 0, false, false, true));
         //64
-        BLOCKS.put("lava_16", new Block(8, -1,0,false,false,true));
+        BLOCKS.put("lava_16", new Block(8, -1, 0, false, false, true));
         //65
-        BLOCKS.put("lava_12", new Block(61, -1,0,false,false,true));
+        BLOCKS.put("lava_12", new Block(61, -1, 0, false, false, true));
         //66
-        BLOCKS.put("lava_8", new Block(62, -1,0,false,false,true));
+        BLOCKS.put("lava_8", new Block(62, -1, 0, false, false, true));
         //67
-        BLOCKS.put("lava_4", new Block(63, -1,0,false,false,true));
+        BLOCKS.put("lava_4", new Block(63, -1, 0, false, false, true));
         //68
-        BLOCKS.put("obsidian", new Block(65, 1500,53));
+        BLOCKS.put("obsidian", new Block(65, 1500, 53));
     }
 
     public static void load() {
index bf9eadf8cb3f81847f6cca80f0e5a4ac1287e18b..974cef4d39fd073bbabd9be170f2e3e89a76e50b 100644 (file)
@@ -1,6 +1,5 @@
 package ru.deadsoftware.cavecraft.game;
 
-import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.math.RandomXS128;
 import com.badlogic.gdx.utils.TimeUtils;
 
@@ -22,51 +21,52 @@ public class WorldGen {
         bMap = new int[width];
         int t;
         res[0] = mid;
-        for (int i=1; i<width; i++) {
-            t = rand.nextInt(7)-3;
-            if (t>-3 && t<3) t=0; else t/=Math.abs(t);
-            if (i>width-(max-min)) {
-                if (res[i-1]+t<res[0]) t=Math.abs(t);
-                    else if (res[i-1]+t>res[0]) t=-Math.abs(t);
+        for (int i = 1; i < width; i++) {
+            t = rand.nextInt(7) - 3;
+            if (t > -3 && t < 3) t = 0;
+            else t /= Math.abs(t);
+            if (i > width - (max - min)) {
+                if (res[i - 1] + t < res[0]) t = Math.abs(t);
+                else if (res[i - 1] + t > res[0]) t = -Math.abs(t);
             }
-            res[i] = res[i-1] + t;
-            if (res[i]<min) res[i] = min;
-            if (res[i]>max) res[i] = max;
-            if (i>=width/2) {
-                bMap [i] = 1;
+            res[i] = res[i - 1] + t;
+            if (res[i] < min) res[i] = min;
+            if (res[i] > max) res[i] = max;
+            if (i >= width / 2) {
+                bMap[i] = 1;
                 if (res[i] < 60) res[i] = 60;
             } else {
                 bMap[i] = 0;
             }
         }
-        if (res[0]<res[width-1]) res[width-1] = res[0];
+        if (res[0] < res[width - 1]) res[width - 1] = res[0];
         return res;
     }
 
     private static void genCactus(int x, int y) {
         foreMap[x][y] = 59;
-        foreMap[x][y-1] = 59;
-        foreMap[x][y-2] = 59;
+        foreMap[x][y - 1] = 59;
+        foreMap[x][y - 2] = 59;
     }
 
     private static void genOak(int x, int y) {
         backMap[x][y] = 15;
-        backMap[x][y-1] = 15;
-        backMap[x][y-2] = 15;
-        backMap[x][y-3] = 15;
-        backMap[x][y-4] = 16;
-        backMap[x][y-5] = 16;
-        backMap[x-1][y-3] = 16;
-        backMap[x-1][y-4] = 16;
-        backMap[x+1][y-3] = 16;
-        backMap[x+1][y-4] = 16;
-        foreMap[x][y-3] = 16;
-        foreMap[x][y-4] = 16;
-        foreMap[x][y-5] = 16;
-        foreMap[x-1][y-3] = 16;
-        foreMap[x-1][y-4] = 16;
-        foreMap[x+1][y-3] = 16;
-        foreMap[x+1][y-4] = 16;
+        backMap[x][y - 1] = 15;
+        backMap[x][y - 2] = 15;
+        backMap[x][y - 3] = 15;
+        backMap[x][y - 4] = 16;
+        backMap[x][y - 5] = 16;
+        backMap[x - 1][y - 3] = 16;
+        backMap[x - 1][y - 4] = 16;
+        backMap[x + 1][y - 3] = 16;
+        backMap[x + 1][y - 4] = 16;
+        foreMap[x][y - 3] = 16;
+        foreMap[x][y - 4] = 16;
+        foreMap[x][y - 5] = 16;
+        foreMap[x - 1][y - 3] = 16;
+        foreMap[x - 1][y - 4] = 16;
+        foreMap[x + 1][y - 3] = 16;
+        foreMap[x + 1][y - 4] = 16;
     }
 
     static void genWorld(int width, int height) {
@@ -79,11 +79,11 @@ public class WorldGen {
         rand = new RandomXS128(seed);
         foreMap = new int[width][height];
         backMap = new int[width][height];
-        hMap = genLandscape(width, height/4, height/8, height/2);
-        for (int x=0; x<width; x++) {
-            dirtH = 4+rand.nextInt(2);
-            for (int y = height- hMap[x]; y<height; y++) {
-                if (y==height- hMap[x]) {
+        hMap = genLandscape(width, height / 4, height / 8, height / 2);
+        for (int x = 0; x < width; x++) {
+            dirtH = 4 + rand.nextInt(2);
+            for (int y = height - hMap[x]; y < height; y++) {
+                if (y == height - hMap[x]) {
                     switch (bMap[x]) {
                         case 0:
                             foreMap[x][y] = 2;
@@ -94,7 +94,7 @@ public class WorldGen {
                             backMap[x][y] = 10;
                             break;
                     }
-                } else if (y<height-hMap[x]+dirtH) {
+                } else if (y < height - hMap[x] + dirtH) {
                     switch (bMap[x]) {
                         case 0:
                             foreMap[x][y] = 3;
@@ -105,10 +105,10 @@ public class WorldGen {
                             backMap[x][y] = 10;
                             break;
                     }
-                } else if (bMap[x]==1 && y<height-hMap[x]+dirtH+3) {
+                } else if (bMap[x] == 1 && y < height - hMap[x] + dirtH + 3) {
                     foreMap[x][y] = 21;
                     backMap[x][y] = 21;
-                } else if (y<height-1){
+                } else if (y < height - 1) {
                     foreMap[x][y] = 1;
                     backMap[x][y] = 1;
                 } else {
@@ -116,52 +116,52 @@ public class WorldGen {
                     backMap[x][y] = 7;
                 }
             }
-            for (int y = height-60; y<height-1; y++) {
-                if (foreMap[x][y]==0 && bMap[x]!=1){
+            for (int y = height - 60; y < height - 1; y++) {
+                if (foreMap[x][y] == 0 && bMap[x] != 1) {
                     foreMap[x][y] = 8;
                     if (bMap[x] == 0) {
-                        if (y==height-60) {
+                        if (y == height - 60) {
                             backMap[x][y] = 2;
                         } else {
                             backMap[x][y] = 3;
                         }
                     }
-                    if (y==height-hMap[x]-1) {
-                        foreMap[x][y+1] = 3;
-                        backMap[x][y+1] = 3;
+                    if (y == height - hMap[x] - 1) {
+                        foreMap[x][y + 1] = 3;
+                        backMap[x][y + 1] = 3;
                     }
                 }
             }
-            if (x>2 && x<width-2){
-                if (foreMap[x][height-hMap[x]-1]==0 && foreMap[x][height-hMap[x]]==2) {
+            if (x > 2 && x < width - 2) {
+                if (foreMap[x][height - hMap[x] - 1] == 0 && foreMap[x][height - hMap[x]] == 2) {
                     switch (rand.nextInt(50)) {
                         case 0:
                             genOak(x, height - hMap[x] - 1);
                             break;
                         case 1:
-                            foreMap[x][height-hMap[x]-1] = 26;
+                            foreMap[x][height - hMap[x] - 1] = 26;
                             break;
                         case 2:
-                            foreMap[x][height-hMap[x]-1] = 29;
+                            foreMap[x][height - hMap[x] - 1] = 29;
                             break;
                         case 3:
-                            foreMap[x][height-hMap[x]-1] = 30;
+                            foreMap[x][height - hMap[x] - 1] = 30;
                             break;
                         case 4:
-                            foreMap[x][height-hMap[x]-1] = 31;
+                            foreMap[x][height - hMap[x] - 1] = 31;
                             break;
                         case 5:
-                            foreMap[x][height-hMap[x]-1] = 32;
+                            foreMap[x][height - hMap[x] - 1] = 32;
                             break;
                     }
                 }
-                if (foreMap[x][height-hMap[x]-1]==0 && foreMap[x][height-hMap[x]]==10) {
-                    switch(rand.nextInt(20)) {
+                if (foreMap[x][height - hMap[x] - 1] == 0 && foreMap[x][height - hMap[x]] == 10) {
+                    switch (rand.nextInt(20)) {
                         case 0:
-                            genCactus(x,height-hMap[x]-1);
+                            genCactus(x, height - hMap[x] - 1);
                             break;
                         case 1:
-                            foreMap[x][height-hMap[x]-1] = 27;
+                            foreMap[x][height - hMap[x] - 1] = 27;
                             break;
                     }
                 }
index 0cfa261380fd6b41f0413e1691f615bea2b4ced0..11d02d2d72b29fa5f0b35f2134713959906c9872 100644 (file)
@@ -6,7 +6,7 @@ import com.badlogic.gdx.math.Vector2;
 import ru.deadsoftware.cavecraft.game.Items;
 import ru.deadsoftware.cavecraft.misc.Assets;
 
-public class FallingGravel extends Mob{
+public class FallingGravel extends Mob {
 
     public FallingGravel(int x, int y) {
         dir = 0;
@@ -29,7 +29,7 @@ public class FallingGravel extends Mob{
 
     @Override
     public void draw(SpriteBatch spriteBatch, float x, float y) {
-        spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("gravel").getTexture()],x, y);
+        spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("gravel").getTexture()], x, y);
     }
 
     @Override
index 1d6a78ee88fa0012f800d2178b5b08653b753074..37f8a59c366527c6946f5d2c3e9a96e26a1be29c 100644 (file)
@@ -3,7 +3,6 @@ package ru.deadsoftware.cavecraft.game.mobs;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.GameProc;
 import ru.deadsoftware.cavecraft.game.Items;
 import ru.deadsoftware.cavecraft.misc.Assets;
 
@@ -30,7 +29,7 @@ public class FallingSand extends Mob {
 
     @Override
     public void draw(SpriteBatch spriteBatch, float x, float y) {
-        spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("sand").getTexture()],x, y);
+        spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("sand").getTexture()], x, y);
     }
 
     @Override
index 180c4d10b1905b91028c8133a8042a1027f62b26..fbab3970d5c52f3adb3c39e35b0fe45f911a93be 100644 (file)
@@ -3,12 +3,10 @@ package ru.deadsoftware.cavecraft.game.mobs;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.GameProc;
-import ru.deadsoftware.cavecraft.misc.Assets;
 
 import java.io.Serializable;
 
-public abstract class Mob implements Serializable{
+public abstract class Mob implements Serializable {
 
     public int ANIM_SPEED = 6;
     public Vector2 position;
@@ -18,8 +16,12 @@ public abstract class Mob implements Serializable{
     public boolean dead;
 
     public abstract void ai();
+
     public abstract void changeDir();
+
     public abstract void draw(SpriteBatch spriteBatch, float x, float y);
+
     public abstract Rectangle getRect();
+
     public abstract int getType(); //0 - mob, 10 - sand, 11 - gravel
 }
index 04a96f6b7d41ad9ced14bc919e584de9ee69f815..0fa08bd2a6c928ba3b049ea73e1e5bad73dd3f07 100644 (file)
@@ -4,16 +4,14 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.MathUtils;
 import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.GameWorld;
 import ru.deadsoftware.cavecraft.misc.Assets;
-import ru.deadsoftware.cavecraft.game.GameProc;
 
-public class Pig extends Mob{
+public class Pig extends Mob {
 
     public Pig(int x, int y) {
         dir = MathUtils.random(1);
         position = new Vector2(x, y);
-        moveX = new Vector2(-1+dir*2, 0);
+        moveX = new Vector2(-1 + dir * 2, 0);
         moveY = new Vector2(0, 0);
         width = 25;
         height = 18;
@@ -23,8 +21,8 @@ public class Pig extends Mob{
 
     @Override
     public void changeDir() {
-        dir=-dir+1;
-        moveX.set(-1+2*dir,0);
+        dir = -dir + 1;
+        moveX.set(-1 + 2 * dir, 0);
     }
 
     @Override
@@ -32,10 +30,11 @@ public class Pig extends Mob{
         if (MathUtils.randomBoolean(.0025f)) changeDir();
         else if (MathUtils.randomBoolean(.0025f)) {
             if (moveX.x != 0f) moveX.setZero();
-            else moveX.set(-1+2*dir, 0);
+            else moveX.set(-1 + 2 * dir, 0);
         }
-        if (moveX.x != 0f) animation+=ANIM_SPEED; else animation=0;
-        if (animation>=60 || animation<=-60) {
+        if (moveX.x != 0f) animation += ANIM_SPEED;
+        else animation = 0;
+        if (animation >= 60 || animation <= -60) {
             ANIM_SPEED = -ANIM_SPEED;
         }
     }
@@ -45,14 +44,14 @@ public class Pig extends Mob{
         Assets.pigSprite[0][1].setRotation(animation);
         Assets.pigSprite[1][1].setRotation(-animation);
         //back legs
-        Assets.pigSprite[1][1].setPosition(x-4+(9-dir*9),y+6);
+        Assets.pigSprite[1][1].setPosition(x - 4 + (9 - dir * 9), y + 6);
         Assets.pigSprite[1][1].draw(spriteBatch);
-        Assets.pigSprite[1][1].setPosition(x+17-(9*dir),y+6);
+        Assets.pigSprite[1][1].setPosition(x + 17 - (9 * dir), y + 6);
         Assets.pigSprite[1][1].draw(spriteBatch);
         //front legs
-        Assets.pigSprite[0][1].setPosition(x-4+(9-dir*9),y+6);
+        Assets.pigSprite[0][1].setPosition(x - 4 + (9 - dir * 9), y + 6);
         Assets.pigSprite[0][1].draw(spriteBatch);
-        Assets.pigSprite[0][1].setPosition(x+17-(9*dir),y+6);
+        Assets.pigSprite[0][1].setPosition(x + 17 - (9 * dir), y + 6);
         Assets.pigSprite[0][1].draw(spriteBatch);
         //head & body
         spriteBatch.draw(Assets.pigSprite[dir][0], x, y);
index 5d2814e7f0e1c26603c763390989819237c26685..dfd8351dffbd6dc694ee9be42f8263e2c1311d64 100644 (file)
@@ -4,18 +4,18 @@ import com.badlogic.gdx.math.Rectangle;
 
 public class Block {
 
-    private int x,y,w,h;
+    private int x, y, w, h;
     private int texture;
     private int hp, drop;
 
     public boolean collision, background, transparent;
 
     public Block(int texture, int hp, int drop) {
-        this(0,0,16,16,texture, hp, drop, true, false, false);
+        this(0, 0, 16, 16, texture, hp, drop, true, false, false);
     }
 
     public Block(int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) {
-        this(0,0,16,16,texture, hp, drop, collision, background, transparent);
+        this(0, 0, 16, 16, texture, hp, drop, collision, background, transparent);
     }
 
     public Block(int x, int y, int w, int h, int texture, int hp, int drop, boolean collision, boolean background, boolean transparent) {
@@ -44,13 +44,13 @@ public class Block {
     }
 
     public Rectangle getRect(int x, int y) {
-        x*=16;
-        y*=16;
-        return new Rectangle(x+this.x, y+this.y, w, h);
+        x *= 16;
+        y *= 16;
+        return new Rectangle(x + this.x, y + this.y, w, h);
     }
 
     public boolean toJump() {
-        return (y<8 && collision);
+        return (y < 8 && collision);
     }
 
 }
index bc2ed8f48814f8526f45833b14061811d76ad389..8c1388116b351913dd36323a9914d50e16f4b4ac 100644 (file)
@@ -21,12 +21,15 @@ public class Item {
     public int getTexture() {
         return texture;
     }
+
     public int getType() {
         return type;
     }
+
     public int getBlock() {
         return block;
     }
+
     public String getName() {
         return name;
     }
index 2d5ffe8859340f30e92eaae6fb6a7191bdb83272..546fb6ef7aaa307b2a98b4ad686cfbcb894f1832 100644 (file)
@@ -27,7 +27,7 @@ public class Player implements Serializable {
     }
 
     public Rectangle getRect() {
-        return new Rectangle(position.x+2, position.y, width, height);
+        return new Rectangle(position.x + 2, position.y, width, height);
     }
 
 }
index da04d469107decbc21aa517a6a0259b75b05fe60..d7da1c5bc0e1eadf7ea6b432465e56409c6f56e4 100644 (file)
@@ -2,7 +2,8 @@ package ru.deadsoftware.cavecraft.menu;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.utils.Array;
-import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.CaveGame;
+import ru.deadsoftware.cavecraft.GameScreen;
 import ru.deadsoftware.cavecraft.game.GameSaver;
 import ru.deadsoftware.cavecraft.game.Items;
 import ru.deadsoftware.cavecraft.menu.objects.Button;
@@ -15,11 +16,11 @@ public class MenuRenderer extends Renderer {
     public Array<Button> menuMainButtons;
 
     public MenuRenderer(int width) {
-        super(width,width*((float) GameScreen.getHeight()/GameScreen.getWidth()));
+        super(width, width * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
         menuMainButtons = new Array<Button>();
-        menuMainButtons.add(new Button("New game", getWidth()/2-100, getHeight()/4));
-        menuMainButtons.add(new Button("Load game", getWidth()/2-100, getHeight()/4+30,GameSaver.exists()?1:0));
-        menuMainButtons.add(new Button("Quit", getWidth()/2-100, getHeight()/4+60));
+        menuMainButtons.add(new Button("New game", getWidth() / 2 - 100, getHeight() / 4));
+        menuMainButtons.add(new Button("Load game", getWidth() / 2 - 100, getHeight() / 4 + 30, GameSaver.exists() ? 1 : 0));
+        menuMainButtons.add(new Button("Quit", getWidth() / 2 - 100, getHeight() / 4 + 60));
     }
 
     public void buttonClicked(Button button) {
@@ -34,17 +35,17 @@ public class MenuRenderer extends Renderer {
 
     private void drawButton(Button button) {
         spriteBatch.draw(Assets.menuButton[button.getType()], button.getX(), button.getY());
-        setFontColor(255,255,255);
+        setFontColor(255, 255, 255);
         drawString(button.getLabel(),
-                (button.getX()+button.getWidth()/2)-Assets.getStringWidth(button.getLabel())/2,
-                (button.getY()+button.getHeight()/2)-Assets.getStringHeight(button.getLabel())/2);
+                (button.getX() + button.getWidth() / 2) - Assets.getStringWidth(button.getLabel()) / 2,
+                (button.getY() + button.getHeight() / 2) - Assets.getStringHeight(button.getLabel()) / 2);
     }
 
     private void drawMenuMain() {
         for (Button button : menuMainButtons) {
-            if (button.getType()>0) {
-                if (button.getRect().contains(Gdx.input.getX()*getWidth()/GameScreen.getWidth(),
-                        Gdx.input.getY()*getHeight()/GameScreen.getHeight()))
+            if (button.getType() > 0) {
+                if (button.getRect().contains(Gdx.input.getX() * getWidth() / GameScreen.getWidth(),
+                        Gdx.input.getY() * getHeight() / GameScreen.getHeight()))
                     button.setType(2);
                 else button.setType(1);
             }
@@ -59,27 +60,40 @@ public class MenuRenderer extends Renderer {
     @Override
     public void render() {
         spriteBatch.begin();
-        for (int x=0; x<=getWidth()/16; x++)
-            for (int y=0; y<=getHeight()/16; y++) {
+        for (int x = 0; x <= getWidth() / 16; x++)
+            for (int y = 0; y <= getHeight() / 16; y++) {
                 spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.get("dirt").getTexture()], x * 16, y * 16);
-                spriteBatch.draw(Assets.shade,x*16,y*16);
+                spriteBatch.draw(Assets.shade, x * 16, y * 16);
             }
-        spriteBatch.draw(Assets.gameLogo, getWidth()/2-Assets.gameLogo.getWidth()/2, 0);
+        spriteBatch.draw(Assets.gameLogo, getWidth() / 2 - Assets.gameLogo.getWidth() / 2, 0);
 
         switch (CaveGame.STATE) {
-            case MENU_MAIN: drawMenuMain(); break;
-            case GOTO_NEW_GAME: case GOTO_LOAD_GAME: drawLabel("Generating World..."); break;
-            case GOTO_MENU: drawLabel("Saving Game..."); break;
+            case MENU_MAIN:
+                drawMenuMain();
+                break;
+            case GOTO_NEW_GAME:
+            case GOTO_LOAD_GAME:
+                drawLabel("Generating World...");
+                break;
+            case GOTO_MENU:
+                drawLabel("Saving Game...");
+                break;
         }
 
-        drawString("CaveCraft "+CaveGame.VERSION,0,
-                getHeight()-Assets.getStringHeight("CaveCraft "+CaveGame.VERSION)*1.5f);
+        drawString("CaveCraft " + CaveGame.VERSION, 0,
+                getHeight() - Assets.getStringHeight("CaveCraft " + CaveGame.VERSION) * 1.5f);
         spriteBatch.end();
 
         switch (CaveGame.STATE) {
-            case GOTO_NEW_GAME: CaveGame.STATE = AppState.NEW_GAME; break;
-            case GOTO_LOAD_GAME: CaveGame.STATE = AppState.LOAD_GAME; break;
-            case GOTO_MENU: CaveGame.STATE = AppState.SAVE_GAME; break;
+            case GOTO_NEW_GAME:
+                CaveGame.STATE = AppState.NEW_GAME;
+                break;
+            case GOTO_LOAD_GAME:
+                CaveGame.STATE = AppState.LOAD_GAME;
+                break;
+            case GOTO_MENU:
+                CaveGame.STATE = AppState.SAVE_GAME;
+                break;
         }
 
     }
index e28c322d3732bb9228b6f1c2ae6c3f48a32be667..9d74b0ead879b09390d9b1c134389a34ef21f4a3 100644 (file)
@@ -58,42 +58,42 @@ public class Assets {
         playerTexture = new Texture(Gdx.files.internal("mobs/char.png"));
         //LOOK TO LEFT
         //head
-        playerSprite[0][0] = new Sprite(new TextureRegion(playerTexture, 0,0,12,12));
-        playerSprite[0][0].flip(false,true);
+        playerSprite[0][0] = new Sprite(new TextureRegion(playerTexture, 0, 0, 12, 12));
+        playerSprite[0][0].flip(false, true);
         //body
-        playerSprite[0][1] = new Sprite(new TextureRegion(playerTexture, 0,13,12,12));
-        playerSprite[0][1].flip(false,true);
+        playerSprite[0][1] = new Sprite(new TextureRegion(playerTexture, 0, 13, 12, 12));
+        playerSprite[0][1].flip(false, true);
         //hand
-        playerSprite[0][2] = new Sprite(new TextureRegion(playerTexture, 25,5,20,20));
-        playerSprite[0][2].flip(false,true);
+        playerSprite[0][2] = new Sprite(new TextureRegion(playerTexture, 25, 5, 20, 20));
+        playerSprite[0][2].flip(false, true);
         //leg
-        playerSprite[0][3] = new Sprite(new TextureRegion(playerTexture, 25,27,20,20));
-        playerSprite[0][3].flip(false,true);
+        playerSprite[0][3] = new Sprite(new TextureRegion(playerTexture, 25, 27, 20, 20));
+        playerSprite[0][3].flip(false, true);
         //LOOK TO RIGHT
         //head
-        playerSprite[1][0] = new Sprite(new TextureRegion(playerTexture, 13,0,12,12));
-        playerSprite[1][0].flip(false,true);
+        playerSprite[1][0] = new Sprite(new TextureRegion(playerTexture, 13, 0, 12, 12));
+        playerSprite[1][0].flip(false, true);
         //body
-        playerSprite[1][1] = new Sprite(new TextureRegion(playerTexture, 13,13,12,12));
-        playerSprite[1][1].flip(false,true);
+        playerSprite[1][1] = new Sprite(new TextureRegion(playerTexture, 13, 13, 12, 12));
+        playerSprite[1][1].flip(false, true);
         //hand
-        playerSprite[1][2] = new Sprite(new TextureRegion(playerTexture, 37,5,20,20));
-        playerSprite[1][2].flip(false,true);
+        playerSprite[1][2] = new Sprite(new TextureRegion(playerTexture, 37, 5, 20, 20));
+        playerSprite[1][2].flip(false, true);
         //leg
-        playerSprite[1][3] = new Sprite(new TextureRegion(playerTexture, 37,27,20,20));
-        playerSprite[1][3].flip(false,true);
+        playerSprite[1][3] = new Sprite(new TextureRegion(playerTexture, 37, 27, 20, 20));
+        playerSprite[1][3].flip(false, true);
     }
 
     private static void loadPig() {
         pigTexture = new Texture(Gdx.files.internal("mobs/pig.png"));
         pigSprite[0][0] = new Sprite(new TextureRegion(pigTexture, 0, 0, 25, 12));
-        pigSprite[0][0].flip(false,true);
+        pigSprite[0][0].flip(false, true);
         pigSprite[1][0] = new Sprite(new TextureRegion(pigTexture, 0, 12, 25, 12));
-        pigSprite[1][0].flip(false,true);
+        pigSprite[1][0].flip(false, true);
         pigSprite[0][1] = new Sprite(new TextureRegion(pigTexture, 4, 26, 12, 12));
-        pigSprite[0][1].flip(false,true);
+        pigSprite[0][1].flip(false, true);
         pigSprite[1][1] = new Sprite(new TextureRegion(pigTexture, 16, 26, 12, 12));
-        pigSprite[1][1].flip(false,true);
+        pigSprite[1][1].flip(false, true);
     }
 
     public static void load() {
@@ -106,8 +106,8 @@ public class Assets {
         gameLogo.flip(false, true);
 
         menuButtonTexture = new Texture(Gdx.files.internal("buttons.png"));
-        for (int i=0; i<3; i++) {
-            menuButton[i] = new TextureRegion(menuButtonTexture, 0, 20*i, 200, 20);
+        for (int i = 0; i < 3; i++) {
+            menuButton[i] = new TextureRegion(menuButtonTexture, 0, 20 * i, 200, 20);
             menuButton[i].flip(false, true);
         }
 
@@ -117,19 +117,19 @@ public class Assets {
         shade = new Sprite(new Texture(Gdx.files.internal("shade.png")));
 
         gui = new Texture(Gdx.files.internal("gui.png"));
-        guiCur = new TextureRegion(gui,0,0,16,16);
-        invBar = new TextureRegion(gui,0,16,182,22);
-        invBarCur = new TextureRegion(gui,0,38,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, 136);
-        creativeInv.flip(false,true);
+        creativeInv.flip(false, true);
         creativeScroll = new TextureRegion(creativeTexture, 3, 137, 12, 15);
         creativeScroll.flip(false, true);
 
         wreckTexture = new Texture(Gdx.files.internal("break.png"));
-        for (int i=0; i<10; i++) {
-            wreck[i] = new TextureRegion(wreckTexture, 16*i, 0, 16, 16);
+        for (int i = 0; i < 10; i++) {
+            wreck[i] = new TextureRegion(wreckTexture, 16 * i, 0, 16, 16);
         }
 
         if (CaveGame.TOUCH) {
@@ -149,32 +149,32 @@ public class Assets {
         }
 
         terrain = new Texture(Gdx.files.internal("terrain.png"));
-        for (int i=0; i<BLOCK_TEXTURES; i++) {
+        for (int i = 0; i < BLOCK_TEXTURES; i++) {
             blockTextures[i] = new Sprite(terrain,
-                    (i%16)*16, (i/16)*16, 16,16);
-            blockTextures[i].flip(false,true);
-            blockTextures[i].setSize(8,8);
+                    (i % 16) * 16, (i / 16) * 16, 16, 16);
+            blockTextures[i].flip(false, true);
+            blockTextures[i].setSize(8, 8);
         }
         terrain = null;
 
         items = new Texture(Gdx.files.internal("items.png"));
-        for (int i=0; i<ITEM_TEXTURES; i++) {
+        for (int i = 0; i < ITEM_TEXTURES; i++) {
             itemTextures[i] = new Sprite(items,
-                    (i%16)*16, (i/16)*16, 16, 16);
+                    (i % 16) * 16, (i / 16) * 16, 16, 16);
             itemTextures[i].flip(false, true);
             //itemTextures[i].setSize(8,8);
         }
         items = null;
     }
 
-    public static int getStringWidth(String s){
-        layout.setText(minecraftFont,s);
-        return (int)layout.width;
+    public static int getStringWidth(String s) {
+        layout.setText(minecraftFont, s);
+        return (int) layout.width;
     }
 
-    public static int getStringHeight(String s){
-        layout.setText(minecraftFont,s);
-        return (int)layout.height;
+    public static int getStringHeight(String s) {
+        layout.setText(minecraftFont, s);
+        return (int) layout.height;
     }
 
 }
index c9de4fab9d1ac38131f30bad3a966f6839c5b5d0..9978e0c99a9edebe2b7620bf07d6bf43c5210036 100644 (file)
@@ -42,20 +42,20 @@ public class InputHandlerGame implements InputProcessor {
 
     @Override
     public boolean touchDown(int screenX, int screenY, int pointer, int button) {
-        int tx = (int)(screenX * tWidth/getWidth());
-        int ty = (int)(screenY * tHeight/getHeight());
-        screenX *= gameProc.renderer.camera.viewportWidth/getWidth();
-        screenY *= gameProc.renderer.camera.viewportHeight/getHeight();
+        int tx = (int) (screenX * tWidth / getWidth());
+        int ty = (int) (screenY * tHeight / getHeight());
+        screenX *= gameProc.renderer.camera.viewportWidth / getWidth();
+        screenY *= gameProc.renderer.camera.viewportHeight / getHeight();
 
         if (CaveGame.TOUCH) {
             if (tx > 26 && tx < 52 && ty > tHeight - 52 && ty < tHeight - 26) {
-                if (gameProc.ctrlMode==1) gameInput.keyDown(Input.Keys.W);
-                    else gameInput.keyDown(Input.Keys.SPACE);
+                if (gameProc.ctrlMode == 1) gameInput.keyDown(Input.Keys.W);
+                else gameInput.keyDown(Input.Keys.SPACE);
             } else if (tx > 0 && tx < 26 && ty > tHeight - 26) {
                 gameInput.keyDown(Input.Keys.A);
             } else if (tx > 26 && tx < 52 && ty > tHeight - 26) {
-                if (gameProc.ctrlMode==1) gameInput.keyDown(Input.Keys.S);
-                    else gameInput.keyDown(Input.Keys.CONTROL_LEFT);
+                if (gameProc.ctrlMode == 1) gameInput.keyDown(Input.Keys.S);
+                else gameInput.keyDown(Input.Keys.CONTROL_LEFT);
             } else if (tx > 52 && tx < 78 && ty > tHeight - 26) {
                 gameInput.keyDown(Input.Keys.D);
             } else if (tx > 78 && tx < 104 && ty > tHeight - 26) {
@@ -75,18 +75,18 @@ public class InputHandlerGame implements InputProcessor {
 
     @Override
     public boolean touchUp(int screenX, int screenY, int pointer, int button) {
-        int tx = (int)(screenX * tWidth/getWidth());
-        int ty = (int)(screenY * tHeight/getHeight());
-        screenX *= gameProc.renderer.camera.viewportWidth/getWidth();
-        screenY *= gameProc.renderer.camera.viewportHeight/getHeight();
+        int tx = (int) (screenX * tWidth / getWidth());
+        int ty = (int) (screenY * tHeight / getHeight());
+        screenX *= gameProc.renderer.camera.viewportWidth / getWidth();
+        screenY *= gameProc.renderer.camera.viewportHeight / getHeight();
         if (CaveGame.TOUCH) {
             if (tx > 26 && tx < 52 && ty > tHeight - 52 && ty < tHeight - 26) {
-                if (gameProc.ctrlMode==1) gameInput.keyUp(Input.Keys.W);
+                if (gameProc.ctrlMode == 1) gameInput.keyUp(Input.Keys.W);
                 else gameInput.keyUp(Input.Keys.SPACE);
             } else if (tx > 0 && tx < 26 && ty > tHeight - 26) {
                 gameInput.keyUp(Input.Keys.A);
             } else if (tx > 26 && tx < 52 && ty > tHeight - 26) {
-                if (gameProc.ctrlMode==1) gameInput.keyUp(Input.Keys.S);
+                if (gameProc.ctrlMode == 1) gameInput.keyUp(Input.Keys.S);
                 else gameInput.keyUp(Input.Keys.CONTROL_LEFT);
             } else if (tx > 52 && tx < 78 && ty > tHeight - 26) {
                 gameInput.keyUp(Input.Keys.D);
@@ -107,9 +107,9 @@ public class InputHandlerGame implements InputProcessor {
 
     @Override
     public boolean touchDragged(int screenX, int screenY, int pointer) {
-        screenX *= gameProc.renderer.camera.viewportWidth/getWidth();
-        screenY *= gameProc.renderer.camera.viewportHeight/getHeight();
-        if (gameProc.isKeyDown && (screenX>78 || screenY<gameProc.renderer.getHeight()-52)) {
+        screenX *= gameProc.renderer.camera.viewportWidth / getWidth();
+        screenY *= gameProc.renderer.camera.viewportHeight / getHeight();
+        if (gameProc.isKeyDown && (screenX > 78 || screenY < gameProc.renderer.getHeight() - 52)) {
             gameInput.keyUp(gameProc.keyDownCode);
         } else {
             gameInput.touchDragged(screenX, screenY);
@@ -119,9 +119,9 @@ public class InputHandlerGame implements InputProcessor {
 
     @Override
     public boolean mouseMoved(int screenX, int screenY) {
-        screenX *= gameProc.renderer.camera.viewportWidth/getWidth();
-        screenY *= gameProc.renderer.camera.viewportHeight/getHeight();
-        gameInput.mouseMoved(screenX,screenY);
+        screenX *= gameProc.renderer.camera.viewportWidth / getWidth();
+        screenY *= gameProc.renderer.camera.viewportHeight / getHeight();
+        gameInput.mouseMoved(screenX, screenY);
         return false;
     }
 
index 74110ea0b88dafbc77b229a7cb5045e4c17d87b1..d551b58c29145dd062023fd929d75d9c0d6e3878 100644 (file)
@@ -5,7 +5,7 @@ import ru.deadsoftware.cavecraft.GameScreen;
 import ru.deadsoftware.cavecraft.menu.MenuRenderer;
 import ru.deadsoftware.cavecraft.menu.objects.Button;
 
-public class InputHandlerMenu implements InputProcessor{
+public class InputHandlerMenu implements InputProcessor {
 
     private MenuRenderer renderer;
 
@@ -35,10 +35,10 @@ public class InputHandlerMenu implements InputProcessor{
 
     @Override
     public boolean touchUp(int screenX, int screenY, int pointer, int mb) {
-        screenX *= renderer.getWidth()/ GameScreen.getWidth();
-        screenY *= renderer.getHeight()/GameScreen.getHeight();
+        screenX *= renderer.getWidth() / GameScreen.getWidth();
+        screenY *= renderer.getHeight() / GameScreen.getHeight();
         for (Button button : renderer.menuMainButtons) {
-            if (button.getRect().contains(screenX, screenY) && button.getType()>0) renderer.buttonClicked(button);
+            if (button.getRect().contains(screenX, screenY) && button.getType() > 0) renderer.buttonClicked(button);
         }
         return false;
     }
index f083a326e9e00d08cf5bd77c6b2875d6b910a1ca..72f8a59929b8935f849dccca515f94fc37e23bfc 100644 (file)
@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
 import ru.deadsoftware.cavecraft.GameScreen;
-import ru.deadsoftware.cavecraft.misc.Assets;
 
 public abstract class Renderer {
 
@@ -29,14 +28,16 @@ public abstract class Renderer {
         return camera.viewportWidth;
     }
 
-    public float getHeight() {return camera.viewportHeight;}
+    public float getHeight() {
+        return camera.viewportHeight;
+    }
 
     public void setFontScale(float scale) {
         Assets.minecraftFont.getData().setScale(scale);
     }
 
     public void setFontColor(int r, int g, int b) {
-        Assets.minecraftFont.setColor(r/255f, g/255f, b/255f, 1f);
+        Assets.minecraftFont.setColor(r / 255f, g / 255f, b / 255f, 1f);
     }
 
     public void drawString(String str, float x, float y) {
@@ -45,8 +46,8 @@ public abstract class Renderer {
 
     public void drawString(String str) {
         Assets.minecraftFont.draw(spriteBatch, str,
-                getWidth()/2 - Assets.getStringWidth(str)/2,
-                getHeight()/2 - Assets.getStringHeight(str)/2);
+                getWidth() / 2 - Assets.getStringWidth(str) / 2,
+                getHeight() / 2 - Assets.getStringHeight(str) / 2);
     }
 
     public abstract void render();