forked from KMUlee/SnakeGameWithCPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (63 loc) · 1.86 KB
/
main.cpp
File metadata and controls
78 lines (63 loc) · 1.86 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <ncurses.h>
#include <cstring>
#include <iostream>
#include <cstring>
#include "Game.hpp"
#define N 22
#define M 40
void mainMenu() {
char *menu_1 = " _____ __ ______";
char *menu_2 = " / ___/____ ____ _/ /_____ / ____/___ _____ ___ ___";
char *menu_3 = " \\__ \\/ __ \\/ __ `/ //_/ _ \\ / / __/ __ `/ __ `__ \\/ _ \\";
char *menu_4 = " ___/ / / / / /_/ / ,< / __/ / /_/ / /_/ / / / / / / __/";
char *menu_5 = " /____/_/ /_/\\__,_/_/|_|\\___/ \\____/\\__,_/_/ /_/ /_/\\___/";
//print snake game
mvprintw(2, 0, "%s", menu_1);
mvprintw(3, 0, "%s", menu_2);
mvprintw(4, 0, "%s", menu_3);
mvprintw(5, 0, "%s", menu_4);
mvprintw(6, 0, "%s", menu_5);
//print select menu
mvprintw(11, 30, "PRESS THE SPACEBAR");
mvprintw(15, 37, "START");
mvprintw(17, 37, "HOW TO");
mvprintw(19, 37, "EXIT");
}
int main(){
int mode = 0, offset = 15;
int keyNum, start = 0;;
Game game(N, M);
initscr();
resize_term(24, 80);
curs_set(false);
noecho();
nodelay(stdscr, TRUE);
keypad(stdscr, TRUE);
while(true) {
clear();
mainMenu();
mvprintw(offset + (mode * 2), 33, "->");
keyNum = getch();
switch (keyNum) {
case KEY_UP:
mode = (mode == 0) ? 2 : mode - 1;
break;
case KEY_DOWN:
mode = (mode == 2) ? 0 : mode + 1;
break;
case 32:
if (mode == 2) {
endwin();
return 0;
}
start = 1;
break;
}
if(start) {
game.setMode(mode);
game.gameInit(start);
start = game.GameStart();
}
}
return 0;
}