diff --git a/defs.h b/defs.h index 9209246..78a1f62 100644 --- a/defs.h +++ b/defs.h @@ -143,6 +143,7 @@ #define BOMBSHAKETIME 100 // time for screen will shake after a bomb #define RATSHAKETIME 50 // shake time when king rat is stunned +#define SNAILSHAKETIME 35 // shake time when king snail jumps #define BOSSFLASHTIME 15 // how long bosses flash white for when hit #define BOSSDIETIME 150 // how long bosses flash when dead @@ -242,7 +243,7 @@ /* enums */ /* sounds */ -#define MAXFX 48 +#define MAXFX 50 #define FX_SHOOT 0 #define FX_SLAM 1 #define FX_KILL 2 @@ -291,6 +292,8 @@ #define FX_GUN 45 #define FX_ALARM 46 #define FX_ZAP 47 +#define FX_SNAILPREPARE 48 +#define FX_WHOOSH 49 // card suits #define CS_HEART 1 @@ -488,6 +491,7 @@ #define PW_GUNNER 13 // machine gunner // "virtual" powerup for bosses #define PW_RATSHAKE 20 // shake screen horizontally +#define PW_SNAILSHAKE 21 // shake screen vertically #define GUNNERSPEED 2.5 // speed crosshair moves in gunner mode #define GUNNERDELAY 10 // how fast gunner powerup shoots diff --git a/rc.c b/rc.c index 41c32f3..b2b9d81 100644 --- a/rc.c +++ b/rc.c @@ -751,6 +751,32 @@ int main (int argc, char **argv) { } + if (--player->timer1 == 0) { + losepowerup(player); + } + } else if (player->powerup == PW_SNAILSHAKE) { // vertical shake due to king snail + // shake screen + if (timer % 5 == 0) { + int amt; + SDL_Rect area; + + amt = (rand() % 20)+1; + + // offset screen upwards + area.x = 0; + area.y = amt; + area.w = 640; + area.h = 480-amt; + SDL_BlitSurface(screen, &area, screen, NULL); + + // fill in empty bit + area.x = 0; + area.y = 480-amt; + area.w = 640; + area.h = amt; + SDL_FillRect(screen, &area, SDL_MapRGB(screen->format,black.r,black.g,black.b)); + } + if (--player->timer1 == 0) { losepowerup(player); } @@ -1338,6 +1364,8 @@ void die(sprite_t *s) { // stop screen shaking and rats falling if (player->powerup == PW_RATSHAKE) { losepowerup(player); + } else if (player->powerup == PW_SNAILSHAKE) { + losepowerup(player); } // reset timers s->timer1 = 0; @@ -1360,6 +1388,7 @@ void die(sprite_t *s) { case P_KINGRAT: addsprite(P_BIGSPEED, (640/2), 0, "bigspeed"); break; + // TODO: kingsnail perm powerup } } else if ((s->id == P_SNAIL) && (s->lives > 0)) { // snails can't die but turn into slugs instead sprite_t *newsp; @@ -2746,6 +2775,7 @@ int movesprite(sprite_t *s) { if ((countmonsters(P_SNAIL) == 0) || (s->timer1 == KSS_WALK1)) { // next state is shooting s->timer1 = KSS_PAUSE1; s->timer2 = KS_SHOOTWAIT; + playfx(FX_SNAILPREPARE); } else { // next state is jump s->timer1 = KSS_PAUSE2; s->timer2 = KS_JUMPWAIT; @@ -2764,6 +2794,7 @@ int movesprite(sprite_t *s) { // shoot! s->timer1 = KSS_SHOOT; // shell cracks + playfx(FX_CRACK); newsp = addsprite(P_KSSHELL, s->x + -s->dir*((s->img->w/4) + (rand() % 7)-3), s->y-(s->img->h/2) - (rand() % 7) - 3, "ksshell"); @@ -2787,6 +2818,7 @@ int movesprite(sprite_t *s) { newsp->jumpdir = (((double)(rand() % 110) - 50) / 10); // -5 to 5 if (rand() % 2) newsp->dir = 1; else newsp->dir = -1; + playfx(FX_WHOOSH); } else { // enough, regenerate shell s->timer1 = KSS_REGEN; @@ -2806,10 +2838,39 @@ int movesprite(sprite_t *s) { } else if (s->timer1 == KSS_PAUSE2) { if (!s->jumptimer) { + int ydis; + int try; + int tot; + int n; + + // remember our height + s->timer3 = s->y; + // delay then jump s->jumptimer = getjumpdelay(s->id); - s->willjumpspeed = getmonjumpspeed(s); s->jumpdir = 0; + + if ((player->dead) || (player->y > s->y)) { // player below or dead + try = 2; + } else { + // get distance + ydis = abs(s->y - player->y); + // figure out how much we need to jump + for (try = 2; try < (KR_MAXJUMP-1); try++) { + tot = 0; + for (n = try; n >= 1; n--) { + tot = tot + (5*n); + } + if (tot >= ydis) { + break; + } + } + } + jump(s, 0); + // manually adjust speed + try++; // one more just to be sure + s->willjumpspeed = try; + // next state s->timer1 = KSS_JUMPING; } @@ -2817,6 +2878,7 @@ int movesprite(sprite_t *s) { // wait until we land... if (!s->jumptimer && !s->jumping && !s->falling) { sprite_t *ss, *nexts; + // snails turn to slugs!! for (ss = sprite ; ss ; ss = nexts) { nexts = ss->next; @@ -2827,6 +2889,12 @@ int movesprite(sprite_t *s) { // now pause a while before moving again s->timer1 = KSS_PAUSE3; s->timer2 = KS_RELOADWAIT; + + // shake the screen via a fake player powerup + playfx(FX_BOSSWALL); + player->powerup = PW_SNAILSHAKE; + player->timer1 = SNAILSHAKETIME; + } } else if (s->timer1 == KSS_PAUSE3) { s->timer2--; @@ -4967,6 +5035,15 @@ void dogravity(sprite_t *s) { s->falling = B_FALSE; s->climbing = B_FALSE; } + } else if ((s->id == P_KINGSNAIL) && (s->timer1 == KSS_JUMPING)) { // special case + // king snail drops until he is at original height + if (s->y < s->timer3) { // above orig height + ontheground = B_FALSE; + } else { + s->dropping = B_FALSE; + s->falling = B_FALSE; + s->climbing = B_FALSE; + } } else if ((s->id == P_SNAIL) && (s->lives == 0) && s->falling) { // snail dies - this is actuall the snail's shell s->dead = D_FINAL; @@ -6069,6 +6146,8 @@ int initsound(void) { loadfx(FX_GUN, "gun.wav"); loadfx(FX_ALARM, "alarm.wav"); loadfx(FX_ZAP, "zap.wav"); + loadfx(FX_SNAILPREPARE, "longdrum.wav"); + loadfx(FX_WHOOSH, "whoosh.wav"); // load sound effects for (i = 0; i < MAXFX; i++) {