diff drawObj/resources/keyboard.js @ 4:86eb5933aeb9

fix keyboard.js
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Apr 2012 19:17:56 +0900
parents d17004426a74
children
line wrap: on
line diff
--- a/drawObj/resources/keyboard.js	Sun Apr 15 19:03:54 2012 +0900
+++ b/drawObj/resources/keyboard.js	Sun Apr 15 19:17:56 2012 +0900
@@ -1,7 +1,22 @@
 function keyboardDown()
 {
-
-
+    var d=-Z/20;
+    switch(String.fromCharCode(event.keyCode)) {
+	case 'w':
+	Z+=d;
+	break;
+	case 'a':
+	X-=d;
+	break;
+	case 's':
+	Z-=d;
+	break;
+	case 'd':
+	X+=d;
+	break;
+	default:
+	break;
+    }
 }
 
 function keyboardUp()
@@ -12,6 +27,22 @@
 
 function keyboardPress()
 {
-
+    var d=-Z/20;
+    switch(String.fromCharCode(event.keyCode)) {
+	case 'w':
+	Z+=d;
+	break;
+	case 'a':
+	X-=d;
+	break;
+	case 's':
+	Z-=d;
+	break;
+	case 'd':
+	X+=d;
+	break;
+	default:
+	break;
+    }
 
 }
\ No newline at end of file