summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: feb58da)
raw | patch | inline | side by side (parent: feb58da)
author | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 14:28:47 +0000 (21:28 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Sun, 30 Sep 2018 14:28:47 +0000 (21:28 +0700) |
Make items and blocks private
diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java
index 541bc8eafab4f50c7e2963f4d5db22d4c8ba9bb6..545ee3f74f0f500f13481286b2f6a5f284be8006 100644 (file)
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
+import ru.deadsoftware.cavecraft.game.GameItems;
import ru.deadsoftware.cavecraft.game.GameProc;
import ru.deadsoftware.cavecraft.game.GameSaver;
-import ru.deadsoftware.cavecraft.game.Items;
import ru.deadsoftware.cavecraft.menu.MenuRenderer;
import ru.deadsoftware.cavecraft.misc.*;
public GameScreen() {
Assets.load();
- Items.load();
+ GameItems.load();
menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
renderer = menuRenderer;
Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index 608ed9f4e93e1f1e45775f88dab29ad1a83875c5..76e45059dd74a4918a025fa18f443760319d73a3 100644 (file)
}
private boolean checkSwim() {
- return (Items.isFluid(gp.world.getForeMap((int) (gp.player.position.x + gp.player.width / 2) / 16,
+ return (GameItems.isFluid(gp.world.getForeMap((int) (gp.player.position.x + gp.player.width / 2) / 16,
(int) (gp.player.position.y + gp.player.height / 4 * 3) / 16)));
}
int iy = (int) (screenY - (gp.renderer.getHeight() / 2 - Assets.creativeInv.getRegionHeight() / 2 + 18)) / 18;
int item = gp.creativeScroll * 8 + (ix + iy * 8);
if (ix >= 8 || ix < 0 || iy < 0 || iy >= 5) item = -1;
- if (item >= 0 && item < Items.items.size()) {
+ if (item >= 0 && item < GameItems.getItemsSize()) {
for (int i = 8; i > 0; i--) {
gp.player.inventory[i] = gp.player.inventory[i - 1];
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/GameItems.java
similarity index 94%
rename from core/src/ru/deadsoftware/cavecraft/game/Items.java
rename to core/src/ru/deadsoftware/cavecraft/game/GameItems.java
index 2853b7b597ecf24b881ee210df3bdb5f66fb68e9..6a39f0584613c169209904777d032ef6a8ce0552 100644 (file)
rename from core/src/ru/deadsoftware/cavecraft/game/Items.java
rename to core/src/ru/deadsoftware/cavecraft/game/GameItems.java
index 2853b7b597ecf24b881ee210df3bdb5f66fb68e9..6a39f0584613c169209904777d032ef6a8ce0552 100644 (file)
import java.util.ArrayList;
-public class Items {
+public class GameItems {
- public static ArrayMap<String, Block> blocks = new ArrayMap<String, Block>();
- public static ArrayList<Item> items = new ArrayList<Item>();
+ private static ArrayMap<String, Block> blocks = new ArrayMap<String, Block>();
+ private static ArrayList<Item> items = new ArrayList<Item>();
public static boolean isFluid(int bl) {
return (bl == 8 || bl == 9 || bl == 60 || bl == 61 || bl == 62 || bl == 63 || bl == 64 || bl == 65 || bl == 66 || bl == 67);
return (bl == 51 || bl == 53 || bl == 54 || bl == 55 || bl == 56 || bl == 58);
}
+ public static String getBlockKey(int id) {
+ return blocks.getKeyAt(id);
+ }
+
+ public static Block getBlock(int id) {
+ return blocks.getValueAt(id);
+ }
+
+ public static Item getItem(int id) {
+ return items.get(id);
+ }
+
+ public static int getBlocksSize() {
+ return blocks.size;
+ }
+
+ public static int getItemsSize() {
+ return items.size();
+ }
+
public static void loadItems() {
//0
items.add(null);
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index fe0765a0fa06b9f06a17344a3973ad82b2637e41..d78d319efaeff1875fa38c6b22c02829e36aeec1 100644 (file)
default:
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 && GameItems.getBlock(bl).toJump() &&
+ (rect.y + rect.height) - GameItems.getBlock(bl).getRect((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16)).y > 8);
}
private boolean checkColl(Rectangle rect) {
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
bl = gp.world.getForeMap(x, y);
- if (bl > 0 && Items.blocks.getValueAt(bl).coll) {
- if (Intersector.overlaps(rect, Items.blocks.getValueAt(bl).getRect(x, y))) {
+ if (bl > 0 && GameItems.getBlock(bl).coll) {
+ if (Intersector.overlaps(rect, GameItems.getBlock(bl).getRect(x, y))) {
return true;
}
}
pl.canJump = false;
}
- if (Items.isFluid(getBlock(pl.getRect()))) {
+ if (GameItems.isFluid(getBlock(pl.getRect()))) {
if (CaveGame.TOUCH && pl.move.x != 0 && !gp.swim && !pl.flyMode) gp.swim = true;
if (!gp.swim) {
if (!pl.flyMode && pl.move.y < 4.5f) pl.move.add(gravity.x / 4, gravity.y / 4);
mob.canJump = false;
}
- if (mob.getType() == 0 && Items.isFluid(getBlock(mob.getRect()))) {
+ if (mob.getType() == 0 && GameItems.isFluid(getBlock(mob.getRect()))) {
if (mob.move.y > 9) mob.move.add(0, -.9f);
mob.move.add(0, -.5f);
if (mob.move.y < -3) mob.move.y = -3;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index f79694f713159318b9fb19b5ad2c634d70dc03f4..e091494daeec99d256544ad78bd7f22daffdf95a 100644 (file)
renderer = new GameRenderer(this, 480,
480 * ((float) GameScreen.getHeight() / GameScreen.getWidth()));
}
- maxCreativeScroll = Items.items.size() / 8;
+ maxCreativeScroll = GameItems.getItemsSize() / 8;
GameSaver.save(this);
}
private boolean isAutoselectable(int x, int y) {
return (world.getForeMap(x, y) > 0 &&
- Items.blocks.getValueAt(world.getForeMap(x, y)).coll);
+ GameItems.getBlock(world.getForeMap(x, y)).coll);
}
private void moveCursor() {
}
private void updateFluids(int x, int y) {
- if (Items.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y) != 8) {
+ if (GameItems.isWater(world.getForeMap(x, y)) && world.getForeMap(x, y) != 8) {
if (world.getForeMap(x, y) == 60) {
- if (!Items.isWater(world.getForeMap(x, y - 1)))
+ if (!GameItems.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)))) {
+ } else if ((!GameItems.isWater(world.getForeMap(x - 1, y)) ||
+ (GameItems.isWater(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) &&
+ (!GameItems.isWater(world.getForeMap(x + 1, y)) ||
+ (GameItems.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) == 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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.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)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y))) ||
- (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 61)) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.isFluid(world.getForeMap(x + 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y))) ||
- (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 61)) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.isFluid(world.getForeMap(x - 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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))
}
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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.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)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y))) ||
- (Items.isWater(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 62)) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.isFluid(world.getForeMap(x + 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y))) ||
- (Items.isWater(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 62)) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.isFluid(world.getForeMap(x - 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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) == 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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.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)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y)))) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y)))) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.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))) {
+ } else if (GameItems.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) == 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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.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 (GameItems.isLava(world.getForeMap(x, y)) && world.getForeMap(x, y) != 9) {
if (world.getForeMap(x, y) == 64) {
- if (!Items.isLava(world.getForeMap(x, y - 1)))
+ if (!GameItems.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)))) {
+ } else if ((!GameItems.isLava(world.getForeMap(x, y - 1))) &&
+ (!GameItems.isLava(world.getForeMap(x - 1, y)) ||
+ (GameItems.isLava(world.getForeMap(x, y)) && world.getForeMap(x - 1, y) >= world.getForeMap(x, y))) &&
+ (!GameItems.isLava(world.getForeMap(x + 1, y)) ||
+ (GameItems.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) == 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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x, y + 1))) {
world.setForeMap(x, y + 1, 1);
- } else if (Items.blocks.getValueAt(world.getForeMap(x, y + 1)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y))) ||
- (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 65)) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.isFluid(world.getForeMap(x + 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y))) ||
- (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 65)) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.isFluid(world.getForeMap(x - 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x - 1, y))) {
world.setForeMap(x - 1, y, 1);
}
}
}
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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x, y + 1))) {
world.setForeMap(x, y + 1, 1);
- } else if (Items.blocks.getValueAt(world.getForeMap(x, y + 1)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y))) ||
- (Items.isLava(world.getForeMap(x + 1, y)) && world.getForeMap(x + 1, y) > 66)) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.isFluid(world.getForeMap(x + 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y))) ||
- (Items.isLava(world.getForeMap(x - 1, y)) && world.getForeMap(x - 1, y) > 66)) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.isFluid(world.getForeMap(x - 1, y))) ||
+ (GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x - 1, y))) {
world.setForeMap(x - 1, y, 1);
}
}
}
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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x, y + 1))) {
world.setForeMap(x, y + 1, 1);
- } else if (Items.blocks.getValueAt(world.getForeMap(x, y + 1)).coll) {
+ } else if (GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
if (world.getForeMap(x + 1, y) == 0 ||
- (!Items.blocks.getValueAt(world.getForeMap(x + 1, y)).coll && !Items.isFluid(world.getForeMap(x + 1, y)))) {
+ (!GameItems.getBlock(world.getForeMap(x + 1, y)).coll && !GameItems.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))) {
+ } else if (GameItems.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)).coll && !Items.isFluid(world.getForeMap(x - 1, y)))) {
+ (!GameItems.getBlock(world.getForeMap(x - 1, y)).coll && !GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x - 1, y))) {
world.setForeMap(x - 1, y, 1);
}
}
}
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)).coll && !Items.isFluid(world.getForeMap(x, y + 1)))) {
+ (!GameItems.getBlock(world.getForeMap(x, y + 1)).coll && !GameItems.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))) {
+ } else if (GameItems.isWater(world.getForeMap(x, y + 1))) {
world.setForeMap(x, y + 1, 1);
}
return;
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)).coll) {
+ if (world.getForeMap(x, y + 1) == 0 || !GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
world.setForeMap(x, y, 0);
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)).coll) {
+ if (world.getForeMap(x, y + 1) == 0 || !GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
world.setForeMap(x, y, 0);
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)).coll) {
+ if (world.getForeMap(x, y + 1) == 0 || !GameItems.getBlock(world.getForeMap(x, y + 1)).coll) {
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)).coll ||
- Items.isFluid(world.getForeMap(x, y - 1)))) {
+ if (world.getForeMap(x, y - 1) > 0 && (GameItems.getBlock(world.getForeMap(x, y - 1)).coll ||
+ GameItems.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 (!bg) world.placeToForeground(x, y, Items.items.get(id).getBlock());
- else world.placeToBackground(x, y, Items.items.get(id).getBlock());
+ if (id > 0 && GameItems.getItem(id).getType() == 0) {
+ if (!bg) world.placeToForeground(x, y, GameItems.getItem(id).getBlock());
+ else world.placeToBackground(x, y, GameItems.getItem(id).getBlock());
}
}
if (isTouchDown && touchDownBtn == Input.Buttons.LEFT) {
if (world.getForeMap(curX, curY) > 0 &&
- Items.blocks.getValueAt(world.getForeMap(curX, curY)).getHp() >= 0) {// || world.getBackMap(curX, curY) > 0) {
+ GameItems.getBlock(world.getForeMap(curX, curY)).getHp() >= 0) {// || world.getBackMap(curX, curY) > 0) {
blockDmg++;
- if (blockDmg >= Items.blocks.getValueAt(world.getForeMap(curX, curY)).getHp()) {
- if (Items.blocks.getValueAt(world.getForeMap(curX, curY)).getDrop() > 0)
- drops.add(new Drop(curX * 16 + 4, curY * 16 + 4, Items.blocks.getValueAt(world.getForeMap(curX, curY)).getDrop()));
+ if (blockDmg >= GameItems.getBlock(world.getForeMap(curX, curY)).getHp()) {
+ if (GameItems.getBlock(world.getForeMap(curX, curY)).getDrop() > 0)
+ drops.add(new Drop(curX * 16 + 4, curY * 16 + 4, GameItems.getBlock(world.getForeMap(curX, curY)).getDrop()));
world.placeToForeground(curX, curY, 0);
blockDmg = 0;
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index cbcaeb801c1e170cee00f29a90eefefe8625fc62..28a7c5687e26b33ede0bc94a285b02a75bf0fcd3 100644 (file)
if (gp.blockDmg > 0) {
spriter.draw(Assets.wreck[
10 * gp.blockDmg /
- Items.blocks.getValueAt(gp.world.getForeMap(gp.curX, gp.curY)).getHp()],
+ GameItems.getBlock(gp.world.getForeMap(gp.curX, gp.curY)).getHp()],
gp.curX * 16 - getCamX(),
gp.curY * 16 - getCamY());
}
if (maxY > gp.world.getHeight()) maxY = gp.world.getHeight();
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
- if ((gp.world.getForeMap(x, y) == 0 || Items.blocks.getValueAt(gp.world.getForeMap(x, y)).tp)
+ if ((gp.world.getForeMap(x, y) == 0 || GameItems.getBlock(gp.world.getForeMap(x, y)).tp)
&& gp.world.getBackMap(x, y) > 0) {
spriter.draw(
- Assets.blockTex[Items.blocks.getValueAt(gp.world.getBackMap(x, y)).getTex()],
+ Assets.blockTex[GameItems.getBlock(gp.world.getBackMap(x, y)).getTex()],
drawX(x), drawY(y));
if (gp.world.getForeMap(x, y) == 0) drawWreck();
Assets.shade.setPosition(drawX(x), drawY(y));
Assets.shade.draw(spriter);
}
- if (gp.world.getForeMap(x, y) > 0 && Items.blocks.getValueAt(gp.world.getForeMap(x, y)).bg) {
+ if (gp.world.getForeMap(x, y) > 0 && GameItems.getBlock(gp.world.getForeMap(x, y)).bg) {
spriter.draw(
- Assets.blockTex[Items.blocks.getValueAt(gp.world.getForeMap(x, y)).getTex()],
+ Assets.blockTex[GameItems.getBlock(gp.world.getForeMap(x, y)).getTex()],
drawX(x), drawY(y));
drawWreck();
}
if (maxY > gp.world.getHeight()) maxY = gp.world.getHeight();
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
- if (gp.world.getForeMap(x, y) > 0 && !Items.blocks.getValueAt(gp.world.getForeMap(x, y)).bg) {
+ if (gp.world.getForeMap(x, y) > 0 && !GameItems.getBlock(gp.world.getForeMap(x, y)).bg) {
spriter.draw(
- Assets.blockTex[Items.blocks.getValueAt(gp.world.getForeMap(x, y)).getTex()],
+ Assets.blockTex[GameItems.getBlock(gp.world.getForeMap(x, y)).getTex()],
drawX(x), drawY(y));
drawWreck();
}
}
private void drawDrop(Drop drop) {
- switch (Items.items.get(drop.getId()).getType()) {
+ switch (GameItems.getItem(drop.getId()).getType()) {
case 0:
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].setPosition(drop.position.x - getCamX() - gp.world.getWidth() * 16, drop.position.y - getCamY());
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].draw(spriter);
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].setPosition(drop.position.x - getCamX(), drop.position.y - getCamY());
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].draw(spriter);
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].setPosition(drop.position.x - getCamX() + gp.world.getWidth() * 16, drop.position.y - getCamY());
- Assets.blockTex[Items.items.get(drop.getId()).getTex()].draw(spriter);
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(drop.position.x - getCamX() - gp.world.getWidth() * 16, drop.position.y - getCamY());
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(drop.position.x - getCamX(), drop.position.y - getCamY());
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].setPosition(drop.position.x - getCamX() + gp.world.getWidth() * 16, drop.position.y - getCamY());
+ Assets.blockTex[GameItems.getItem(drop.getId()).getTex()].draw(spriter);
}
}
pl.position.x - getCamX() - 2, pl.position.y - getCamY() + 8);
//item in hand
if (pl.inventory[gp.invSlot] > 0)
- switch (Items.items.get(pl.inventory[gp.invSlot]).getType()) {
+ switch (GameItems.getItem(pl.inventory[gp.invSlot]).getType()) {
case 0:
- Assets.blockTex[Items.items.get(pl.inventory[gp.invSlot]).getTex()].setPosition(
+ Assets.blockTex[GameItems.getItem(pl.inventory[gp.invSlot]).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[Items.items.get(pl.inventory[gp.invSlot]).getTex()].draw(spriter);
+ Assets.blockTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].draw(spriter);
break;
default:
- Assets.itemTex[Items.items.get(pl.inventory[gp.invSlot]).getTex()].flip((pl.dir == 0), false);
- Assets.itemTex[Items.items.get(pl.inventory[gp.invSlot]).getTex()].setRotation(
+ Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].flip((pl.dir == 0), false);
+ Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).getTex()].setRotation(
-45 + pl.dir * 90 + Assets.plSprite[0][2].getRotation());
- Assets.itemTex[Items.items.get(pl.inventory[gp.invSlot]).getTex()].setPosition(
+ Assets.itemTex[GameItems.getItem(pl.inventory[gp.invSlot]).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[Items.items.get(pl.inventory[gp.invSlot]).getTex()].draw(spriter);
- Assets.itemTex[Items.items.get(pl.inventory[gp.invSlot]).getTex()].flip((pl.dir == 0), false);
+ 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);
break;
}
//front hand
spriter.draw(Assets.creativeScr, x + 156,
y + 18 + (gp.creativeScroll * (72 / gp.maxCreativeScroll)));
for (int i = gp.creativeScroll * 8; i < gp.creativeScroll * 8 + 40; i++) {
- if (i > 0 && i < Items.items.size())
- switch (Items.items.get(i).getType()) {
+ if (i > 0 && i < GameItems.getItemsSize())
+ switch (GameItems.getItem(i).getType()) {
case 0:
- spriter.draw(Assets.blockTex[Items.items.get(i).getTex()],
+ spriter.draw(Assets.blockTex[GameItems.getItem(i).getTex()],
x + 8 + ((i - gp.creativeScroll * 8) % 8) * 18,
y + 18 + ((i - gp.creativeScroll * 8) / 8) * 18);
break;
case 1:
- spriter.draw(Assets.itemTex[Items.items.get(i).getTex()],
+ spriter.draw(Assets.itemTex[GameItems.getItem(i).getTex()],
x + 8 + ((i - gp.creativeScroll * 8) % 8) * 18,
y + 18 + ((i - gp.creativeScroll * 8) / 8) * 18);
break;
}
for (int i = 0; i < 9; i++) {
if (gp.player.inventory[i] > 0)
- switch (Items.items.get(gp.player.inventory[i]).getType()) {
+ switch (GameItems.getItem(gp.player.inventory[i]).getType()) {
case 0:
- spriter.draw(Assets.blockTex[Items.items.get(gp.player.inventory[i]).getTex()],
+ spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inventory[i]).getTex()],
x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
break;
case 1:
- spriter.draw(Assets.itemTex[Items.items.get(gp.player.inventory[i]).getTex()],
+ spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inventory[i]).getTex()],
x + 8 + i * 18, y + Assets.creativeInv.getRegionHeight() - 24);
break;
}
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 (Items.items.get(gp.player.inventory[i]).getType()) {
+ switch (GameItems.getItem(gp.player.inventory[i]).getType()) {
case 0:
- spriter.draw(Assets.blockTex[Items.items.get(gp.player.inventory[i]).getTex()],
+ spriter.draw(Assets.blockTex[GameItems.getItem(gp.player.inventory[i]).getTex()],
getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
3);
break;
case 1:
- spriter.draw(Assets.itemTex[Items.items.get(gp.player.inventory[i]).getTex()],
+ spriter.draw(Assets.itemTex[GameItems.getItem(gp.player.inventory[i]).getTex()],
getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 + 3 + i * 20,
3);
break;
drawString("Y: " + (int) (gp.player.position.y / 16), 0, 20);
drawString("Mobs: " + gp.mobs.size(), 0, 30);
drawString("Drops: " + gp.drops.size(), 0, 40);
- drawString("Block: " + Items.blocks.getKeyAt(gp.world.getForeMap(gp.curX, gp.curY)), 0, 50);
+ drawString("Block: " + GameItems.getBlockKey(gp.world.getForeMap(gp.curX, gp.curY)), 0, 50);
}
spriter.end();
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
index 6adac2d5ad1f7bd47b873f25ad832bdd3c927c8a..073c3d56a384df2df41f097a78fbbf195ad6c8bf 100644 (file)
}
public void placeToForeground(int x, int y, int value) {
- if (getForeMap(x, y) == 0 || value == 0 || !Items.blocks.getValueAt(getForeMap(x, y)).coll) {
+ if (getForeMap(x, y) == 0 || value == 0 || !GameItems.getBlock(getForeMap(x, y)).coll) {
setForeMap(x, y, value);
- } else if (Items.isSlab(value) && getForeMap(x, y) == value) {
+ } else if (GameItems.isSlab(value) && getForeMap(x, y) == value) {
placeSlab(x, y, value);
}
GameProc.UPD_X = x - 8;
}
public void placeToBackground(int x, int y, int value) {
- if (value == 0 || (getBackMap(x, y) == 0 && Items.blocks.getValueAt(value).coll) &&
- (!Items.blocks.getValueAt(value).tp || value == 18)) {
+ if (value == 0 || (getBackMap(x, y) == 0 && GameItems.getBlock(value).coll) &&
+ (!GameItems.getBlock(value).tp || value == 18)) {
setBackMap(x, y, value);
}
}
int x = 0, y = 0;
while (true) {
y++;
- if (getForeMap(x, y) > 0 && Items.blocks.getValueAt(getForeMap(x, y)).coll) break;
+ if (getForeMap(x, y) > 0 && GameItems.getBlock(getForeMap(x, y)).coll) break;
}
x = x * 16 + 4;
y = y * 16 - 32;
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingGravel.java
index de841190239a0d541bc3a84c59581017dd789ca5..21b8dd84f6aa63a58e2ad23de84d0b94389d6f2f 100644 (file)
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.Items;
+import ru.deadsoftware.cavecraft.game.GameItems;
import ru.deadsoftware.cavecraft.misc.Assets;
public class FallingGravel extends Mob {
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- spriteBatch.draw(Assets.blockTex[Items.blocks.get("gravel").getTex()], x, y);
+ spriteBatch.draw(Assets.blockTex[GameItems.getBlock(11).getTex()], x, y);
}
@Override
diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/FallingSand.java
index 8c7661923ec57249a05ed11fa4b76175b0f0763c..b491af5dc7dace59f61af69a0a53ab9b4d5986f4 100644 (file)
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavecraft.game.Items;
+import ru.deadsoftware.cavecraft.game.GameItems;
import ru.deadsoftware.cavecraft.misc.Assets;
public class FallingSand extends Mob {
@Override
public void draw(SpriteBatch spriteBatch, float x, float y) {
- spriteBatch.draw(Assets.blockTex[Items.blocks.get("sand").getTex()], x, y);
+ spriteBatch.draw(Assets.blockTex[GameItems.getBlock(10).getTex()], x, y);
}
@Override
diff --git a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java
index a1f50e665852aa9d6dd19681da5c423db21939c1..aab04d9b76dde0f683c87a89e202859a523c92ba 100644 (file)
import com.badlogic.gdx.utils.Array;
import ru.deadsoftware.cavecraft.CaveGame;
import ru.deadsoftware.cavecraft.GameScreen;
+import ru.deadsoftware.cavecraft.game.GameItems;
import ru.deadsoftware.cavecraft.game.GameSaver;
-import ru.deadsoftware.cavecraft.game.Items;
import ru.deadsoftware.cavecraft.menu.objects.Button;
import ru.deadsoftware.cavecraft.misc.AppState;
import ru.deadsoftware.cavecraft.misc.Assets;
spriter.begin();
for (int x = 0; x <= getWidth() / 16; x++)
for (int y = 0; y <= getHeight() / 16; y++) {
- spriter.draw(Assets.blockTex[Items.blocks.get("dirt").getTex()], x * 16, y * 16);
+ spriter.draw(Assets.blockTex[GameItems.getBlock(3).getTex()], x * 16, y * 16);
spriter.draw(Assets.shade, x * 16, y * 16);
}
spriter.draw(Assets.gameLogo, getWidth() / 2 - Assets.gameLogo.getWidth() / 2, 0);