Allowed the player to continue the game upon losing all lifes (asked with a menu). Continues are kept track of, may be used later to implement the traditional no-good-end-with-continues.

This commit is contained in:
Akari 2011-07-02 12:39:36 +03:00
parent a2a6fb9343
commit 29b12b6253
5 changed files with 65 additions and 3 deletions

View file

@ -33,6 +33,7 @@ set(SRCs
menu/menu.c
menu/mainmenu.c
menu/ingamemenu.c
menu/gameovermenu.c
menu/difficulty.c
menu/charselect.c
stages/stage0.c

46
src/menu/gameovermenu.c Normal file
View file

@ -0,0 +1,46 @@
#include "menu.h"
#include "gameovermenu.h"
#include "global.h"
void continue_game(void *arg)
{
printf("The game is being continued...\n");
create_item(global.plr.pos, 6-15*I, Power);
create_item(global.plr.pos, -6-15*I, Power);
global.plr.pos = VIEWPORT_W/2 + VIEWPORT_H*I;
global.plr.recovery = -(global.frames + 150);
if(global.plr.bombs < 3)
global.plr.bombs = 3;
global.plr.lifes = 2;
global.plr.continues += 1;
delete_projectiles(&global.projs);
delete_projectiles(&global.particles);
}
void give_up(void *arg) {
global.game_over = GAMEOVER_ABORT;
}
MenuData *create_gameover_menu() {
MenuData *m = malloc(sizeof(MenuData));
create_menu(m);
if(global.plr.continues)
{
char s[256];
sprintf(s, "Continue (%i)", global.plr.continues);
add_menu_entry(m, s, continue_game, NULL);
}
else
add_menu_entry(m, "Continue", continue_game, NULL);
add_menu_entry(m, "Give up", give_up, NULL);
return m;
}

9
src/menu/gameovermenu.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef GAMEOVERMENU_H
#define GAMEOVERMENU_H
#include "menu.h"
MenuData *create_gameover_menu();
#endif

View file

@ -11,6 +11,7 @@
#include "projectile.h"
#include "global.h"
#include "plrmodes.h"
#include "menu/gameovermenu.h"
void init_player(Player* plr, Character cha, ShotMode shot) {
memset(plr, 0, sizeof(Player));
@ -25,6 +26,8 @@ void init_player(Player* plr, Character cha, ShotMode shot) {
plr->deathtime = -1;
plr->continues = 0;
switch(cha) {
case Youmu:
plr->ani = get_ani("youmu");
@ -146,7 +149,8 @@ void plr_realdeath(Player *plr) {
plr->deathtime = -1;
if(plr->lifes-- == 0) {
game_over();
//game_over();
global.menu = create_gameover_menu();
} else {
create_item(plr->pos, 6-15*I, Power);
create_item(plr->pos, -6-15*I, Power);
@ -167,4 +171,4 @@ void plr_death(Player *plr) {
create_particle2c("blast", plr->pos, rgb(1,0.5,0.3), GrowFade, timeout, 35, 2.4);
plr->deathtime = global.frames + DEATHBOMB_TIME;
}
}
}

View file

@ -47,6 +47,8 @@ typedef struct {
int deathtime;
int continues;
Character cha;
ShotMode shot;
Enemy *slaves;
@ -64,4 +66,4 @@ void plr_set_power(Player *plr, float npow);
void plr_bomb(Player*);
void plr_realdeath(Player*);
void plr_death(Player*);
#endif
#endif