From 48aece7927ba18ac6804b0a49825e44a9cdca707 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 23 Dec 2008 01:18:18 +0000 Subject: [PATCH] Powerup detector now changes colour based on powerup type. --- rc.c | 30 ++++++++++++++++++++++++++++-- shared.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ shared.h | 3 +++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/rc.c b/rc.c index 5324f79..886ce3e 100644 --- a/rc.c +++ b/rc.c @@ -624,10 +624,30 @@ int main (int argc, char **argv) { * after sprite movement */ if ((player && player->hasbell) || (player2 && player2->hasbell)) { + int dobell = B_FALSE; + SDL_Color fcol; /* check for bell sound */ /* play a bell sound if the powerup will be a permenant one */ if (ispermenant(level->poweruptype)) { + // flash white + dobell = B_TRUE; + fcol.r = 255; fcol.g = 255; ; fcol.b = 255; + } else if (isabilitypowerup(level->poweruptype)) { + // flash green + dobell = B_TRUE; + fcol.r = 0; fcol.g = 255; ; fcol.b = 0; + } else if (iswinpowerup(level->poweruptype)) { + // flash red + dobell = B_TRUE; + fcol.r = 255; fcol.g = 0; ; fcol.b = 0; + } else if (isbadpowerup(level->poweruptype)) { + // flash purple + dobell = B_TRUE; + fcol.r = 255; fcol.g = 0; ; fcol.b = 255; + } + + if (dobell) { // play sound once if (!playedbell) { playfx(FX_BELL); @@ -642,12 +662,14 @@ int main (int argc, char **argv) { area.y = 0; area.w = 640; area.h = 480; - SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,white.r,white.g,white.b)); + SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,fcol.r,fcol.g,fcol.b)); flip(); } } } + } + // camera flash if ((globpowerup == PW_CAMERA) && (cameraalpha)) { @@ -8090,7 +8112,11 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) { addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); return B_TRUE; } else if (s->id == P_BELL) { - // all powerups + // powerup detector - makes the level flash depending on what power up will appear. + // white = permenant + // green = temporary ability + // red = instawin + // purple = bad playfx(FX_BELL); // different sound effect pp->hasbell = B_TRUE; sprintf(tempm, "Powerup Detector!"); diff --git a/shared.c b/shared.c index cebaf6b..bfd16ad 100644 --- a/shared.c +++ b/shared.c @@ -2566,6 +2566,53 @@ int isflower(int id) { return B_FALSE; } +/* returns B_TRUE if the given powerup is one which + gives the player a special ability */ +int isabilitypowerup(int id) { + switch (id) { + case P_BOXING: + case P_MACEPOWERUP: + case P_SHIELD: + case P_RINGSILVER: + case P_RINGGOLD: + case P_CLOVER: + case P_ACCORDION: + case P_ZAPPOWERUP: + case P_GUN: + case P_CANNONPOWERUP: + case P_MAGNET: + case P_JETPACK: + case P_PILL: + case P_RAYGUN: + return B_TRUE; + } + return B_FALSE; +} + + + +int isbadpowerup(int id) { + switch (id) { + case P_SKULL: + case P_BADMAGNET: + return B_TRUE; + } + return B_FALSE; +} + + +/* returns B_TRUE if the given powerup is one which + will or could effectively win the level */ +int iswinpowerup(int id) { + switch (id) { + case P_BOMB: + case P_PHONE: + case P_WAND: + return B_TRUE; + } + return B_FALSE; +} + int isfruit(int id) { switch (id) { /* fruits */ diff --git a/shared.h b/shared.h index 1e7c4c5..5b1c3cf 100644 --- a/shared.h +++ b/shared.h @@ -67,6 +67,9 @@ int isplayer(sprite_t *s); int isplayer(sprite_t *s); int playersalive(void); int getnumplayers(void); +int isbadpowerup(int id); +int iswinpowerup(int id); +int isabilitypowerup(int id); // for doco void setfruitinfo(void); void setinfo(int id, char *name, char *desc, char *file);