Fixed double jump behaviour - need to release the jump key
This commit is contained in:
parent
092cfa2180
commit
f7a3b69144
1
defs.h
1
defs.h
|
@ -680,6 +680,7 @@ typedef struct sprite_s {
|
||||||
int doublejump; // have we collected a doublejump powerup?
|
int doublejump; // have we collected a doublejump powerup?
|
||||||
|
|
||||||
int useddoublejump;
|
int useddoublejump;
|
||||||
|
int doublejumpready;
|
||||||
|
|
||||||
// player cards
|
// player cards
|
||||||
int numcards;
|
int numcards;
|
||||||
|
|
19
rc.c
19
rc.c
|
@ -978,10 +978,16 @@ void jump(sprite_t *s, int dir) {
|
||||||
s->dir = s->jumpdir;
|
s->dir = s->jumpdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// used up the doublejump
|
if (s->doublejump) {
|
||||||
if ((s->doublejump) && (s->falling)) {
|
if (s->falling) {
|
||||||
|
// we just used up the doublejump
|
||||||
s->useddoublejump = B_TRUE;
|
s->useddoublejump = B_TRUE;
|
||||||
puffin(-1, s->x, s->y, "nothing", 0);
|
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
|
// if on rollers, they add to your inertia
|
||||||
|
@ -1002,6 +1008,7 @@ void jump(sprite_t *s, int dir) {
|
||||||
} else {
|
} else {
|
||||||
s->jumpspeed = 5;
|
s->jumpspeed = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// stop climbing
|
// stop climbing
|
||||||
s->climbing = B_FALSE;
|
s->climbing = B_FALSE;
|
||||||
|
@ -6576,6 +6583,7 @@ void handleinput(void) {
|
||||||
player->netbig = B_TRUE; // big net
|
player->netbig = B_TRUE; // big net
|
||||||
player->speed = 2; // fast
|
player->speed = 2; // fast
|
||||||
player->netsticky = B_TRUE;
|
player->netsticky = B_TRUE;
|
||||||
|
player->doublejump = B_TRUE;
|
||||||
sprintf(tempm, "Cheat!");
|
sprintf(tempm, "Cheat!");
|
||||||
addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM);
|
addoutlinetext(player->x,player->y - player->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY,TT_NORM);
|
||||||
toggletimer = 80;
|
toggletimer = 80;
|
||||||
|
@ -6719,6 +6727,11 @@ void handleinput(void) {
|
||||||
// Jump
|
// Jump
|
||||||
if (keydown(SDLK_x)) {
|
if (keydown(SDLK_x)) {
|
||||||
trytojump(player);
|
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
|
// Shoot
|
||||||
if (keydown(SDLK_z)) {
|
if (keydown(SDLK_z)) {
|
||||||
|
@ -6763,7 +6776,7 @@ void trytojump(sprite_t *pl) {
|
||||||
} else { // not in water
|
} else { // not in water
|
||||||
// jump
|
// jump
|
||||||
if (!pl->jumping) {
|
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 ) {
|
if (isonground(pl) || isonladder(pl) || pl->doublejump ) {
|
||||||
/* dropping through a bridge */
|
/* dropping through a bridge */
|
||||||
if (keydown(SDLK_DOWN)) {
|
if (keydown(SDLK_DOWN)) {
|
||||||
|
|
Loading…
Reference in New Issue