DEADSOFTWARE

Update input handling (pretty messy)
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / GameProc.java
index 61c64ffebf940ab81233bce72fb7da74977c4e2a..d6378d3d028ea2e98a240ec74847cc22d7741ed4 100644 (file)
@@ -1,6 +1,12 @@
 package ru.deadsoftware.cavecraft.game;
 
+import com.badlogic.gdx.Input;
+import com.badlogic.gdx.math.RandomXS128;
+import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.TimeUtils;
+import ru.deadsoftware.cavecraft.Assets;
+import ru.deadsoftware.cavecraft.game.mobs.Human;
+import ru.deadsoftware.cavecraft.game.mobs.Mob;
 import ru.deadsoftware.cavecraft.game.objects.Player;
 
 public class GameProc {
@@ -9,21 +15,28 @@ public class GameProc {
 
     public Player player;
 
+    public Array<Mob> mobs;
+
     public GameWorld world;
     public GameRenderer renderer;
     public GamePhysics physics;
 
     public int cursorX, cursorY;
+    public int invSlot;
+    public int ctrlMode;
 
     public boolean isTouchDown = false;
     public int touchDownX, touchDownY;
+    public int touchDownButton;
     public long touchDownTime;
 
     public GameProc() {
-        world = new GameWorld(512,32);
+        world = new GameWorld(4096,256);
         renderer = new GameRenderer(this);
         physics = new GamePhysics(this);
-        player = new Player();
+        player = new Player(world.getSpawnPoint());
+        mobs = new Array<Mob>();
+
     }
 
     public void resetRenderer() {
@@ -36,7 +49,15 @@ public class GameProc {
         physics.update(delta);
 
         if (isTouchDown && TimeUtils.timeSinceMillis(touchDownTime) > 500) {
-            world.placeToBackground(cursorX,cursorY,1);
+            if (touchDownButton== Input.Buttons.RIGHT) {
+                world.placeToBackground(cursorX, cursorY,
+                        player.inventory[invSlot]);
+            } else if (touchDownButton==Input.Buttons.LEFT &&
+                    touchDownY< Assets.invBar.getRegionHeight() &&
+                    touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
+                    touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
+                renderer.showCreative = !renderer.showCreative;
+            }
             isTouchDown = false;
         }
     }