X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameProc.java;h=d946942fdfa53bfaa1a787288e0c98a3f965c0e9;hb=22eccb137bf9642700f762dd39cf02ea144bdca3;hp=dd2c38732f361983f7a8f396b04ff1ada1fb57d3;hpb=cef4b5a9985bcbdfea6dc652147ecde0721d7fdc;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index dd2c387..d946942 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -19,47 +19,42 @@ import java.util.ArrayList; public class GameProc implements Serializable { - public static double RUN_TIME = 0; + static boolean DO_UPD = false; + static int UPD_X = -1, UPD_Y = -1; - public static boolean DO_UPD = false; - public static int UPD_X = -1, UPD_Y = -1; + public transient GameWorld world; + public transient GameRenderer renderer; + public transient GamePhysics physics; public Player player; - public ArrayList mobs; public ArrayList drops; - public transient GameWorld world; - public transient GameRenderer renderer; - public transient GamePhysics physics; - - public int curX, curY; - public int slot; - public int ctrlMode; - public int creativeScroll, maxCreativeScroll; - public int blockDmg = 0; - public boolean isTouchDown, isKeyDown, swim; - public int touchDownX, touchDownY, keyDownCode; - public int touchDownBtn; + public boolean isTouchDown, isKeyDown; + public int ctrlMode, touchDownX, touchDownY, touchDownBtn, keyDownCode; public long touchDownTime; - public GameProc(int gameMode) { + int curX, curY; + int creativeScroll, maxCreativeScroll; + int blockDmg = 0; + + public void initGame(int gameMode) { world = new GameWorld(); world.generate(1024, 256); - player = new Player(world, gameMode); + player = new Player(gameMode); drops = new ArrayList(); mobs = new ArrayList(); for (int i = 0; i < 16; i++) { mobs.add(new Pig(i * 256, 196 * 16)); } - physics = new GamePhysics(this); + physics = new GamePhysics(); if (CaveGame.TOUCH) { - renderer = new GameRenderer(this, 320, + renderer = new GameRenderer(320, 320 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } else { ctrlMode = 1; - renderer = new GameRenderer(this, 480, + renderer = new GameRenderer(480, 480 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } maxCreativeScroll = GameItems.getItemsSize() / 8; @@ -68,10 +63,10 @@ public class GameProc implements Serializable { public void resetRenderer() { if (CaveGame.TOUCH) { - renderer = new GameRenderer(this, 320, + renderer = new GameRenderer(320, 320 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } else { - renderer = new GameRenderer(this, 480, + renderer = new GameRenderer(480, 480 * ((float) GameScreen.getHeight() / GameScreen.getWidth())); } } @@ -380,7 +375,7 @@ public class GameProc implements Serializable { } } - public void useItem(int x, int y, int id, boolean bg) { + void useItem(int x, int y, int id, boolean bg) { 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()); @@ -388,8 +383,6 @@ public class GameProc implements Serializable { } public void update(float delta) { - 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++) { @@ -436,7 +429,7 @@ public class GameProc implements Serializable { if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) { if (touchDownBtn == Input.Buttons.RIGHT) { - useItem(curX, curY, player.inv[slot], true); + useItem(curX, curY, player.inv[player.invSlot], true); isTouchDown = false; } else if (touchDownY < Assets.invBar.getRegionHeight() && touchDownX > renderer.getWidth() / 2 - Assets.invBar.getRegionWidth() / 2 &&