Sistemate le chiamate al menu
This commit is contained in:
parent
5de7f55889
commit
94fd8c9aec
10 changed files with 32 additions and 14 deletions
BIN
build/game.o
BIN
build/game.o
Binary file not shown.
BIN
build/gui.o
BIN
build/gui.o
Binary file not shown.
BIN
build/input.o
BIN
build/input.o
Binary file not shown.
BIN
build/main.o
BIN
build/main.o
Binary file not shown.
BIN
build/shooter
BIN
build/shooter
Binary file not shown.
|
|
@ -20,10 +20,13 @@ enum {
|
|||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
//extern char* choices[];
|
||||
#define START_MODE 0
|
||||
#define GMOVR_MODE 1
|
||||
#define PAUSE_MODE 2
|
||||
|
||||
/* initialization and screens */
|
||||
void init_colors(void);
|
||||
int print_menu(WINDOW* win);
|
||||
int print_menu(WINDOW* win, int mode);
|
||||
void print_gameover(WINDOW* win);
|
||||
void print_win_screen(WINDOW* win);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
int game_run(void) {
|
||||
WINDOW *game_window = NULL;
|
||||
int height, width, win_startx, win_starty;
|
||||
char *pause_msg = "PAUSA: premi q per uscire dal gioco...";
|
||||
char *pause_msg = "PAUSE...";
|
||||
int pause = 0;
|
||||
int auto_shoot = 0;
|
||||
|
||||
|
|
|
|||
19
src/gui.c
19
src/gui.c
|
|
@ -3,12 +3,6 @@
|
|||
|
||||
/************** FUNZIONI GUI ***************/
|
||||
|
||||
static char *choices[] = {
|
||||
"Start Game",
|
||||
"Exit",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char* title[] =
|
||||
{
|
||||
"###########################################################################################################",
|
||||
|
|
@ -52,8 +46,19 @@ void init_colors() {
|
|||
init_pair(WINSC_PAIR, COLOR_YELLOW, COLOR_BLACK);
|
||||
}
|
||||
|
||||
static char *choices[] = {
|
||||
"",
|
||||
"Exit",
|
||||
NULL,
|
||||
};
|
||||
// FUNCTION THAT PRINTS THE MENU
|
||||
int print_menu(WINDOW* win) {
|
||||
int print_menu(WINDOW* win, int mode) {
|
||||
switch(mode) {
|
||||
case START_MODE : choices[0] = "Start Game"; break;
|
||||
case PAUSE_MODE: choices[0] = "Continue"; break;
|
||||
case GMOVR_MODE: choices[0] = ""; break;
|
||||
defualt: choices[0] = "Start Game"; break;
|
||||
}
|
||||
int height;
|
||||
int width;
|
||||
int ch;
|
||||
|
|
|
|||
16
src/input.c
16
src/input.c
|
|
@ -1,4 +1,5 @@
|
|||
#include "../include/input.h"
|
||||
#include "../include/gui.h"
|
||||
#include <ncurses.h>
|
||||
|
||||
/* Returns 1 to continue, 0 if quit requested (player inactive). */
|
||||
|
|
@ -22,9 +23,18 @@ int process_input(int input,
|
|||
}
|
||||
} else if (input == 'p') {
|
||||
*pause = !(*pause);
|
||||
} else if (input == 'q') {
|
||||
/* signal to caller to quit by marking player inactive */
|
||||
return 0;
|
||||
|
||||
int choice = print_menu(stdscr, PAUSE_MODE);
|
||||
|
||||
switch(choice) {
|
||||
case 0: {
|
||||
werase(stdscr);
|
||||
mvprintw(LINES-1, 1, "p per pausa");
|
||||
*pause = !(*pause);
|
||||
break;
|
||||
}
|
||||
case 1: return 0; break;
|
||||
}
|
||||
} else if (input == 'g') {
|
||||
*auto_shoot = !(*auto_shoot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ int main(void) {
|
|||
init_colors();
|
||||
|
||||
/* show menu */
|
||||
int choice = print_menu(stdscr);
|
||||
int choice = print_menu(stdscr, START_MODE);
|
||||
|
||||
switch(choice) {
|
||||
case 0: {
|
||||
werase(stdscr);
|
||||
mvprintw(1, 1, "p per pausa, q per uscire");
|
||||
mvprintw(LINES-1, 1, "p per pausa");
|
||||
refresh();
|
||||
game_run();
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue