From fe240dcdb4b72a0de0321a15ff4cc92d845fa7fe Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 6 Nov 2008 01:15:12 +0000 Subject: [PATCH] Modified behaviour of scuba mask - now makes it easier to move underwater --- rc.c | 118 ++++++++++++++++++++++++++++++++++++++--------------------- rc.h | 2 + 2 files changed, 78 insertions(+), 42 deletions(-) diff --git a/rc.c b/rc.c index bd08ec3..e2be9a4 100644 --- a/rc.c +++ b/rc.c @@ -5072,18 +5072,24 @@ void dogravity(sprite_t *s) { // do nothing //} else { //if (!s->climbing) { - if (s->falling == B_FALSE) { - s->fallspeed = 1; - } - s->falling = B_TRUE; - if (isinwater(s) && !s->iced) { - s->y += (s->fallspeed/2); + if (s->falling == B_FALSE) { + s->fallspeed = 1; + } + s->falling = B_TRUE; + if (isinwater(s) && !s->iced) { + if (s->hasmask) { + // bob around + s->y += (sin(timer/5)/3); } else { - s->y += s->fallspeed; - } - if ((timer % 10 == 0) && (s->fallspeed < FALLSPEED)) { - s->fallspeed++; + // sink + s->y += (s->fallspeed/2); } + } else { + s->y += s->fallspeed; + } + if ((timer % 10 == 0) && (s->fallspeed < FALLSPEED)) { + s->fallspeed++; + } //} //} @@ -7664,6 +7670,7 @@ if (cheat) { player->netsticky = B_TRUE; player->doublejump = B_TRUE; player->hasbell = B_TRUE; + player->hasmask = B_TRUE; sprintf(tempm, "Cheat!"); addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); toggletimer = 80; @@ -7797,7 +7804,11 @@ if (cheat) { } if (keydown(SDLK_UP)) { - if (!player->netting && !player->slamming && !player->jumping) { + if ((player->swimming) && (player->hasmask)) { + // swimming + swimup(player); + } else if (!player->netting && !player->slamming && !player->jumping) { + // climbing if (player->climbing) { int ladderx = isladderabove(player); // if tile above is non-solid, or a ladder @@ -7829,7 +7840,10 @@ if (cheat) { } } if (keydown(SDLK_DOWN)) { - if (!player->netting && !player->slamming && !player->jumping) { + if ((player->swimming) && (player->hasmask)) { + // swimming + swimdown(player); + } else if (!player->netting && !player->slamming && !player->jumping) { int ladderx = isonladder(player); if (ladderx) { player->y += getspeed(player); @@ -7874,6 +7888,55 @@ if (cheat) { +void swimup(sprite_t *pl) { + pl->falling = B_FALSE; + if (!isroofabove(pl)) { + // is there water above us too? + if (isinwaterpoint(pl->x, pl->y-TILEH)) { + double swimspeed; + + swimspeed = getspeed(pl); + if (pl->hasmask) { + swimspeed *= 1.5; + } else { + swimspeed *= 2; + } + // if so, swim up + pl->y -= swimspeed; + } else { + int whichway; + // if not, jump up + pl->climbing = B_FALSE; + if (keydown(SDLK_RIGHT)) { + whichway = 1; + } else if (keydown(SDLK_LEFT)) { + whichway = -1; + } else { + whichway = 0; + } + playfx(FX_SPLASH); + jump(pl, whichway); + } + + } +} + +void swimdown(sprite_t *pl) { + pl->falling = B_FALSE; + if (!isonground(pl)) { + double swimspeed; + // swim down + swimspeed = getspeed(pl); + if (pl->hasmask) { + swimspeed *= 1.5; + } else { + swimspeed *= 2; + } + pl->y += swimspeed; + } +} + + void trytojump(sprite_t *pl) { // can't jump while slamming if (pl->slamming) return; @@ -7881,36 +7944,7 @@ void trytojump(sprite_t *pl) { if (isinwater(pl)) { // in water? // swim up if (!pl->jumping) { - pl->falling = B_FALSE; - if (!isroofabove(pl)) { - // is there water above us too? - if (isinwaterpoint(pl->x, pl->y-TILEH)) { - double swimspeed; - - swimspeed = getspeed(pl); - if (pl->hasmask) { - swimspeed *= 1.5; - } else { - swimspeed *= 2; - } - // if so, swim up - pl->y -= swimspeed; - } else { - int whichway; - // if not, jump up - pl->climbing = B_FALSE; - if (keydown(SDLK_RIGHT)) { - whichway = 1; - } else if (keydown(SDLK_LEFT)) { - whichway = -1; - } else { - whichway = 0; - } - playfx(FX_SPLASH); - jump(pl, whichway); - } - - } + swimup(pl); } } else { // not in water // jump diff --git a/rc.h b/rc.h index 70ab6e0..1f38b8f 100644 --- a/rc.h +++ b/rc.h @@ -105,3 +105,5 @@ void stopteleporting(sprite_t *s); void losepowerup(sprite_t *s); int easymode(void); int uncaughtmonsters(void); +void swimup(sprite_t *pl); +void swimdown(sprite_t *pl);