From: fred-boy Date: Sun, 30 Sep 2018 14:34:55 +0000 (+0700) Subject: Rename inventory -> inv X-Git-Tag: alpha0.4~79 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=18f9e2e6b8a17746e80f8332a7a57f6296678bdd;p=cavedroid.git Rename inventory -> inv --- diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index 76e4505..5f7dfea 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -149,19 +149,19 @@ public class GameInput { if (ix >= 8 || ix < 0 || iy < 0 || iy >= 5) item = -1; if (item >= 0 && item < GameItems.getItemsSize()) { for (int i = 8; i > 0; i--) { - gp.player.inventory[i] = gp.player.inventory[i - 1]; + gp.player.inv[i] = gp.player.inv[i - 1]; } - gp.player.inventory[0] = item; + gp.player.inv[0] = item; } } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) { CaveGame.STATE = AppState.GAME_PLAY; } else if (screenY < Assets.invBar.getRegionHeight() && screenX > gp.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 && screenX < gp.renderer.getWidth() / 2 + Assets.invBar.getRegionWidth() / 2) { - gp.invSlot = (int) ((screenX - (gp.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2)) / 20); + gp.slot = (int) ((screenX - (gp.renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2)) / 20); } else if (button == Input.Buttons.RIGHT) { gp.useItem(gp.curX, gp.curY, - gp.player.inventory[gp.invSlot], false); + gp.player.inv[gp.slot], false); } else if (button == Input.Buttons.LEFT) { gp.blockDmg = 0; } @@ -188,9 +188,9 @@ public class GameInput { public void scrolled(int amount) { switch (CaveGame.STATE) { case GAME_PLAY: - gp.invSlot += amount; - if (gp.invSlot < 0) gp.invSlot = 8; - if (gp.invSlot > 8) gp.invSlot = 0; + gp.slot += amount; + if (gp.slot < 0) gp.slot = 8; + if (gp.slot > 8) gp.slot = 0; break; case GAME_CREATIVE_INV: gp.creativeScroll += amount; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index e091494..3117cde 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -34,7 +34,7 @@ public class GameProc implements Serializable { public transient GamePhysics physics; public int curX, curY; - public int invSlot; + public int slot; public int ctrlMode; public int creativeScroll, maxCreativeScroll; public int blockDmg = 0; @@ -423,7 +423,7 @@ public class GameProc implements Serializable { if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) { if (touchDownBtn == Input.Buttons.RIGHT) { - useItem(curX, curY, player.inventory[invSlot], true); + useItem(curX, curY, player.inv[slot], true); isTouchDown = false; } else if (touchDownY < Assets.invBar.getRegionHeight() && touchDownX > renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 && diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 28a7c56..a0ac68a 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -145,23 +145,23 @@ public class GameRenderer extends Renderer { spriter.draw(Assets.plSprite[pl.dir][1], pl.position.x - getCamX() - 2, pl.position.y - getCamY() + 8); //item in hand - if (pl.inventory[gp.invSlot] > 0) - switch (GameItems.getItem(pl.inventory[gp.invSlot]).getType()) { + if (pl.inv[gp.slot] > 0) + switch (GameItems.getItem(pl.inv[gp.slot]).getType()) { case 0: - Assets.blockTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].setPosition( + Assets.blockTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].setPosition( pl.position.x - getCamX() - 8 * MathUtils.sin(MathUtils.degRad * Assets.plSprite[0][2].getRotation()), pl.position.y - getCamY() + 6 + 8 * MathUtils.cos(MathUtils.degRad * Assets.plSprite[0][2].getRotation())); - Assets.blockTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].draw(spriter); + Assets.blockTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].draw(spriter); break; default: - Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].flip((pl.dir == 0), false); - Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].setRotation( + Assets.itemTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].flip((pl.dir == 0), false); + Assets.itemTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].setRotation( -45 + pl.dir * 90 + Assets.plSprite[0][2].getRotation()); - Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].setPosition( + Assets.itemTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].setPosition( pl.position.x - getCamX() - 10 + (12 * pl.dir) - 8 * MathUtils.sin(MathUtils.degRad * Assets.plSprite[0][2].getRotation()), pl.position.y - getCamY() + 2 + 8 * MathUtils.cos(MathUtils.degRad * Assets.plSprite[0][2].getRotation())); - Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].draw(spriter); - Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].flip((pl.dir == 0), false); + Assets.itemTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].draw(spriter); + Assets.itemTex[GameItems.getItem(pl.inv[gp.slot]).getTex()].flip((pl.dir == 0), false); break; } //front hand @@ -193,14 +193,14 @@ public class GameRenderer extends Renderer { } } for (int i = 0; i < 9; i++) { - if (gp.player.inventory[i] > 0) - switch (GameItems.getItem(gp.player.inventory[i]).getType()) { + if (gp.player.inv[i] > 0) + switch (GameItems.getItem(gp.player.inv[i]).getType()) { case 0: - spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inventory[i]).getTex()], + spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inv[i]).getTex()], x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); break; case 1: - spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inventory[i]).getTex()], + spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inv[i]).getTex()], x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24); break; } @@ -217,15 +217,15 @@ public class GameRenderer extends Renderer { gp.curY * 16 - getCamY()); spriter.draw(Assets.invBar, getWidth() / 2 - Assets.invBar.getRegionWidth() / 2, 0); for (int i = 0; i < 9; i++) { - if (gp.player.inventory[i] > 0) { - switch (GameItems.getItem(gp.player.inventory[i]).getType()) { + if (gp.player.inv[i] > 0) { + switch (GameItems.getItem(gp.player.inv[i]).getType()) { case 0: - spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inventory[i]).getTex()], + spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inv[i]).getTex()], getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, 3); break; case 1: - spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inventory[i]).getTex()], + spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inv[i]).getTex()], getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20, 3); break; @@ -233,7 +233,7 @@ public class GameRenderer extends Renderer { } } spriter.draw(Assets.invBarCur, - getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 - 1 + 20 * gp.invSlot, + getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 - 1 + 20 * gp.slot, -1); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java index e967f88..d92b846 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Drop.java @@ -17,9 +17,9 @@ public class Drop implements Serializable { } public void pickUpDrop(Player pl) { - for (int i = 0; i < pl.inventory.length; i++) { - if (pl.inventory[i] == 0 || pl.inventory[i] == id) { - pl.inventory[i] = id; + for (int i = 0; i < pl.inv.length; i++) { + if (pl.inv[i] == 0 || pl.inv[i] == id) { + pl.inv[i] = id; pickedUp = true; break; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java index 4a6c4d4..ad5faaf 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java @@ -13,7 +13,7 @@ public class Player implements Serializable { public Vector2 move; public int width, height, dir, texWidth; public boolean canJump; - public int[] inventory; + public int[] inv; public boolean flyMode = false; public Player(Vector2 spawnPoint) { @@ -22,7 +22,7 @@ public class Player implements Serializable { width = 4; height = 30; texWidth = 8; - inventory = new int[9]; + inv = new int[9]; } public Rectangle getRect() {