-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonster.cpp
59 lines (52 loc) · 1.07 KB
/
monster.cpp
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
#include "monster.h"
std::mt19937 Object::rng;
event Monster::action(int input) {
std::uniform_int_distribution<int> dist(0, 8);
auto dir = Direction(dist(rng));
return try_to(MOVE, dir);
}
Player::Player() {
symbol = '@';
color = MAGENTA;
msg[MOVE][FAIL] = "Ouch!";
msg[PICK_UP][SUCCESS] = "You got it!";
}
event Player::action(int input) {
switch (input) {
// movement keys
case '1':
return try_to(MOVE, DOWNLEFT);
break;
case KEY_DOWN:
case '2':
return try_to(MOVE, DOWN);
break;
case '3':
return try_to(MOVE, DOWNRIGHT);
case KEY_LEFT:
case '4':
return try_to(MOVE, LEFT);
break;
case KEY_RIGHT:
case '6':
return try_to(MOVE, RIGHT);
break;
case '7':
return try_to(MOVE, UPLEFT);
case KEY_UP:
case '8':
return try_to(MOVE, UP);
break;
case '9':
return try_to(MOVE, UPRIGHT);
case ',':
return try_to(PICK_UP);
break;
}
return try_to(WAIT);
}
Feline::Feline() {
symbol = 'f';
color = YELLOW;
msg[MOVE][FAIL] = "meow";
}