-
Notifications
You must be signed in to change notification settings - Fork 6
/
backupDancer.d
59 lines (51 loc) · 2.21 KB
/
backupDancer.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
module backupDancer;
import tango.math.random.Random;
import animatedAsciiSprite;
class BackupDancer {
enum Animate { DOWN, JUMP, LEFT, MOONWALK, RIGHT, UP, YMCA, THRUSTLEFT, THRUSTRIGHT, DISCO }
AnimatedAsciiSprite[10] _animations;
Animate _curAnimation;
this(int x, int y) {
_animations[Animate.DOWN] = new AnimatedAsciiSprite("graphics/man-down.txt", null, true, true, x, y);
_animations[Animate.JUMP] = new AnimatedAsciiSprite("graphics/man-jump.txt", null, true, true, x, y);
_animations[Animate.LEFT] = new AnimatedAsciiSprite("graphics/man-left.txt", null, true, true, x, y);
_animations[Animate.MOONWALK] = new AnimatedAsciiSprite("graphics/man-moonwalk.txt", null, true, true, x, y);
_animations[Animate.RIGHT] = new AnimatedAsciiSprite("graphics/man-right.txt", null, true, true, x, y);
_animations[Animate.UP] = new AnimatedAsciiSprite("graphics/man-up.txt", null, true, true, x, y);
_animations[Animate.YMCA] = new AnimatedAsciiSprite("graphics/man-ymca.txt", null, true, true, x, y);
_animations[Animate.THRUSTLEFT] = new AnimatedAsciiSprite("graphics/man-thrust-left.txt", null, true, true, x, y);
_animations[Animate.THRUSTRIGHT] = new AnimatedAsciiSprite("graphics/man-thrust-right.txt", null, true, true, x, y);
_animations[Animate.DISCO] = new AnimatedAsciiSprite("graphics/man-disco.txt", null, true, true, x, y);
}
void setCurAnimation(Animate animation) {
_curAnimation = animation;
}
void animate() {
if(_animations[_curAnimation]._frame == _animations[_curAnimation]._animation.length - 1){
int random = rand.uniformR(10);
switch(random) {
case 0: _curAnimation = Animate.DOWN;
break;
case 1: _curAnimation = Animate.JUMP;
break;
case 2: _curAnimation = Animate.MOONWALK;
break;
case 3: _curAnimation = Animate.RIGHT;
break;
case 4: _curAnimation = Animate.UP;
break;
case 5: _curAnimation = Animate.THRUSTLEFT;
break;
case 6: _curAnimation = Animate.THRUSTRIGHT;
break;
case 7: _curAnimation = Animate.DISCO;
break;
case 8: _curAnimation = Animate.LEFT;
break;
default: _curAnimation = Animate.YMCA;
}
}
_animations[_curAnimation].drawSprite();
_animations[_curAnimation].nextFrame();
}
}