-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.tpp
107 lines (93 loc) · 2.2 KB
/
test.tpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <string>
#include <iostream>
#include <ncurses.h>
#include "position.hpp"
void read_in_map(){
// for (std::string line; std::getline(std::cin, line); ){
// map.push_back(std::vector<unsigned char>());
// maxw = std::max(line.size(), maxw);
// y_cache = map.size()-1;
// for (unsigned char c : line) {
// switch(c) {
// case '@':
// playerpos = Pos(map[y_cache].size(), y_cache);
// map[y_cache].push_back(Map::EMPTY);
// break;
// case '$':
// boxes.push_back(Pos(map[y_cache].size(), y_cache));
// map[y_cache].push_back(Map::EMPTY);
// break;
// case ' ':
// map[y_cache].push_back(Map::EMPTY);
// break;
// case '#':
// map[y_cache].push_back(Map::WALL);
// break;
// case '+':
// playerpos = Pos(map[y_cache].size(), y_cache);
// map[y_cache].push_back(Map::GOAL);
// break;
// case '*':
// boxes.push_back(Pos(map[y_cache].size(), y_cache));
// map[y_cache].push_back(Map::GOAL);
// break;
// case '.':
// map[y_cache].push_back(Map::GOAL);
// break;
// default:
// exit(1);
// break;
// }
// }
// }
}
int main()
{
std::string map[] = {
"#####################",
"# #",
"# #",
"# #",
"# #",
"# #",
"# #",
"# #",
"#####################"
};
bool game_over = false;
int x = 5, y = 5;
initscr(); /* Start curses mode */
curs_set(0);
keypad(stdscr, TRUE);
for(int i = 0; i < 9; i++)
printw("%s\n", map[i].c_str());
while(!game_over){
move(y, x);
printw("@");
refresh(); /* Print it on to the real screen */
int key = getch(); /* Wait for user input */
move(y, x);
printw(" ");
switch(key){
case KEY_DOWN:
y++;
break;
case KEY_UP:
y--;
break;
case KEY_LEFT:
x--;
break;
case KEY_RIGHT:
x++;
break;
case 'Q': case 'q':
game_over = true;
break;
default:
break;
}
}
endwin(); /* End curses mode */
return 0;
}