summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5fd3c5a)
raw | patch | inline | side by side (parent: 5fd3c5a)
author | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 14:34:55 +0000 (21:34 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 14:34:55 +0000 (21:34 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index 76e45059dd74a4918a025fa18f443760319d73a3..5f7dfea6e2714ee3306ef5666585b5e6b9997642 100644 (file)
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;
}
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 e091494daeec99d256544ad78bd7f22daffdf95a..3117cde54273bfac17de2cbf6dee429629c42b90 100644 (file)
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;
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 28a7c5687e26b33ede0bc94a285b02a75bf0fcd3..a0ac68a2c4ae6b73041a42d7c055bf0650465191 100644 (file)
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
}
}
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;
}
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;
}
}
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 e967f880314480a1fd9b9d73c77aedea4729622f..d92b846250571521dfd33f3f85cd826a35f3f312 100644 (file)
}
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 4a6c4d41682c36eca08ea7c288d3938df9f66acb..ad5faafeba30e00907637a1fc1e4ed9aef77b6cd 100644 (file)
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) {
width = 4;
height = 30;
texWidth = 8;
- inventory = new int[9];
+ inv = new int[9];
}
public Rectangle getRect() {