Aggiunto schermo di vittoria
This commit is contained in:
parent
8eab9d9c54
commit
e12d4188d0
1 changed files with 49 additions and 0 deletions
49
main.c
49
main.c
|
|
@ -4,12 +4,15 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <curses.h>
|
||||||
|
#include <menu.h>
|
||||||
|
|
||||||
/************* STATIC DEFINITIONS ************/
|
/************* STATIC DEFINITIONS ************/
|
||||||
// Game constants
|
// Game constants
|
||||||
#define ENEMY_N 5
|
#define ENEMY_N 5
|
||||||
#define BULLET_N 3
|
#define BULLET_N 3
|
||||||
#define LIVES_N 5
|
#define LIVES_N 5
|
||||||
|
#define WIN_PTS 100
|
||||||
|
|
||||||
// Window constants
|
// Window constants
|
||||||
#define DELAY 30000
|
#define DELAY 30000
|
||||||
|
|
@ -25,6 +28,7 @@
|
||||||
#define BONUS_PAIR 2
|
#define BONUS_PAIR 2
|
||||||
#define TITLE_PAIR 3
|
#define TITLE_PAIR 3
|
||||||
#define GMOVR_PAIR 4
|
#define GMOVR_PAIR 4
|
||||||
|
#define WINSC_PAIR 5
|
||||||
|
|
||||||
/************* GAME STRUCTURES **************/
|
/************* GAME STRUCTURES **************/
|
||||||
struct speed {
|
struct speed {
|
||||||
|
|
@ -71,6 +75,15 @@ char* gameover[] =
|
||||||
|
|
||||||
char gameover_desc[] = "HAI PERSO. Premi q per uscire...";
|
char gameover_desc[] = "HAI PERSO. Premi q per uscire...";
|
||||||
|
|
||||||
|
char* win_screen[] =
|
||||||
|
{
|
||||||
|
"o8 o8 o8888o o8 8o o8 8o o8888o o8 8o",
|
||||||
|
"88 o8 88 888 88 88 oo 88 88 88 888o88",
|
||||||
|
"888 88 888 88 88 88/\\88 88 88 888",
|
||||||
|
"888 088880 088880 8888 088880 88 88"
|
||||||
|
};
|
||||||
|
char win_desc[] = "HAI VINTO. Premi q per uscire...";
|
||||||
|
|
||||||
void print_menu(WINDOW* win) {
|
void print_menu(WINDOW* win) {
|
||||||
// Ottieni parametri della finestra
|
// Ottieni parametri della finestra
|
||||||
int height;
|
int height;
|
||||||
|
|
@ -120,6 +133,32 @@ void print_gameover(WINDOW* win) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_win_screen(WINDOW* win) {
|
||||||
|
// Parametri della finestra e pulisci tutto
|
||||||
|
int height;
|
||||||
|
int width;
|
||||||
|
int ch;
|
||||||
|
wclear(win);
|
||||||
|
getmaxyx(win, height, width);
|
||||||
|
|
||||||
|
// Stampa della scritta colorata
|
||||||
|
wattron(win, COLOR_PAIR(WINSC_PAIR));
|
||||||
|
for(int i = 0; i < TEXTLINES; i++) {
|
||||||
|
mvwprintw(win, i+1, (width-(strlen(win_screen[0])))/2, "%s", win_screen[i]);
|
||||||
|
}
|
||||||
|
wattroff(win, COLOR_PAIR(WINSC_PAIR));
|
||||||
|
|
||||||
|
// Stampa della scritta che blinka
|
||||||
|
wattron(win, A_BLINK);
|
||||||
|
mvwprintw(win, TEXTLINES+1, (width-(strlen(win_desc)))/2, "%s", win_desc);
|
||||||
|
wattroff(win, A_BLINK);
|
||||||
|
|
||||||
|
// Stampa a video e attendi input
|
||||||
|
refresh();
|
||||||
|
while((ch = wgetch(win)) != 'q');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void print_status_bar(WINDOW* main_win, int y, int x, struct status game_status) {
|
void print_status_bar(WINDOW* main_win, int y, int x, struct status game_status) {
|
||||||
int status_x = x + 1;
|
int status_x = x + 1;
|
||||||
int status_y = y;
|
int status_y = y;
|
||||||
|
|
@ -181,6 +220,7 @@ int main() {
|
||||||
init_pair(TITLE_PAIR, COLOR_MAGENTA, COLOR_BLACK);
|
init_pair(TITLE_PAIR, COLOR_MAGENTA, COLOR_BLACK);
|
||||||
init_pair(GMOVR_PAIR, COLOR_RED, COLOR_BLACK);
|
init_pair(GMOVR_PAIR, COLOR_RED, COLOR_BLACK);
|
||||||
init_pair(BONUS_PAIR, COLOR_GREEN, COLOR_BLACK);
|
init_pair(BONUS_PAIR, COLOR_GREEN, COLOR_BLACK);
|
||||||
|
init_pair(WINSC_PAIR, COLOR_YELLOW, COLOR_BLACK);
|
||||||
|
|
||||||
// Dimensioni finestra di gioco e controlli
|
// Dimensioni finestra di gioco e controlli
|
||||||
// calcolo delle misure della finestra
|
// calcolo delle misure della finestra
|
||||||
|
|
@ -278,6 +318,10 @@ int main() {
|
||||||
enemy[i].active = 0;
|
enemy[i].active = 0;
|
||||||
bullet[j].active = 0;
|
bullet[j].active = 0;
|
||||||
game_status.score++;
|
game_status.score++;
|
||||||
|
if(game_status.score == WIN_PTS) {
|
||||||
|
player.active = 0;
|
||||||
|
print_win_screen(stdscr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -320,6 +364,10 @@ int main() {
|
||||||
enemy[i].active = 0;
|
enemy[i].active = 0;
|
||||||
bullet[j].active = 0;
|
bullet[j].active = 0;
|
||||||
game_status.score++;
|
game_status.score++;
|
||||||
|
if(game_status.score == WIN_PTS) {
|
||||||
|
player.active = 0;
|
||||||
|
print_win_screen(stdscr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -378,3 +426,4 @@ int main() {
|
||||||
printf("Gioco terminato.\n");
|
printf("Gioco terminato.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue