-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.cpp
71 lines (54 loc) · 1.48 KB
/
Main.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
#include "Header.hpp"
//#include "Fruit.hpp"
//g++ -O2 -std=c++17 header.h Source.cpp Main.cpp -o m
//g++ -std=c++17 header.h Snake.cpp Source.cpp Main.cpp -o m
//g++ -std=c++17 Header.hpp Snake.cpp Source.cpp Main.cpp -o m
int main()
{
char choice;
//System::welcome_screen(choice);
Timer timer;
Map::canvas = System::get_file_content("Map.txt");
Head::set_coord();
Fruit fruit;
int lives = 1;
int score = 0;
int difficulty = 0;
char key_pressed = MOVE_UP;
bool quit_game = false;
System::show_consol_cursor();
system("cls");
Map::print();
fruit.draw();
//set_console_size();
while (!(GetAsyncKeyState('Q')) && lives > 0)
{
timer.start();
//Sleep(difficulty);
if (_kbhit())
key_pressed = toupper(_getch());
Head::move(key_pressed);
if (Head::get_colision())
{
lives--;
}
else
{
Head::print();
Tail::move();
}
if (Head::get_coord() == fruit.get_coord())
{
Tail::increase_size();
Tail::move();
score += 10;
fruit.generate();
}
print_information(lives, score, timer);
}
System::update_map_to_print(fruit.get_position());
System::write_file();
System::gotoxy(0, Map::get_height() + 10);
system("cls");
return 0;
}