-
Notifications
You must be signed in to change notification settings - Fork 1
/
runner.cpp
74 lines (57 loc) · 1.32 KB
/
runner.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <curses.h>
#include <cstdlib>
#include <ctime>
#define bRead(value, bit) (((value) >> (bit)) & 0x01)
#define cactus '|'
#define player '@'
void sleep(int);
void init();
int main() {
init();
int map = 0, plry = 10, score = 0, asd = 2;
while (true) {
if (!bRead(map, 1) && !bRead(map, 2) && !bRead(map, 3) && !bRead(map, 4) && !bRead(map, 5)) map |= 1UL;
if (plry < 10) {
if (asd) asd -= 1;
else {
asd = 2;
mvwaddch(stdscr, plry, 14, ' ');
++plry;
}
}
if (getch() == KEY_UP && plry >= 9) {
mvwaddch(stdscr, plry, 14, ' ');
--plry;
}
if (plry == 10 && bRead(map, 28)) break;
if (bRead(map, 29)) ++score;
move(10, 11);
for (int j = 31; j >= 0; --j) {
waddch(stdscr, (bRead(map, j) ? cactus | COLOR_PAIR(1) : ' '));
}
mvwaddch(stdscr, plry, 14, player);
mvwaddch(stdscr, 5, 42, cactus | COLOR_PAIR(1));
wprintw(stdscr, " - %d", score);
map <<= 1;
refresh();
sleep(150);
}
sleep(2000);
endwin();
return 0;
}
void sleep(int mseconds) {
clock_t startClock = clock();
while(clock() < startClock + (((float)mseconds / 1000) * CLOCKS_PER_SEC));
}
void init() {
srand(static_cast<unsigned int>(time(NULL)));
initscr();
start_color();
init_pair(1, COLOR_GREEN, 0);
curs_set(false);
keypad(stdscr, true);
nodelay(stdscr, true);
noecho();
}
//By B.S.M