- Added "Easy Mode" - gives more lives, longer time limit before hurryup, longer invulnerability at start

This commit is contained in:
Rob Pearce 2008-10-19 22:58:54 +00:00
parent b08cdd3eae
commit f39e2ef53a
6 changed files with 174 additions and 41 deletions

10
defs.h
View File

@ -45,6 +45,7 @@
#define TEXTSIZE_CLOVER 20 #define TEXTSIZE_CLOVER 20
#define TEXTSIZE_DEATH 20 #define TEXTSIZE_DEATH 20
#define TEXTSIZE_TITLE 20 #define TEXTSIZE_TITLE 20
#define TEXTSIZE_TITLE2 16
#define TEXTSIZE_LEVEL2 22 #define TEXTSIZE_LEVEL2 22
#define TEXTSIZE_BIFF 26 #define TEXTSIZE_BIFF 26
#define TEXTSIZE_MULTI 26 #define TEXTSIZE_MULTI 26
@ -473,6 +474,14 @@
#define F_SWIM2 17 #define F_SWIM2 17
// Title screen states
#define TS_WAITKEY 0
#define TS_SELECTMODE 1
// Game modes
#define GM_EASY 0
#define GM_NORM 1
// Level states // Level states
#define LV_INIT 5 // just loaded, waiting for monsters to appear #define LV_INIT 5 // just loaded, waiting for monsters to appear
#define LV_INPROGRESS 0 // regular game play #define LV_INPROGRESS 0 // regular game play
@ -766,6 +775,7 @@ extern level_t *curlevel;
extern tiletype_t fakeblock; extern tiletype_t fakeblock;
extern int gtime; extern int gtime;
extern int timer; extern int timer;
extern int gamemode;
extern SDL_Color red; extern SDL_Color red;
extern SDL_Color black; extern SDL_Color black;
extern SDL_Color blue; extern SDL_Color blue;

View File

@ -9,6 +9,8 @@ int numlevels;
int maxlevid; int maxlevid;
int gamemode; // easy or hard?
spriteinfo_t spriteinfo[MAXPTYPES]; spriteinfo_t spriteinfo[MAXPTYPES];
char *datadir; char *datadir;

188
rc.c
View File

