-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (41 loc) · 1.17 KB
/
main.cpp
File metadata and controls
53 lines (41 loc) · 1.17 KB
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
#include <iostream>
#include <thread>
#include <chrono>
#include <cstring>
#include "src/Listen_Draw.hpp"
#include "src/Essentials.hpp"
#include "src/Field.hpp"
#include "src/Global.h"
void loop(){
Field field(10, 10);
bool running = true;
auto dir = RIGHT;
while (running) {
char c = key_listener();
if(c == 'w'){ dir = UP; }
else if(c == 'a'){ dir = LEFT; }
else if(c == 's'){ dir = DOWN; }
else if(c == 'd'){ dir = RIGHT; }
field.check_and_set(dir);
if( c == 'x' || field.flag()){ running = false; }
draw(field, running);
std::this_thread::sleep_for(std::chrono::milliseconds(game_speed));
}
}
int main(int argc, char* argv[]) {
for(int i=1; i<argc; i++){
if(strcmp(argv[i], "--speed") == 0){
i++;
game_speed = (strcmp(argv[i], "slow") == 0) ? 700 : (strcmp(argv[i], "fast") == 0) ? 300 : 500;
}
else if(strcmp(argv[i], "--dynamic") == 0){
dynamic_speed = true;
}
else{
std::cout << "Unknown command";
exit(1);
}
}
loop();
return 0;
}