forked from LindseyB/AsciiAsciiRevolution
-
Notifications
You must be signed in to change notification settings - Fork 1
/
input.d
79 lines (65 loc) · 1.44 KB
/
input.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module input;
import ncurses;
import selectScreen;
import levelScreen;
import tango.core.Thread;
import types;
import tango.io.stream.TextFile;
import AAR;
bool listenforkey = true;
bool levelInput(SelectScreen screen, WINDOW* win){
int key;
clear();
screen.drawScreen();
refresh();
while((key = getch()) != ERR){
if(key == Key.Enter){
screen.selectLevel();
break;
}else if(key == Key.UpArrow){
screen.up();
}else if(key == Key.DownArrow){
screen.down();
}else if(key == 'q'){
return false;
}
clear();
screen.drawScreen();
refresh();
}
return true;
}
class Shitz {
LevelScreen _s;
WINDOW* _win;
bool _killGame;
this(LevelScreen s, WINDOW* win){
_s = s;
_win = win;
_killGame = false;
}
void callMyShit() {
levelInput(_s, _win);
}
}
void levelInput(LevelScreen screen, WINDOW* win){
int key;
while((key = getch()) != ERR && listenforkey){
if(key == Key.UpArrow) {
screen._arrowSect._input |= 4;
screen._dancingMan.setCurAnimation(Animate.UP);
} else if (key == Key.DownArrow) {
screen._arrowSect._input |= 8;
screen._dancingMan.setCurAnimation(Animate.DOWN);
} else if (key == Key.LeftArrow) {
screen._arrowSect._input |= 1;
screen._dancingMan.setCurAnimation(Animate.LEFT);
} else if (key == Key.RightArrow) {
screen._arrowSect._input |= 2;
screen._dancingMan.setCurAnimation(Animate.RIGHT);
} else if (key == 'q') {
userquit = true;
// do nothing.
}
}
}