X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameProc.java;h=5b497a4ae17b846d794dabf8869940dd48f886d6;hb=d7f5950fc751cec8fa64005dd1886cac4081ee99;hp=3117cde54273bfac17de2cbf6dee429629c42b90;hpb=18f9e2e6b8a17746e80f8332a7a57f6296678bdd;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 3117cde..5b497a4 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -44,10 +44,10 @@ public class GameProc implements Serializable { public int touchDownBtn; public long touchDownTime; - public GameProc() { + public GameProc(int gameMode) { world = new GameWorld(); world.generate(1024, 256); - player = new Player(world.getSpawnPoint()); + player = new Player(world, gameMode); drops = new ArrayList(); mobs = new ArrayList(); for (int i = 0; i < 16; i++) { @@ -84,10 +84,10 @@ public class GameProc implements Serializable { private void moveCursor() { int pastX = curX, pastY = curY; if (ctrlMode == 0 && CaveGame.TOUCH) { - curX = (int) (player.position.x + player.texWidth / 2) / 16; + curX = (int) (player.pos.x + player.texWidth / 2) / 16; if (player.dir == 0) curX--; else curX++; - curY = (int) (player.position.y + player.texWidth) / 16; + curY = (int) (player.pos.y + player.texWidth) / 16; if (!isAutoselectable(curX, curY)) { curY++; } @@ -114,9 +114,9 @@ public class GameProc implements Serializable { if (curY < 0) curY = 0; if (curY >= world.getHeight()) curY = world.getHeight() - 1; if (ctrlMode == 1) { - if (curX * 16 + 8 < player.position.x + player.texWidth / 2) + if (curX * 16 + 8 < player.pos.x + player.texWidth / 2) player.dir = 0; - if (curX * 16 + 8 > player.position.x + player.texWidth / 2) + if (curX * 16 + 8 > player.pos.x + player.texWidth / 2) player.dir = 1; } } @@ -365,9 +365,9 @@ public class GameProc implements Serializable { } } - if (world.getForeMap(x, y) == 59) { + if (world.getForeMap(x, y) > 0 && GameItems.getBlock(world.getForeMap(x, y)).rb) { if (world.getForeMap(x, y + 1) == 0 || !GameItems.getBlock(world.getForeMap(x, y + 1)).coll) { - world.setForeMap(x, y, 0); + world.destroyForeMap(x, y, this); updateBlock(x, y - 1); } } @@ -409,14 +409,27 @@ public class GameProc implements Serializable { checkCursorBounds(); if (isTouchDown && touchDownBtn == Input.Buttons.LEFT) { - if (world.getForeMap(curX, curY) > 0 && - GameItems.getBlock(world.getForeMap(curX, curY)).getHp() >= 0) {// || world.getBackMap(curX, curY) > 0) { - blockDmg++; - 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; + if ((world.getForeMap(curX, curY) > 0 && GameItems.getBlock(world.getForeMap(curX, curY)).getHp() >= 0) || + (world.getForeMap(curX, curY) == 0 && + world.getBackMap(curX, curY) > 0 && + GameItems.getBlock(world.getBackMap(curX, curY)).getHp() >= 0)) { + if (player.gameMode == 0) { + blockDmg++; + if (world.getForeMap(curX, curY) > 0) { + if (blockDmg >= GameItems.getBlock(world.getForeMap(curX, curY)).getHp()) { + world.destroyForeMap(curX, curY, this); + blockDmg = 0; + } + } else if (world.getBackMap(curX, curY) > 0) { + if (blockDmg >= GameItems.getBlock(world.getBackMap(curX, curY)).getHp()) { + world.destroyBackMap(curX, curY, this); + blockDmg = 0; + } + } + } else { + if (world.getForeMap(curX, curY) > 0) world.placeToForeground(curX, curY, 0); + else if (world.getBackMap(curX, curY) > 0) world.placeToBackground(curX, curY, 0); + isTouchDown = false; } } }