Fixed double jump behaviour - need to release the jump key

This commit is contained in:
Rob Pearce 2008-10-18 21:52:08 +00:00
parent 092cfa2180
commit f7a3b69144
3 changed files with 21 additions and 6 deletions

1
defs.h
View File

@ -680,6 +680,7 @@ typedef struct sprite_s {
int doublejump; // have we collected a doublejump powerup?
int useddoublejump;
int doublejumpready;
// player cards
int numcards;

23
rc.c
View File

@ -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,6 +6727,11 @@ 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)) {
@ -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)) {

View File

@ -586,6 +586,7 @@ void setdefaults(sprite_t *s) {
}
s->doublejump = B_FALSE;
s->doublejumpready = B_FALSE;