Skip to content

Commit

Permalink
Added types.d to store specific enum types and added the loop for the
Browse files Browse the repository at this point in the history
keyboard input.
  • Loading branch information
LindseyB committed Oct 24, 2010
1 parent 33d0845 commit 679b441
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dancingMan.d
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
30 changes: 23 additions & 7 deletions input.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 changes: 12 additions & 0 deletions types.d
Original file line number Diff line number Diff line change
@@ -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.