Permalink
Browse files

Added types.d to store specific enum types and added the loop for the

keyboard input.
  • Loading branch information...
1 parent 33d0845 commit 679b4417bdb877c43565a7d29b841ea39ecc26db @LindseyB LindseyB committed Oct 24, 2010
Showing with 36 additions and 8 deletions.
  1. +1 −1 dancingMan.d
  2. +23 −7 input.d
  3. +12 −0 types.d
View
2 dancingMan.d
@@ -1,9 +1,9 @@
module dancingMan;
import animatedAsciiSprite;
+import types;
class DancingMan {
- enum Animate { DOWN, LEFT, MOONWALK, RIGHT, UP, YMCA }
AnimatedAsciiSprite[6] _animations;
Animate _curAnimation;
View
30 input.d
@@ -2,15 +2,10 @@ module input;
import ncurses;
import selectScreen;
+import levelScreen;
import tango.core.Thread;
+import types;
-enum Key{
- Enter = 10,
- DownArrow = 258,
- UpArrow = 259,
- LeftArrow = 260,
- RightArrow = 261
-}
bool levelInput(SelectScreen screen, WINDOW* win){
int key;
@@ -40,3 +35,24 @@ bool levelInput(SelectScreen screen, WINDOW* win){
return true;
}
+bool levelInput(LevelScreen screen, WINDOW* win){
+ int key;
+
+ clear();
+
+ while((key = getch()) != ERR){
+ if(key == Key.UpArrow) {
+ screen._dancingMan.setCurAnimation(Animate.UP);
+ } else if (key == Key.DownArrow) {
+ screen._dancingMan.setCurAnimation(Animate.DOWN);
+ } else if (key == Key.LeftArrow) {
+ screen._dancingMan.setCurAnimation(Animate.LEFT);
+ } else if (key == Key.RightArrow) {
+ screen._dancingMan.setCurAnimation(Animate.RIGHT);
+ } else if (key == 'q') {
+ return false;
+ }
+
+ return true;
+ }
+}
View
12 types.d
@@ -0,0 +1,12 @@
+module types;
+
+enum Key{
+ Enter = 10,
+ DownArrow = 258,
+ UpArrow = 259,
+ LeftArrow = 260,
+ RightArrow = 261
+}
+
+
+enum Animate { DOWN, LEFT, MOONWALK, RIGHT, UP, YMCA }

0 comments on commit 679b441

Please sign in to comment.