From dce734bf0f967063e6e0287709248dc2ff6019dc Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 23 Oct 2008 06:26:13 +0000 Subject: [PATCH] - Can now slam with 'c', or joystick button 2 or 3 --- rc.c | 183 +++++++++++++++++++++++++++++++++-------------------------- rc.h | 4 +- 2 files changed, 107 insertions(+), 80 deletions(-) diff --git a/rc.c b/rc.c index f2b11cf..6db7998 100644 --- a/rc.c +++ b/rc.c @@ -6846,7 +6846,7 @@ if (cheat) { toggletimer = 30; } } - if (keydown(SDLK_c)) { // cheat + if (keydown(SDLK_v)) { // cheat if (toggletimer == 0) { // all powerups playfx(FX_POWERUP); @@ -6980,7 +6980,16 @@ if (cheat) { } // Shoot if (keydown(SDLK_z)) { - trytoshoot(player); + if (keydown(SDLK_DOWN)) { + trytoslam(player); + } else { + trytoshoot(player); + } + } + + // Slam + if (keydown(SDLK_c)) { + trytoslam(player); } } } @@ -6992,6 +7001,9 @@ if (cheat) { void trytojump(sprite_t *pl) { + // can't jump while slamming + if (pl->slamming) return; + if (isinwater(pl)) { // in water? // swim up if (!pl->jumping) { @@ -7058,90 +7070,92 @@ void trytojump(sprite_t *pl) { } +void trytoslam(sprite_t *pl) { + if ((!pl->netting) && (!pl->slamming)) { + /* slam */ + if ((!pl->slamming) && (isonground(pl) && !pl->climbing)) { + playfx(FX_SLAM); + pl->slamming = B_TRUE; + pl->slamangle = 0; + pl->netxstart = pl->x - (pl->img->w/2)*pl->dir; + + + adjustx(pl, F_SLAM1); + pl->netystart = pl->y; + + /* handle mace */ + if (pl->powerup == PW_MACE) { + sprite_t *s; + int found; + // use existing mace if it is there + found = B_FALSE; + for (s = sprite; s ; s = s->next) { + if (s->id == P_MACE) { + s->x = pl->x; + s->y = pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5; + found = B_TRUE; + } + } + + if (!found) { + addsprite(P_MACE, pl->x, + pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5, + "mace"); + } + } + + } + } +} + void trytoshoot(sprite_t *pl) { if ((!pl->netting) && (!pl->slamming)) { - if (keydown(SDLK_DOWN)) { - /* slam */ - if ((!pl->slamming) && (isonground(pl) && !pl->climbing)) { - playfx(FX_SLAM); - pl->slamming = B_TRUE; - pl->slamangle = 0; - pl->netxstart = pl->x - (pl->img->w/2)*pl->dir; + if ((pl->netcaught < pl->netmax) && (pl->climbing == B_FALSE)) { + // handle cannon + if (pl->powerup == PW_CANNON) { + playfx(FX_CANNON); + pl->powerup = PW_CANNONFIRE; + pl->timer3 = CANNONSIZE+5; // use this for size + } else { + /* shoot net */ + playfx(FX_SHOOT); + pl->netting = 1; - adjustx(pl, F_SLAM1); - pl->netystart = pl->y; - - /* handle mace */ - if (pl->powerup == PW_MACE) { - sprite_t *s; - int found; - // use existing mace if it is there - found = B_FALSE; - for (s = sprite; s ; s = s->next) { - if (s->id == P_MACE) { - s->x = pl->x; - s->y = pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5; - found = B_TRUE; - } - } - - if (!found) { - addsprite(P_MACE, pl->x, - pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5, - "mace"); - } - } - - } - } else { // not holding down - try to shoot net - if ((pl->netcaught < pl->netmax) && (pl->climbing == B_FALSE)) { - // handle cannon - if (pl->powerup == PW_CANNON) { - playfx(FX_CANNON); - pl->powerup = PW_CANNONFIRE; - pl->timer3 = CANNONSIZE+5; // use this for size + adjustx(pl, F_SHOOT); + if (pl->powerup == PW_ACCORDION) { + pl->netspeed = ACCNETSPEED; + } else if (pl->netbig) { + pl->netspeed = BIGNETSPEED; } else { - /* shoot net */ - playfx(FX_SHOOT); + pl->netspeed = NETSPEED; + } + pl->netlen = 0; + pl->netdir = pl->dir; - pl->netting = 1; + // set up initial... + pl->nety = pl->y - (pl->img->h/2) + 2; + } - adjustx(pl, F_SHOOT); - if (pl->powerup == PW_ACCORDION) { - pl->netspeed = ACCNETSPEED; - } else if (pl->netbig) { - pl->netspeed = BIGNETSPEED; - } else { - pl->netspeed = NETSPEED; + + /* handle boxing glove */ + if (pl->powerup == PW_BOXING) { + sprite_t *s; + int found; + // use existing glove if it is there + found = B_FALSE; + for (s = sprite; s ; s = s->next) { + if (s->id == P_GLOVE) { + s->x = pl->x; + s->y = pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5; + found = B_TRUE; } - pl->netlen = 0; - pl->netdir = pl->dir; - - // set up initial... - pl->nety = pl->y - (pl->img->h/2) + 2; } - - /* handle boxing glove */ - if (pl->powerup == PW_BOXING) { - sprite_t *s; - int found; - // use existing glove if it is there - found = B_FALSE; - for (s = sprite; s ; s = s->next) { - if (s->id == P_GLOVE) { - s->x = pl->x; - s->y = pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5; - found = B_TRUE; - } - } - - if (!found) { - addsprite(P_GLOVE, pl->x, - pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5, - "glove"); - } + if (!found) { + addsprite(P_GLOVE, pl->x, + pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5, + "glove"); } } } @@ -7155,7 +7169,8 @@ int keydown(int checkfor) { } // check for joystick if (havejoysticks) { - if (joybut[keytojoybutton(checkfor)]) return B_TRUE; + //if (joybut[keytojoybutton(checkfor)]) return B_TRUE; + if (joybuttondown(checkfor)) return B_TRUE; if ((checkfor == SDLK_UP) && (joyy <= -6000)) return B_TRUE; if ((checkfor == SDLK_DOWN) && (joyy >= 6000)) return B_TRUE; if ((checkfor == SDLK_LEFT) && (joyx <= -6000)) return B_TRUE; @@ -7573,6 +7588,8 @@ void setjoymappings(void) { // mame (directions are joystick) joymap[0] = SDLK_z; joymap[1] = SDLK_x; + joymap[2] = SDLK_c; + joymap[3] = SDLK_c; } } @@ -7581,6 +7598,15 @@ int joybuttontokey(int buttonnum) { return joymap[buttonnum]; } +int joybuttondown(int key) { + int i; + for (i = 0; i < joybuttons; i++) { + if ((joymap[i] == key) && (joybut[i])) return i; + } + return -1; +} + +/* int keytojoybutton(int key) { int i; for (i = 0; i < joybuttons; i++) { @@ -7588,6 +7614,7 @@ int keytojoybutton(int key) { } return -1; } +*/ void handletitleinput(int key) { @@ -7950,11 +7977,9 @@ void checkhiscores(void){ // wait for a key... if (SDL_PollEvent(&event)) { int key = -1; - int keyval; switch (event.type) { case SDL_KEYUP: key = event.key.keysym.sym; - keyval = event.key.keysym.unicode & 0x7F; break; case SDL_JOYBUTTONUP: key = joybuttontokey(event.jbutton.button); diff --git a/rc.h b/rc.h index 8c96729..c9ca1fb 100644 --- a/rc.h +++ b/rc.h @@ -77,6 +77,7 @@ char *getpokermsg2(int effect, char *buf); void handleinput(void); int keydown(int checkfor); void trytojump(sprite_t *pl); +void trytoslam(sprite_t *pl); void trytoshoot(sprite_t *pl); void docannoneffect(void); void dotitlescreen(void); @@ -85,7 +86,8 @@ void uncatch(sprite_t *s); void makeinvuln(sprite_t *s); void handletitleinput(int key); void setjoymappings(void); -int keytojoybutton(int key); +//int keytojoybutton(int key); +int joybuttondown(int key); int joybuttontokey(int buttonnum); void drawcredits(void); int drawoutlinetext(SDL_Surface *where,int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol);