diff --git a/Makefile b/Makefile index 9096af5..173a3db 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: rc edit rc: rc.c shared.c rc.h shared.h globals.h defs.h - gcc -Wall -o rc -g rc.c shared.c -L/Users/rob/c/rc/libs `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer + gcc -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer edit: edit.c shared.c edit.h shared.h globals.h defs.h gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf diff --git a/data/world1/level1.dat b/data/world1/level1.dat index 9114758..592a33b 100644 --- a/data/world1/level1.dat +++ b/data/world1/level1.dat @@ -2,6 +2,7 @@ bgfile forest.png bg 0 hurryup 30 help +Press Z to clear help messages Use X to jump, Z to catch the rat. Then use Down+Z to slam and kill a monster! endhelp @@ -26,6 +27,7 @@ monsters 15 34 19 16 35 19 17 36 19 +14 17 19 endmonsters exitdir 1 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, diff --git a/defs.h b/defs.h index caa0b34..8522fa8 100644 --- a/defs.h +++ b/defs.h @@ -55,6 +55,12 @@ #define TEXTSIZE_PAUSED 50 #define TEXTSIZE_GAMEOVER 50 + +// text tuypes +#define TT_NORM 0 +#define TT_HELP 1 +#define TT_HELPSHADOW 2 + // text delays #define TEXTSPEED 2 // how fast text zooms in @@ -461,6 +467,7 @@ #define LV_NEXTLEV 7 // cloud done , nextlevel() in 5 seconds #define LV_GAMEOVER 8 // No lives left. #define LV_DOPOKER 9 // Got a full set of cards! +#define LV_HELPFREEZE 10 // Freeze after help text // movement types #define MV_NONE 0 // didn't move @@ -562,6 +569,7 @@ typedef struct text_s { int size; int maxsize; int state; + int type; int delay; // how long to stay on screen char txt[BUFLEN]; SDL_Rect bgarea; diff --git a/rc.c b/rc.c index 8564223..f3979f9 100644 --- a/rc.c +++ b/rc.c @@ -286,7 +286,7 @@ int main (int argc, char **argv) { * check for end of level */ if (levelcomplete == LV_CLEAR) { - addoutlinetext(320,240,TEXTSIZE_LEVEL,"Level Complete!",&green,&black,LEVELWINDELAY); + addoutlinetext(320,240,TEXTSIZE_LEVEL,"Level Complete!",&green,&black,LEVELWINDELAY, TT_NORM); levelcomplete = LV_WAIT; playfx(FX_WINLEVEL); // turn off clock and water powerups @@ -377,14 +377,18 @@ int main (int argc, char **argv) { } } } else { // all other states... - // move sprites - moveallsprites(); + if (levelcomplete != LV_HELPFREEZE) { + // move sprites + moveallsprites(); + } } /********************************************** * Move onscreen text */ - movetext(); + if (levelcomplete != LV_HELPFREEZE) { + movetext(); + } /********************************************** @@ -422,6 +426,7 @@ int main (int argc, char **argv) { } break; case LV_DOPOKER: // do nothing + case LV_HELPFREEZE: // do nothing break; } } @@ -459,7 +464,7 @@ int main (int argc, char **argv) { /********************************************** * Collision detection */ - if (levelcomplete != LV_DOPOKER) { + if ((levelcomplete != LV_DOPOKER) && (levelcomplete != LV_HELPFREEZE)) { checkcollideall(); } } @@ -471,18 +476,18 @@ int main (int argc, char **argv) { */ // player netting - if (levelcomplete != LV_DOPOKER) { + if ((levelcomplete != LV_DOPOKER) && (levelcomplete != LV_HELPFREEZE)) { drawnetting(player); } // cannon firing - if ((levelcomplete != LV_DOPOKER) && (player->powerup == PW_CANNONFIRE)) { // cannon firing + if ((levelcomplete != LV_DOPOKER) && (levelcomplete != LV_HELPFREEZE) && (player->powerup == PW_CANNONFIRE)) { // cannon firing docannoneffect(); } // draw sprites - if (levelcomplete != LV_DOPOKER) { + if ((levelcomplete != LV_DOPOKER) && (levelcomplete != LV_HELPFREEZE)) { drawallsprites(); } @@ -507,6 +512,15 @@ int main (int argc, char **argv) { drawsprite(this); } } + } else if (levelcomplete == LV_HELPFREEZE) { + SDL_Rect area; + + area.x = 0; + area.y = 0; + area.w = 640; + area.h = 480; + // clear screen + SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); } // draw text @@ -639,6 +653,7 @@ void tick(void) { SDL_framerateDelay(&manager); if (paused) return; + if (levelcomplete == LV_HELPFREEZE) return; fpsticks = SDL_GetTicks(); if (fpsstart == 0) { @@ -655,7 +670,7 @@ void tick(void) { // text if (clocktime > 0) { sprintf(tempm, "%d",clocktime); - addoutlinetext(320,120,TEXTSIZE_LEVEL, tempm, &yellow,&black,15); + addoutlinetext(320,120,TEXTSIZE_LEVEL, tempm, &yellow,&black,15, TT_NORM); // sound effect playfx(FX_CLOCK); } @@ -676,7 +691,7 @@ void tick(void) { // text if (watertime > 0) { sprintf(tempm, "%d",watertime); - addoutlinetext(320,120,TEXTSIZE_LEVEL, tempm, &cyan,&black,15); + addoutlinetext(320,120,TEXTSIZE_LEVEL, tempm, &cyan,&black,15, TT_NORM); } // never reach hurryup time nexthurryup++; @@ -710,7 +725,7 @@ void tick(void) { } - addoutlinetext(320,240,TEXTSIZE_HURRY, "Hurry up!", &yellow,&black,HURRYDELAY); + addoutlinetext(320,240,TEXTSIZE_HURRY, "Hurry up!", &yellow,&black,HURRYDELAY, TT_NORM); stopmusic(); Mix_PlayChannel(CH_HURRYUP, sfx[FX_HURRYUP], 0); @@ -718,7 +733,7 @@ void tick(void) { } else if (gtime == nexthurryup + 15) { // 15 secs after hurryup if (!levelcomplete) { addsprite(P_BLACKCLOUD, 320,240,"cloud"); - addoutlinetext(320,240,TEXTSIZE_HURRY, "Too slow!", &red,&black,HURRYDELAY); + addoutlinetext(320,240,TEXTSIZE_HURRY, "Too slow!", &red,&black,HURRYDELAY, TT_NORM); playfx(FX_TOOSLOW); } } @@ -863,11 +878,11 @@ void nextlevel(void) { level->icey = -1; sprintf(msg, "Level %d-%d",getcurworld(), getcurlevel()); - addoutlinetext(320,240-18,TEXTSIZE_LEVEL,msg,&white,&black,LEVELDELAY); + addoutlinetext(320,240-18,TEXTSIZE_LEVEL,msg,&white,&black,LEVELDELAY, TT_NORM); sprintf(msg, "\"%s\"", curlevel->name); - addoutlinetext(320,240+18,TEXTSIZE_LEVEL2,msg,&cyan,&black,LEVELDELAY); + addoutlinetext(320,240+18,TEXTSIZE_LEVEL2,msg,&cyan,&black,LEVELDELAY, TT_NORM); /* reset player stats */ player->netting = B_FALSE; @@ -1031,7 +1046,7 @@ void die(sprite_t *s) { // draw text tnum = rand() % MAXDEATHTEXT; - addoutlinetext(player->x,player->y,TEXTSIZE_DEATH,deathtext[tnum],&red,&black,DIEDELAY); + addoutlinetext(player->x,player->y,TEXTSIZE_DEATH,deathtext[tnum],&red,&black,DIEDELAY, TT_NORM); } } @@ -1247,7 +1262,7 @@ void checkcollide(sprite_t *s) { playfx(FX_KILL); sprintf(tempm, bifftext[rand() % MAXBIFFTEXT]); - addoutlinetext(s2->x,s2->y - s->img->h/2, TEXTSIZE_BIFF, tempm,&red,&yellow,POINTSDELAY); + addoutlinetext(s2->x,s2->y - s->img->h/2, TEXTSIZE_BIFF, tempm,&red,&yellow,POINTSDELAY, TT_NORM); keepchecking = B_FALSE; } else if (s2->iced) { @@ -1680,7 +1695,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n"); (ydiff <= player->img->h/2 + newsp->img->h/2)) { // bonus! getfruit(player, newsp, 4); - addoutlinetext(player->x,player->y - (player->img->h*1.5), TEXTSIZE_MULTI, "Nice catch!", &green,&black,MULTIDELAY); + addoutlinetext(player->x,player->y - (player->img->h*1.5), TEXTSIZE_MULTI, "Nice catch!", &green,&black,MULTIDELAY, TT_NORM); } } @@ -3330,7 +3345,7 @@ double getspeed(sprite_t *s ) { } -int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay) { +int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay, int ttype) { text_t *t; if (text == NULL) { @@ -3351,6 +3366,7 @@ int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay) { screen->format->Gmask,screen->format->Bmask, screen->format->Amask); + t->type = ttype; t->c = c; t->x = x; t->y = y; @@ -3383,12 +3399,22 @@ void fruit(void) { void movetext(void) { text_t *t,*nextt; + int newhelpfreeze = B_FALSE; + for (t = text ; t ; t = nextt) { nextt = t->next; if (t->state == 0) { t->size += TEXTSPEED; if (t->size >= t->maxsize) { - t->state = 1; + if (t->type == TT_HELP) { + // freeze + oldlevelcomplete = levelcomplete; + levelcomplete = LV_HELPFREEZE; + t->state = t->delay; + newhelpfreeze = B_TRUE; + } else { + t->state = 1; + } } } else if (t->state == t->delay) { t->size -= TEXTSPEED; @@ -3400,6 +3426,15 @@ void movetext(void) { t->state++; } } + + if (newhelpfreeze) { + // expire delay on all help text + for (t = text ; t ; t = t->next) { + if (t->type == TT_HELPSHADOW) { + t->state = t->delay; + } + } + } } void drawbosshealth(void) { @@ -3511,42 +3546,44 @@ void drawtext(void) { SDL_Rect area; for (t = text ; t ; t = t->next) { + if ((levelcomplete != LV_HELPFREEZE) || (t->type == TT_HELP)) { - /* create text */ - if (t->img) { - SDL_FreeSurface(t->img); - t->img = NULL; - } - t->img = TTF_RenderText_Solid(font[t->size], t->txt, *t->c); + /* create text */ + if (t->img) { + SDL_FreeSurface(t->img); + t->img = NULL; + } + t->img = TTF_RenderText_Solid(font[t->size], t->txt, *t->c); - // make sure it's on the screen (leave space for border) - if (t->x - (t->img->w / 2) < 2) { // left - t->x = 2 + (t->img->w/2); - } - if (t->x + (t->img->w / 2) > 640-2) { // right - t->x = 640-2 - (t->img->w/2); - } - if (t->y - (t->img->h / 2) < 2) { // top - t->y = 2 + (t->img->h/2); - } - if (t->y + (t->img->h / 2) > 480-2) { // bottom - t->y = 480-2 - (t->img->h/2); - } + // make sure it's on the screen (leave space for border) + if (t->x - (t->img->w / 2) < 2) { // left + t->x = 2 + (t->img->w/2); + } + if (t->x + (t->img->w / 2) > 640-2) { // right + t->x = 640-2 - (t->img->w/2); + } + if (t->y - (t->img->h / 2) < 2) { // top + t->y = 2 + (t->img->h/2); + } + if (t->y + (t->img->h / 2) > 480-2) { // bottom + t->y = 480-2 - (t->img->h/2); + } - /* get bg */ - t->bgarea.x = t->x - t->img->w/2; - t->bgarea.y = t->y - t->img->h/2; - t->bgarea.w = t->img->w; - t->bgarea.h = t->img->h; - SDL_BlitSurface(screen, &t->bgarea, t->bg, NULL); - - /* draw text */ - area.x = t->x - t->img->w/2; - area.y = t->y - t->img->h/2; - area.w = t->img->w; - area.h = t->img->h; - SDL_BlitSurface(t->img,NULL, screen, &area); + /* get bg */ + t->bgarea.x = t->x - t->img->w/2; + t->bgarea.y = t->y - t->img->h/2; + t->bgarea.w = t->img->w; + t->bgarea.h = t->img->h; + SDL_BlitSurface(screen, &t->bgarea, t->bg, NULL); + + /* draw text */ + area.x = t->x - t->img->w/2; + area.y = t->y - t->img->h/2; + area.w = t->img->w; + area.h = t->img->h; + SDL_BlitSurface(t->img,NULL, screen, &area); + } } @@ -4129,18 +4166,22 @@ void dogravity(sprite_t *s) { s->netlen += s->netspeed; s->netting++; if (s->netting % 2 == 0) { - if (s->netspeed > -NETSPEED) s->netspeed--; - else { - if (s->netlen <= 0) { - s->netting = 0; - adjustx(s, F_WALK1); - for (s2 = sprite ; s2 ; s2 = s2->next) { - if ((s2->caughtby == s) && (s2->caughtstate == C_NETTING)) { - s2->caughtstate = C_NETTED; - } + if (s->netspeed == 0) { + printf("maxlen %d\n",s->netlen); + } + if (s->netspeed > -NETSPEED) { + s->netspeed--; + } else { + if (s->netlen <= 0) { + s->netting = 0; + adjustx(s, F_WALK1); + for (s2 = sprite ; s2 ; s2 = s2->next) { + if ((s2->caughtby == s) && (s2->caughtstate == C_NETTING)) { + s2->caughtstate = C_NETTED; } } } + } } } else if (s->slamming) { int netx,nety; @@ -4434,7 +4475,7 @@ void dogravity(sprite_t *s) { } if (pointsinc > 250) { sprintf(tempm, "%d",pointsinc); - addoutlinetext(xnet,ynet-TILEH, psize, tempm, &white,&black,POINTSDELAY); + addoutlinetext(xnet,ynet-TILEH, psize, tempm, &white,&black,POINTSDELAY, TT_NORM); /* give points to player */ //s->score += pointsinc; addscore(s, pointsinc); @@ -4567,13 +4608,13 @@ int dofruiteffect(sprite_t *s) { if (s->id == P_SPEED) { playfx(FX_POWERUP); player->speed = PLAYERFAST; - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, "Speed up!", &white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, "Speed up!", &white,&black,POINTSDELAY, TT_NORM); return B_TRUE; } else if (s->id == P_BIGSPEED) { playfx(FX_POWERUP); player->permspeed = B_TRUE; player->speed = PLAYERFAST; - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_LIFE, "SUPER SPEED UP!", &cyan,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_LIFE, "SUPER SPEED UP!", &cyan,&black,POINTSDELAY, TT_NORM); return B_TRUE; } else if (s->id == P_NUMNETS) { playfx(FX_POWERUP); @@ -4581,13 +4622,13 @@ int dofruiteffect(sprite_t *s) { player->netmax++; } sprintf(tempm, "%d nets!",player->netmax); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_BIGNET) { playfx(FX_POWERUP); player->netbig = B_TRUE; sprintf(tempm, "Big net!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_TROPHY) { // all powerups @@ -4596,46 +4637,46 @@ int dofruiteffect(sprite_t *s) { player->netbig = B_TRUE; // big net player->speed = 2; // fast sprintf(tempm, "Full power!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_MASKPOWERUP) { playfx(FX_POWERUP); player->hasmask = B_TRUE; sprintf(tempm, "Scuba Mask!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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 playfx(FX_BELL); // different sound effect player->hasbell = B_TRUE; sprintf(tempm, "Powerup Detector!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_RINGGOLD) { // points for walking playfx(FX_POWERUP); player->powerup = PW_RINGWALK; sprintf(tempm, "Walk Ring!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_RINGSILVER) { // points for walking playfx(FX_POWERUP); player->powerup = PW_RINGJUMP; sprintf(tempm, "Jump Ring!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_MACEPOWERUP) { playfx(FX_POWERUP); player->powerup = PW_MACE; sprintf(tempm, "Mace Slam!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_BOXING) { playfx(FX_POWERUP); player->powerup = PW_BOXING; sprintf(tempm, "Boxing Glove!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_HELMET) { int xx,yy; @@ -4643,7 +4684,7 @@ int dofruiteffect(sprite_t *s) { player->id = P_ARMOUR; // change how the player looks player->armour = B_TRUE; sprintf(tempm, "Armour!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); // add puffs for (xx = s->x - TILEW; xx <= s->x + TILEW; xx += TILEW) { for (yy = s->y - TILEW*2; yy <= s->y; yy += TILEH) { @@ -4659,14 +4700,14 @@ int dofruiteffect(sprite_t *s) { player->gemboost = 3; } sprintf(tempm, "Bonus x%d!",player->gemboost); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_FTODIAMOND) { sprite_t *s2, *nexts; // convert all flowers to diamonds playfx(FX_MORPH); sprintf(tempm, "Make diamonds!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); for (s2 = sprite; s2 ; s2 = nexts) { nexts = s2->next; if (isflower(s2->id)) { @@ -4690,7 +4731,7 @@ int dofruiteffect(sprite_t *s) { // convert all flowers to gems playfx(FX_MORPH); sprintf(tempm, "Make gems!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); for (s2 = sprite; s2 ; s2 = nexts) { nexts = s2->next; if (isflower(s2->id)) { @@ -4746,7 +4787,7 @@ int dofruiteffect(sprite_t *s) { player->powerup = PW_CLOCK; clocktime = CLOCKTIME; sprintf(tempm, "Freeze time!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); // pause music Mix_PauseMusic(); return B_TRUE; @@ -4754,7 +4795,7 @@ int dofruiteffect(sprite_t *s) { // flood level playfx(FX_FLOOD); sprintf(tempm, "Flood!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&blue,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&blue,&black,POINTSDELAY, TT_NORM); if (!curlevel->iced) { curlevel->iced = WATER_INPROGRESS; curlevel->icey = LEVELH-1; @@ -4766,7 +4807,7 @@ int dofruiteffect(sprite_t *s) { // ice playfx(FX_FREEZE); sprintf(tempm, "Blizzard!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&cyan,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&cyan,&black,POINTSDELAY, TT_NORM); if (!curlevel->iced) { curlevel->iced = ICE_INPROGRESS; curlevel->icey = 0; @@ -4776,7 +4817,7 @@ int dofruiteffect(sprite_t *s) { // flyspray playfx(FX_SPRAY); sprintf(tempm, "Fly Spray!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); player->powerup = PW_SPRAYUP; sprayalpha = 0; return B_TRUE; @@ -4784,7 +4825,7 @@ int dofruiteffect(sprite_t *s) { // flyspray playfx(FX_POWERUP); sprintf(tempm, "Fusion Cannon"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); player->powerup = PW_CANNON; puffin(P_CANNON, player->x, player->y,"cannon", 0); return B_TRUE; @@ -4792,7 +4833,7 @@ int dofruiteffect(sprite_t *s) { playfx(FX_POWERUP); player->netsticky = B_TRUE; sprintf(tempm, "Sticky net!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_LIFE) { extralife(player); @@ -4804,11 +4845,11 @@ int dofruiteffect(sprite_t *s) { if (isbosslevel(curlevelnum + 1)) { playfx(FX_ENGAGED); sprintf(tempm, "Engaged"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); } else { playfx(FX_PHONE); sprintf(tempm, "Telephone!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); // set powerup player->powerup = PW_PHONE; skiplevels = 1; @@ -4835,7 +4876,7 @@ int dofruiteffect(sprite_t *s) { playfx(FX_POWERUP); sprintf(tempm, "Meteor Shower!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); wid = imageset[P_METEOR].img[0]->w; hei = imageset[P_METEOR].img[0]->h; for (n = 0; n < 7; n++) { @@ -4875,7 +4916,7 @@ int dofruiteffect(sprite_t *s) { } playfx(FX_STAR); sprintf(tempm, "Shuriken!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + 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_BOMB) { @@ -4888,7 +4929,7 @@ int dofruiteffect(sprite_t *s) { // kill all monsters playfx(FX_BOOM); sprintf(tempm, "KABOOM!!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_BOMB, tempm,&red,&yellow,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_BOMB, tempm,&red,&yellow,POINTSDELAY, TT_NORM); for (s2 = sprite; s2 ; s2 = nexts) { nexts = s2->next; if (isbullet(s2->id)) { @@ -4908,7 +4949,7 @@ int dofruiteffect(sprite_t *s) { } else if (s->id == P_SHIELD) { playfx(FX_POWERUP); sprintf(tempm, "Shield!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); // temp invincibility player->invuln = SHIELDTIME; @@ -4917,7 +4958,7 @@ int dofruiteffect(sprite_t *s) { } else if (s->id == P_HELP) { playfx(FX_POWERUP); // TODO: move other HELP text around if need be! - addoutlinetext(320,240,TEXTSIZE_HELP, s->name, &white,&black,HELPDELAY); + addoutlinetext(320,240,TEXTSIZE_HELP, s->name, &white,&black,HELPDELAY,TT_HELP); return B_TRUE; } else if (iscard(s->id)) { if (player->numcards < MAXCARDS) { @@ -4928,7 +4969,7 @@ int dofruiteffect(sprite_t *s) { // show text sprintf(tempm, getcardname(s->id)); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); // add a "card" effect. it will move slowly towards the corner. newc = addsprite(P_MOVINGCARD,s->x, s->y, "moving_card"); @@ -4946,7 +4987,7 @@ int dofruiteffect(sprite_t *s) { newc->img = imageset[s->timer1].img[F_WALK1]; } else { // is this possible?! - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, "Full cards!",&red,&black,POINTSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, "Full cards!",&red,&black,POINTSDELAY,TT_NORM); } return B_TRUE; } else if (isflower(s->id)) { @@ -4992,7 +5033,7 @@ int dofruiteffect(sprite_t *s) { } playfx(FX_BONUS); sprintf(tempm, "BONUS!"); - addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_BONUS, tempm,&white,&black,BONUSDELAY); + addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_BONUS, tempm,&white,&black,BONUSDELAY,TT_NORM); return B_TRUE; } } @@ -5240,16 +5281,22 @@ void dumpsprites(void) { printf("\n\n"); } -void addoutlinetext(int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol, int delay) { - addtext(x-1,y,size,msg,bgcol,delay); // outline - addtext(x-1,y-1,size,msg,bgcol,delay); // outline - addtext(x,y-1,size,msg,bgcol,delay); // outline - addtext(x+1,y-1,size,msg,bgcol,delay); // outline - addtext(x+1,y,size,msg,bgcol,delay); // outline - addtext(x+1,y+1,size,msg,bgcol,delay); // outline - addtext(x,y+1,size,msg,bgcol,delay); // outline - addtext(x-1,y+1,size,msg,bgcol,delay); // outline - addtext(x,y,size,msg,col,delay); // main text +void addoutlinetext(int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol, int delay, int ttype) { + int shadowtype; + if (ttype == TT_HELP) { + shadowtype = TT_HELPSHADOW; + } else { + shadowtype = TT_NORM; + } + addtext(x-1,y,size,msg,bgcol,delay,shadowtype); // outline + addtext(x-1,y-1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x,y-1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x+1,y-1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x+1,y,size,msg,bgcol,delay,shadowtype); // outline + addtext(x+1,y+1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x,y+1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x-1,y+1,size,msg,bgcol,delay,shadowtype); // outline + addtext(x,y,size,msg,col,delay,ttype); // main text } char *addcommas(char *buffer, int num) { @@ -5301,7 +5348,7 @@ void addscore(sprite_t *s, int amt) { void extralife(sprite_t *which) { playfx(FX_LIFE); which->lives += 1; - addoutlinetext(which->x,which->y - which->img->h/2, TEXTSIZE_LIFE, "Extra life!",&green,&black,LIFEDELAY); + addoutlinetext(which->x,which->y - which->img->h/2, TEXTSIZE_LIFE, "Extra life!",&green,&black,LIFEDELAY,TT_NORM); } // slowly change level to ice @@ -5436,7 +5483,7 @@ void checksprites(void) { // then show hiscores // then back to title screen } else { - addoutlinetext(320,240,TEXTSIZE_GAMEOVER,"Game Over",&red,&black,GAMEOVERDELAY); + addoutlinetext(320,240,TEXTSIZE_GAMEOVER,"Game Over",&red,&black,GAMEOVERDELAY,TT_NORM); levelcomplete = LV_GAMEOVER; stopmusic(); playfx(FX_GAMEOVER); @@ -5637,10 +5684,10 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) { playfx(FX_FRUIT); if (multiplier <= 1) { sprintf(tempm, "%d", gotscore); - addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS, tempm, &white,&black,POINTSDELAY); + addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS, tempm, &white,&black,POINTSDELAY,TT_NORM); } else { sprintf(tempm, "%d x %d" , gotscore,multiplier); - addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS + 2*multiplier, tempm, &white,&black,POINTSDELAY); + addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS + 2*multiplier, tempm, &white,&black,POINTSDELAY,TT_NORM); } } } @@ -5833,8 +5880,8 @@ void gaincard(sprite_t *s, int cardid) { getpokermsg2(pokereffect, msg); // display BIG message - addoutlinetext(320,180,TEXTSIZE_POKER,getpokermsg(pokereffect),&green, &black, POKERDELAY); - addoutlinetext(320,290,TEXTSIZE_POKER,msg,&green, &black, POKERDELAY); + addoutlinetext(320,180,TEXTSIZE_POKER,getpokermsg(pokereffect),&green, &black, POKERDELAY,TT_NORM); + addoutlinetext(320,290,TEXTSIZE_POKER,msg,&green, &black, POKERDELAY,TT_NORM); // pause music Mix_PauseMusic(); @@ -6199,12 +6246,12 @@ void dopokereffect(sprite_t *pl, int effect) { // points addscore(pl, pokerpoints); sprintf(tempmsg, "%d",pokerpoints); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); break; case PE_TRIPLE: // skip 3 levels sprintf(tempmsg, "Skip 3 levels!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); // set powerup player->powerup = PW_PHONE; skiplevels = 2; @@ -6228,12 +6275,12 @@ void dopokereffect(sprite_t *pl, int effect) { pl->permsticky = B_TRUE; pl->netsticky = B_TRUE; sprintf(tempmsg, "Permenant sticky net!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); break; case PE_FLUSH: // skip 5 levels sprintf(tempmsg, "Skip 5 levels!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); // set powerup player->powerup = PW_PHONE; skiplevels = 4; @@ -6257,19 +6304,19 @@ void dopokereffect(sprite_t *pl, int effect) { pl->permbignet = B_TRUE; pl->netbig = B_TRUE; sprintf(tempmsg, "Permenant Big Nets!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); break; case PE_FOUR: // permenant max nets pl->permnumnets = B_TRUE; pl->netmax = 4; sprintf(tempmsg, "Permenant Max Nets!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); break; case PE_STRAIGHTFLUSH: // skip 7 levels sprintf(tempmsg, "Skip 7 levels!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); // set powerup player->powerup = PW_PHONE; skiplevels = 6; @@ -6297,7 +6344,7 @@ void dopokereffect(sprite_t *pl, int effect) { pl->netbig = B_TRUE; pl->netmax = 4; sprintf(tempmsg, "Permenant full power!"); - addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY); + addoutlinetext(pl->x,pl->y - pl->img->h/2, TEXTSIZE_BONUS, tempmsg,&cyan,&black,POKERMSGDELAY,TT_NORM); break; } } @@ -6401,9 +6448,29 @@ int getcardvalue(int cardid) { void handleinput(void) { int i; + SDL_Event event; + + if (levelcomplete == LV_HELPFREEZE) { + // handle keys differently + // we only care about a single keyup event + + SDL_PumpEvents(); + while (SDL_PollEvent(&event)) { + if (event.type == SDL_KEYUP) { + if (event.key.keysym.sym == SDLK_z) { + levelcomplete = oldlevelcomplete; + } + } + } + // TODO: handle joystick buttonpress!! + + return; + } + /* check for keys */ SDL_PumpEvents(); + keys = SDL_GetKeyState(NULL); // check for joystick @@ -6435,7 +6502,7 @@ void handleinput(void) { player->speed = 2; // fast player->netsticky = B_TRUE; sprintf(tempm, "Cheat!"); - addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY); + addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); toggletimer = 80; } } @@ -6496,7 +6563,7 @@ void handleinput(void) { // kill all monsters playfx(FX_BOOM); sprintf(tempm, "KABOOM!!"); - addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_BOMB, tempm,&red,&yellow,POINTSDELAY); + addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_BOMB, tempm,&red,&yellow,POINTSDELAY,TT_NORM); for (s2 = sprite; s2 ; s2 = nexts) { nexts = s2->next; if (isbullet(s2->id)) { @@ -6585,6 +6652,9 @@ void handleinput(void) { } } } + // ignore other events + while (SDL_PollEvent(&event)) { + } } diff --git a/rc.h b/rc.h index 92c642a..a2c3c4f 100644 --- a/rc.h +++ b/rc.h @@ -1,6 +1,6 @@ void cleanup(void); -int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay); -void addoutlinetext(int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol, int delay); +int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay, int ttype); +void addoutlinetext(int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol, int delay, int ttype); void drawscore(void); void drawbosshealth(void); void drawtext(void);