From f7a3b69144945b15bfed2a91ea655f0de95fd89d Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Sat, 18 Oct 2008 21:52:08 +0000 Subject: [PATCH] Fixed double jump behaviour - need to release the jump key --- defs.h | 1 + rc.c | 25 +++++++++++++++++++------ shared.c | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/defs.h b/defs.h index e63ff88..f165833 100644 --- a/defs.h +++ b/defs.h @@ -680,6 +680,7 @@ typedef struct sprite_s { int doublejump; // have we collected a doublejump powerup? int useddoublejump; + int doublejumpready; // player cards int numcards; diff --git a/rc.c b/rc.c index d872595..6c2dad2 100644 --- a/rc.c +++ b/rc.c @@ -978,10 +978,16 @@ void jump(sprite_t *s, int dir) { s->dir = s->jumpdir; } - // used up the doublejump - if ((s->doublejump) && (s->falling)) { - s->useddoublejump = B_TRUE; - puffin(-1, s->x, s->y, "nothing", 0); + if (s->doublejump) { + if (s->falling) { + // we just used up the doublejump + s->useddoublejump = B_TRUE; + puffin(-1, s->x, s->y, "nothing", 0); + } else { + // we're jumping off the ground + // need to let go of jump before double jumping + s->doublejumpready = B_FALSE; + } } // if on rollers, they add to your inertia @@ -1002,6 +1008,7 @@ void jump(sprite_t *s, int dir) { } else { s->jumpspeed = 5; } + } // stop climbing s->climbing = B_FALSE; @@ -6576,6 +6583,7 @@ void handleinput(void) { player->netbig = B_TRUE; // big net player->speed = 2; // fast player->netsticky = B_TRUE; + player->doublejump = B_TRUE; sprintf(tempm, "Cheat!"); addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM); toggletimer = 80; @@ -6719,7 +6727,12 @@ void handleinput(void) { // Jump if (keydown(SDLK_x)) { trytojump(player); - } + } else if (player->jumping && player->doublejump) { + // have to let go of jump button to double jump + if (!player->doublejumpready) { + player->doublejumpready = B_TRUE; + } + } // Shoot if (keydown(SDLK_z)) { trytoshoot(player); @@ -6763,7 +6776,7 @@ void trytojump(sprite_t *pl) { } else { // not in water // jump if (!pl->jumping) { - if (!pl->falling || (pl->doublejump && pl->falling && (pl->fallspeed == 0))) { + if (!pl->falling || (pl->doublejump && pl->falling && (pl->fallspeed == 0) && pl->doublejumpready)) { if (isonground(pl) || isonladder(pl) || pl->doublejump ) { /* dropping through a bridge */ if (keydown(SDLK_DOWN)) { diff --git a/shared.c b/shared.c index b89e679..b856a44 100644 --- a/shared.c +++ b/shared.c @@ -586,6 +586,7 @@ void setdefaults(sprite_t *s) { } s->doublejump = B_FALSE; + s->doublejumpready = B_FALSE;