@ -105,6 +105,7 @@ int pokerpoints;
SDL_Color red = {255, 0, 0, 0}; SDL_Color red = {255, 0, 0, 0};
SDL_Color red2 = {150, 0, 0, 0};
SDL_Color orange = {255, 167, 88, 1}; SDL_Color orange = {255, 167, 88, 1};
SDL_Color black = {0, 0, 0, 0}; SDL_Color black = {0, 0, 0, 0};
SDL_Color blue = {0, 0, 255, 0}; SDL_Color blue = {0, 0, 255, 0};
@ -842,7 +843,7 @@ void nextlevel(void) {
drawlevel(); drawlevel();
// now the player gets invincibility // now the player gets invincibility
player->invuln = INVULNTIME; makeinvuln(player);
// phone is cancelled on boss levels // phone is cancelled on boss levels
if (player->powerup == PW_PHONE) { if (player->powerup == PW_PHONE) {
@ -1048,7 +1049,7 @@ void die(sprite_t *s) {
player->armour = B_FALSE; player->armour = B_FALSE;
player->id = P_PLAYER; player->id = P_PLAYER;
// become invulnerable temporarily // become invulnerable temporarily
player->invuln = INVULNTIME; makeinvuln(player);
// bounce back // bounce back
player->recoiling = B_TRUE; player->recoiling = B_TRUE;
jump(player, -player->dir); jump(player, -player->dir);
@ -1064,7 +1065,7 @@ void die(sprite_t *s) {
} }
player->powerup = B_FALSE; player->powerup = B_FALSE;
nexthurryup = gtime + level->hurryuptime; resethurryup(curlevel);
if (curmusic == fastmusic) { if (curmusic == fastmusic) {
playmusic(normalmusic); playmusic(normalmusic);
} }
@ -2804,7 +2805,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
if (s->size <= 0.2) { if (s->size <= 0.2) {
s->dead = D_FINAL; s->dead = D_FINAL;
/* reset hurryup timer */ /* reset hurryup timer */
nexthurryup = gtime + level->hurryuptime; resethurryup(curlevel);
} else { } else {
SDL_Surface *ts, *cloudim; SDL_Surface *ts, *cloudim;
//printf("shrink\n"); //printf("shrink\n");
@ -5613,7 +5614,7 @@ void checksprites(void) {
setdefaults(s); setdefaults(s);
s->x = (curlevel->p1x * TILEW) + (TILEW/2); s->x = (curlevel->p1x * TILEW) + (TILEW/2);
s->y = (curlevel->p1y * TILEH) + (TILEH/2); s->y = (curlevel->p1y * TILEH) + (TILEH/2);
s->invuln = INVULNTIME; makeinvuln(player);
} else { } else {
if (levelcomplete != LV_GAMEOVER) { if (levelcomplete != LV_GAMEOVER) {
// special type - when it expires, gameover timer will start // special type - when it expires, gameover timer will start
@ -7052,12 +7053,15 @@ void docannoneffect(void) {
void dotitlescreen(void) { void dotitlescreen(void) {
char temps[BUFLEN]; char temps[BUFLEN];
SDL_Surface *titlebg; SDL_Surface *titlebg;
SDL_Surface *text, *texts; SDL_Surface *text, *text2, *easy, *norm;
SDL_Event event; SDL_Event event;
int done; int done;
int timer = 0; int timer = 0;
int i; int i;
int texton = B_TRUE; int texton = B_TRUE;
int titlemode;
int blinkspeed;
int thiskey;
// load title screen // load title screen
@ -7070,37 +7074,56 @@ void dotitlescreen(void) {
// set up text // set up text
text = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Press any key to start", red); text = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Press any key to start", red);
texts = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Press any key to start", black); text2 = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Select game mode:", red);
easy = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Easy Mode", red2);
norm = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Normal Mode", red2);
titlemode = TS_WAITKEY;
gamemode = GM_NORM; // default
blinkspeed = 20;
// wait for keypress // wait for keypress
done = B_FALSE; done = B_FALSE;
while (!done) { while (!done) {
SDL_PollEvent(&event); if (SDL_PollEvent(&event)) {
switch (event.type) { switch (event.type) {
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
joyx = SDL_JoystickGetAxis(joy,0); joyx = SDL_JoystickGetAxis(joy,0);
joyy = SDL_JoystickGetAxis(joy,1); joyy = SDL_JoystickGetAxis(joy,1);
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
joybut[i] = SDL_JoystickGetButton(joy,i); joybut[i] = SDL_JoystickGetButton(joy,i);
if (joybut[i]) printf("button %d down\n",i); if (joybut[i]) printf("button %d down\n",i);
} }
//printf("joystick coords are: %d,%d button0=%d, button1=%d\n",joyx,joyy,joybut[0],joybut[1]); //printf("joystick coords are: %d,%d button0=%d, button1=%d\n",joyx,joyy,joybut[0],joybut[1]);
break; break;
case SDL_KEYDOWN: case SDL_KEYUP:
keys = SDL_GetKeyState(NULL); //keys = SDL_GetKeyState(NULL);
if (keys[SDLK_ESCAPE]) { thiskey = event.key.keysym.sym;
// quit if (thiskey == SDLK_ESCAPE) {
exit(0); // quit
} else { exit(0);
done = B_TRUE; }
} if (titlemode == TS_WAITKEY) {
break; titlemode = TS_SELECTMODE;
blinkspeed = 5;
} else if (titlemode == TS_SELECTMODE) {
// pick current mode
if (thiskey == SDLK_UP) {
gamemode = GM_EASY;
} else if (thiskey == SDLK_DOWN) {
gamemode = GM_NORM;
} else if (thiskey == SDLK_z) {
done = B_TRUE;
}
}
break;
}
} }
if (++timer == 20) { if (++timer >= blinkspeed) {
// reset timer // reset timer
timer = 0; timer = 0;
// blink text // blink text
@ -7116,14 +7139,85 @@ void dotitlescreen(void) {
// draw screen // draw screen
SDL_BlitSurface(titlebg, NULL, screen, NULL); SDL_BlitSurface(titlebg, NULL, screen, NULL);
// draw text // draw text
if (texton) { if (titlemode == TS_WAITKEY) {
SDL_Rect area; SDL_Rect area;
area.x = 320 - (texts->w/2)+2; if (texton) {
area.y = 240 - (texts->h/2)+2; area.x = 320 - (text->w/2)+2;
SDL_BlitSurface(texts, NULL, screen, &area); area.y = 240 - (text->h/2)+2;
area.x = 320 - (text->w/2); SDL_SetColors(text, &black, 1, 1);
area.y = 240 - (text->h/2); SDL_BlitSurface(text, NULL, screen, &area);
SDL_BlitSurface(text, NULL, screen, &area);
area.x -= 2;
area.y -= 2;
SDL_SetColors(text, &red, 1, 1);
SDL_BlitSurface(text, NULL, screen, &area);
}
} else if (titlemode == TS_SELECTMODE) {
SDL_Rect area;
SDL_Surface *desc;
// "select mode"
area.x = 320 - (text2->w/2)+2;
area.y = 240 - (text2->h*3)+2;
SDL_SetColors(text2, &black, 1, 1);
SDL_BlitSurface(text2, NULL, screen, &area);
area.x -=2 ; area.y -= 2;
SDL_SetColors(text2, &red, 1, 1);
SDL_BlitSurface(text2, NULL, screen, &area);
// "easy"
area.x = 320 - (easy->w/2)+2;
area.y = 240 - (easy->h)+2;
SDL_SetColors(easy, &black, 1, 1);
SDL_BlitSurface(easy, NULL, screen, &area);
area.x -= 2; area.y -= 2;
if ((gamemode == GM_NORM) || (texton)) { // easy not blinking
// normal
SDL_SetColors(easy, &red2, 1, 1);
} else {
// white
SDL_SetColors(easy, &white, 1, 1);
}
SDL_BlitSurface(easy, NULL, screen, &area);
// "normal"
area.x = 320 - (norm->w/2)+2;
area.y = 240 +2;
SDL_SetColors(norm, &black, 1, 1);
SDL_BlitSurface(norm, NULL, screen, &area);
area.x -= 2; area.y -= 2;
if ((gamemode == GM_EASY) || (texton)) { // easy not blinking
// normal
SDL_SetColors(norm, &red2, 1, 1);
} else {
// white
SDL_SetColors(norm, &white, 1, 1);
}
SDL_BlitSurface(norm, NULL, screen, &area);
// level description
if (gamemode == GM_EASY) {
int x,y;
int startx,starty;
desc = TTF_RenderText_Solid(font[TEXTSIZE_TITLE2], "More lives, extended time limit", black);
startx = 320 - (desc->w/2);
starty = 240 + (desc->h)*3;
for (x = startx-1 ; x <= startx+1; x++) {
for (y = starty-1 ; y <= starty+1; y++) {
area.x = x; area.y = y;
SDL_BlitSurface(desc, NULL, screen, &area);
}
}
area.x = startx;
area.y = starty;
SDL_SetColors(desc, &green, 1, 1);
SDL_BlitSurface(desc, NULL, screen, &area);
SDL_FreeSurface(desc);
}
} }
@ -7131,6 +7225,12 @@ void dotitlescreen(void) {
} }
// clear screen to black // clear screen to black
//SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); //SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
// free temp surfaces
SDL_FreeSurface(text );
SDL_FreeSurface(text2 );
SDL_FreeSurface(easy );
SDL_FreeSurface(norm );
} }
void startgame(void) { void startgame(void) {
@ -7186,9 +7286,13 @@ void startgame(void) {
} }
// more initial variables // more initial variables
player->invuln = INVULNTIME; makeinvuln(player);
player->score = 0; player->score = 0;
player->lives = 3; if (gamemode == GM_EASY) {
player->lives = 6;
} else {
player->lives = 3;
}
forcegoodcard = B_FALSE; forcegoodcard = B_FALSE;
nextforcegoodcard = B_FALSE; nextforcegoodcard = B_FALSE;
@ -7212,3 +7316,11 @@ void uncatch(sprite_t *s) {
s->caughtby = NULL; s->caughtby = NULL;
s->caughtstate = B_FALSE; s->caughtstate = B_FALSE;
} }
void makeinvuln(sprite_t *s) {
if ((s == player) && (gamemode == GM_EASY)) {
s->invuln = INVULNTIME*2;
} else {
s->invuln = INVULNTIME;
}
}

1
rc.h
View File

@ -82,3 +82,4 @@ void docannoneffect(void);
void dotitlescreen(void); void dotitlescreen(void);
void startgame(void); void startgame(void);
void uncatch(sprite_t *s); void uncatch(sprite_t *s);
void makeinvuln(sprite_t *s);

View File

@ -403,8 +403,6 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
tempanim[numanim] = y*LEVELW+x; tempanim[numanim] = y*LEVELW+x;
numanim++; numanim++;
} }
if (y*LEVELW+x == 800) printf("tileframe of 800 is %d\n",level->tileframe[y*LEVELW+x]);
x++; x++;
p = strtok(NULL, ","); p = strtok(NULL, ",");
@ -523,6 +521,8 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
int delay; int delay;
if (level->initm[i].id == P_HELP) { if (level->initm[i].id == P_HELP) {
// TODO: want this??? unless in easy mode, these aren't shown
//if (gamemode != GM_EASY) continue;
strncpy(name, level->initm[i].help, MIDBUFLEN); strncpy(name, level->initm[i].help, MIDBUFLEN);
} else { } else {
sprintf(name, "Monster-%d",i); sprintf(name, "Monster-%d",i);
@ -545,7 +545,7 @@ int loadlevel(int wnum, int lnum, int wantmonsters) {
} }
gtime = 0; gtime = 0;
nexthurryup = level->hurryuptime; resethurryup(level);
boss = NULL; boss = NULL;
mask = NULL; mask = NULL;
@ -3228,3 +3228,10 @@ void drawplayer(sprite_t *s, SDL_Rect *where) {
} }
#endif #endif
} }
void resethurryup(level_t *lev) {
nexthurryup = gtime + lev->hurryuptime;
if (gamemode == GM_EASY) {
nexthurryup += 15;
}
}

View File

@ -61,6 +61,7 @@ int getcardsuit(int cardid);
int getworld(int lev); int getworld(int lev);
int getlevel(int lev); int getlevel(int lev);
void drawplayer(sprite_t *s, SDL_Rect *where); void drawplayer(sprite_t *s, SDL_Rect *where);
void resethurryup(level_t *lev);
// for doco // for doco
void setfruitinfo(void); void setfruitinfo(void);
void setinfo(int id, char *name, char *desc, char *file); void setinfo(int id, char *name, char *desc, char *file);