-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
51 lines (49 loc) · 933 Bytes
/
Copy pathMain.cpp
File metadata and controls
51 lines (49 loc) · 933 Bytes
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
/*
* =====================================================================================
*
* Filename: Main.cpp
*
* Description:
*
* Version: 1.0
* Created: 2012/3/27 ÐÇÆÚ¶þ 9:53:40
* Revision: none
* Compiler: gcc
*
* Author: Python (),
* Company:
*
* =====================================================================================
*/
#include "Snake.h"
#include <conio.h>
int main(void) {
SnakeMap *map = new SnakeMap();
Food *food = new Food(map);
map->print();
char keydown;
Snake *snake = new Snake(map,food);
snake->print();
while(true) {
if(snake->move()) {
food->createFood();
snake->print();
Sleep(200);
if(kbhit()) {
keydown = getch();
snake->changePoint(keydown);
}
}
else {
break;
}
}
delete food;
food = 0;
delete snake;
snake = 0;
delete map;
map = 0;
system("PAUSE");
return 0;
}