diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java
index dd2c38732f361983f7a8f396b04ff1ada1fb57d3..d946942fdfa53bfaa1a787288e0c98a3f965c0e9 100644 (file)
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<Mob> mobs;
public ArrayList<Drop> 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<Drop>();
mobs = new ArrayList<Mob>();
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;
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()));
}
}
}
}
- 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());
}
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++) {
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 &&