Allow use of credits to continue after all players are out of lives.

(will go back to the start of the world, and lose all points)
This commit is contained in:
Rob Pearce 2016-07-30 17:44:53 +12:00
parent 2cd7d417e7
commit ec44f15c35
5 changed files with 103 additions and 25 deletions

Binary file not shown.

7
defs.h
View File

@ -90,6 +90,8 @@
#define TEXTSIZE_HURRY 50 #define TEXTSIZE_HURRY 50
#define TEXTSIZE_PAUSED 50 #define TEXTSIZE_PAUSED 50
#define TEXTSIZE_GAMEOVER 50 #define TEXTSIZE_GAMEOVER 50
#define TEXTSIZE_CONTINUE 50
#define TEXTSIZE_CONTINUECOUNTER 50
#define TEXTSIZE_HISCORE 16 #define TEXTSIZE_HISCORE 16
#define TEXTSIZE_ENDING 16 #define TEXTSIZE_ENDING 16
#define TEXTSIZE_CREDITS 16 #define TEXTSIZE_CREDITS 16
@ -102,6 +104,8 @@
#define TT_INTROTEXT 3 #define TT_INTROTEXT 3
#define TT_GAMEOVER 4 #define TT_GAMEOVER 4
#define TT_ENDING 5 #define TT_ENDING 5
#define TT_CONTINUE 6
#define TT_CONTINUECOUNTER 7
// intro states // intro states
@ -141,6 +145,8 @@
#define ENDTEXTTIME 200 #define ENDTEXTTIME 200
#define GAMEOVERDELAY 200 #define GAMEOVERDELAY 200
#define CONTINUECOUNTERDELAY 20 // 1 sec
#define CONTINUEDELAY (CONTINUECOUNTERDELAY * 10 * 3) // 10 secs
#define POKERDELAY 170 #define POKERDELAY 170
#define ICEDRIPSPEED 0.5 #define ICEDRIPSPEED 0.5
@ -837,6 +843,7 @@ enum SPELL {
#define LV_GAMEOVER 8 // No lives left. #define LV_GAMEOVER 8 // No lives left.
#define LV_DOPOKER 9 // Got a full set of cards! #define LV_DOPOKER 9 // Got a full set of cards!
#define LV_HELPFREEZE 10 // Freeze after help text #define LV_HELPFREEZE 10 // Freeze after help text
#define LV_CONTINUE 11 // Asking player whether to use a credit to continue
// movement types // movement types
#define MV_NONE 0 // didn't move #define MV_NONE 0 // didn't move

85
rc.c
View File

@ -1641,7 +1641,6 @@ void nextlevel(void) {
/* in case we skipped the level due to a powerup etc */ /* in case we skipped the level due to a powerup etc */
levelcomplete = LV_NEXTLEV; levelcomplete = LV_NEXTLEV;
// disable "forcegold" (comes form magic lamp) unless we got // disable "forcegold" (comes form magic lamp) unless we got
// if on this level // if on this level
if (forcegold) { if (forcegold) {
@ -7480,6 +7479,18 @@ void movetext(void) {
} else if (t->state == t->delay) { } else if (t->state == t->delay) {
t->size -= TEXTSPEED; t->size -= TEXTSPEED;
if (t->size <= 3) { if (t->size <= 3) {
if ((t->type == TT_CONTINUECOUNTER) && (levelcomplete == LV_CONTINUE)) {
int num;
// next countdown.
num = atoi(t->txt);
if (num > 1) {
char buf[4];
sprintf(buf, "%d",num - 1);
addoutlinetext(320,240 + 50,TEXTSIZE_CONTINUECOUNTER,buf,&red,&black,CONTINUECOUNTERDELAY,TT_CONTINUECOUNTER);
} else {
startgameover();
}
}
if ((t->type == TT_GAMEOVER) && (levelcomplete == LV_GAMEOVER)) { if ((t->type == TT_GAMEOVER) && (levelcomplete == LV_GAMEOVER)) {
// start game over timer // start game over timer
gameovertime = gtime; gameovertime = gtime;
@ -10900,12 +10911,15 @@ void checksprites(void) {
} }
if (alldead) { if (alldead) {
if (levelcomplete != LV_GAMEOVER) { if ((levelcomplete != LV_GAMEOVER) && (levelcomplete != LV_CONTINUE)) {
// special type - when it expires, gameover timer will start if (credits >= 1) {
addoutlinetext(320,240,TEXTSIZE_GAMEOVER,"Game Over",&red,&black,GAMEOVERDELAY,TT_GAMEOVER); // start continue timer
levelcomplete = LV_GAMEOVER; addoutlinetext(320,240 - 50,TEXTSIZE_CONTINUE,"Continue?",&red,&black,CONTINUEDELAY,TT_CONTINUE);
stopmusic(); addoutlinetext(320,240 + 50,TEXTSIZE_CONTINUECOUNTER,"10",&red,&black,CONTINUECOUNTERDELAY,TT_CONTINUECOUNTER);
playfx(FX_GAMEOVER); levelcomplete = LV_CONTINUE;
} else {
startgameover();
}
} }
} }
} else { } else {
@ -12206,7 +12220,7 @@ if (cheat) {
sprintf(tempm, "Cheat!"); sprintf(tempm, "Cheat!");
if (player) { if (player) {
//player->powerup = PW_MAGNET; //player->powerup = PW_MAGNET;
player->powerup = PW_RAYGUN; player->lives = 2;
player->netmax = 4; // all nets player->netmax = 4; // all nets
player->netbig = B_TRUE; // big net player->netbig = B_TRUE; // big net
player->speed = PLAYERFAST; // fast player->speed = PLAYERFAST; // fast
@ -12214,8 +12228,8 @@ if (cheat) {
player->doublejump = B_TRUE; player->doublejump = B_TRUE;
player->hasbell = B_TRUE; player->hasbell = B_TRUE;
player->umbrella = B_TRUE; player->umbrella = B_TRUE;
player->armour = B_TRUE; //player->armour = B_TRUE;
player->id = P_ARMOUR; // change how the player looks //player->id = P_ARMOUR; // change how the player looks
player->hasmask = B_TRUE; player->hasmask = B_TRUE;
addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM);
} }
@ -12394,6 +12408,49 @@ if (cheat) {
} }
} }
} }
} else if (levelcomplete == LV_CONTINUE) {
int docontinue = B_FALSE;
if (keydown(0, SDLK_1)) {
if (player && (credits >= 1)) {
// lose credit and go back to start of world.
credits--;
if (player) {
playfx(FX_EXTRALIFE);
// go back to start of world
docontinue = B_TRUE;
}
}
}
if (keydown(0, SDLK_2)) {
if (player2 && (credits >= 1)) {
// lose credit and go back to start of world.
credits--;
if (player2) {
playfx(FX_EXTRALIFE);
// go back to start of world
docontinue = B_TRUE;
}
}
}
if (docontinue) {
// one before the level we want to go to
curlevelnum = (curlevelnum / 20) * 20;
// set player defaults
if (player) {
setdefaults(player);
player->lives = INITPLAYERLIVES;
player->score = 0;
}
if (player2) {
setdefaults(player2);
player2->lives = INITPLAYERLIVES;
player2->score = 0;
}
nextlevel();
}
} }
@ -13419,6 +13476,14 @@ void startgame(void) {
timer = 0; timer = 0;
} }
void startgameover(void) {
// special type - when it expires, gameover timer will start
addoutlinetext(320,240,TEXTSIZE_GAMEOVER,"Game Over",&red,&black,GAMEOVERDELAY,TT_GAMEOVER);
levelcomplete = LV_GAMEOVER;
stopmusic();
playfx(FX_GAMEOVER);
}
void uncatch(sprite_t *s) { void uncatch(sprite_t *s) {
if (s->caughtby) { if (s->caughtby) {

1
rc.h
View File

@ -102,6 +102,7 @@ void trytoshoot(sprite_t *pl);
void docannoneffect(sprite_t *pp); void docannoneffect(sprite_t *pp);
void dotitlescreen(void); void dotitlescreen(void);
void startgame(void); void startgame(void);
void startgameover(void);
void uncatch(sprite_t *s); void uncatch(sprite_t *s);
void makeinvuln(sprite_t *s); void makeinvuln(sprite_t *s);
void handletitleinput(int whichplayer, int key); void handletitleinput(int whichplayer, int key);

33
todo
View File

@ -1,28 +1,33 @@
- animate players hanging from umbrellas ? - animate players hanging from umbrellas ?
- if drawing a score text on the same location as another score text,
delay it by a little ?
- make points worth chasing for something more than a high schore - make points worth chasing for something more than a high schore
- bonus level teleport appears on next level once you - bonus level teleport appears on next level once you
reach a certain amount of points ? reach a certain amount of points ?
Figure out POINT VALUES? Test games to figure out good point values.
1-13 - 233k Level 1-13 - 233k points
Cutoffs for special stuff:
500k? 500k?
1m? 1m?
5m?
15m?
30m?
- bonus levels: - bonus levels which give Diamonds which give random effect:
..triple walk speed? - triple walk speed
..spike boots to jump on monsters - spike boots to jump on monsters
..50% chance to skip two levels each time? - from now on, 50% chance to skip two levels each time
.. shortcut to skip directly to start of next world? - shortcut to skip directly to start of next world
- Collecting all the diamonds gives something special ?
- Make level editor work again in opengl - Make level editor work again in opengl
- add help to level editor! - add help to level editor!
- top left tile is always blank?? - why is top left tile is always blank?
- New powerups: - New powerups:
- until end of level - until end of level
@ -37,8 +42,7 @@
- Draw graphics for between-level sequences. - Draw graphics for between-level sequences.
- draw and scan ? - draw and scan ?
- had a plan for this somewhere, i think in an old omnioutliner doc PLAN:
CODE:
- [ ] instrad of cloud coming, wipe screen - [ ] instrad of cloud coming, wipe screen
- [ ] moviescript(): - [ ] moviescript():
- [ ] picture filename - [ ] picture filename
@ -116,6 +120,8 @@
l 86 - earlier (dificulty easier than other castle levels before it) l 86 - earlier (dificulty easier than other castle levels before it)
delay animated spikes until at least world 2 ?
- New tiles - New tiles
- destroyable tile - destroyable tile
- when a net hits it, it explodes into 4 pieces. don't come back. - when a net hits it, it explodes into 4 pieces. don't come back.
@ -127,13 +133,12 @@
- falling icicle (regrows) - falling icicle (regrows)
- for snow world
- secret levels/worlds - secret levels/worlds
- totally underwater with currents towards spikes - totally underwater with currents towards spikes
- all moving platforms - all moving platforms
- Make 'credits' let you continue... but from the start of the world and with 0 points
- sound delays after long play - sound delays after long play
- new level ideas - new level ideas