-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (42 loc) · 910 Bytes
/
main.cpp
File metadata and controls
45 lines (42 loc) · 910 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
#include <iostream>
#include "Snake.h"
#include "Game.h"
#include <ncurses.h>
using namespace std;
void initial();
int main()
{
Game myGame;
initial();
myGame.memu();
cbreak();
noecho();
nodelay(stdscr, TRUE);
while(!myGame.game_over())
{
myGame.render();
myGame.pilot_snake();
if(myGame.eat_apple())
{
myGame.gain_point();
myGame.produce_apple();
myGame.get_snake().extend_body();
}
}
nodelay(stdscr, FALSE);
printw("GAME OVER...");
getch();
endwin();
myGame.load_leaders();
myGame.write_record();
myGame.print_leader_board();
return 0;
}
void initial() /* 自定開啟 curses 函式 */
{
initscr();
nonl();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
}