Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

keyboard input.
  • Loading branch information...
commit 679b4417bdb877c43565a7d29b841ea39ecc26db 1 parent 33d0845
Lindsey Bieda LindseyB authored
Showing with 36 additions and 8 deletions.
  1. +1 −1  dancingMan.d
  2. +23 −7 input.d
  3. +12 −0 types.d
2  dancingMan.d
View
@@ -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;
30 input.d
View
@@ -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;
+ }
+}
12 types.d
View
@@ -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 }
Please sign in to comment.
Something went wrong with that request. Please try again.