Commits

Anonymous committed 6525047

added movement

  • Participants
  • Parent commits feb2ad6

Comments (0)

Files changed (1)

src/main/java/net/fishbulb/jcod/demo/Fov.java

 package net.fishbulb.jcod.demo;
 
+import com.badlogic.gdx.Input;
 import com.badlogic.gdx.graphics.Color;
 import net.fishbulb.jcod.Console;
 import net.fishbulb.jcod.fov.Basic;
             }
         }
     }
+
+
+    private void moveTo(int x, int y) {
+        if (map[y].charAt(x) == ' ') {
+            console.putChar(px,py,' ',BlendMode.None);
+            px = x;
+            py = y;
+            console.putChar(px,py,'@',BlendMode.None);
+        }
+    }
+
+    @Override public boolean keyDown(int keyCode) {
+        switch (keyCode) {
+            case Input.Keys.W:
+                moveTo(px, py-1);
+                return true;
+            case Input.Keys.A:
+                moveTo(px-1, py);
+                return true;
+            case Input.Keys.S:
+                moveTo(px, py+1);
+                return true;
+            case Input.Keys.D:
+                moveTo(px+1, py);
+                return true;
+        }
+        return false;
+    }
 }