- Can now slam with 'c', or joystick button 2 or 3

This commit is contained in:
Rob Pearce 2008-10-23 06:26:13 +00:00
parent 55d1de8340
commit dce734bf0f
2 changed files with 107 additions and 80 deletions

183
rc.c
View File

@ -6846,7 +6846,7 @@ if (cheat) {
toggletimer = 30; toggletimer = 30;
} }
} }
if (keydown(SDLK_c)) { // cheat if (keydown(SDLK_v)) { // cheat
if (toggletimer == 0) { if (toggletimer == 0) {
// all powerups // all powerups
playfx(FX_POWERUP); playfx(FX_POWERUP);
@ -6980,7 +6980,16 @@ if (cheat) {
} }
// Shoot // Shoot
if (keydown(SDLK_z)) { 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) { void trytojump(sprite_t *pl) {
// can't jump while slamming
if (pl->slamming) return;
if (isinwater(pl)) { // in water? if (isinwater(pl)) { // in water?
// swim up // swim up
if (!pl->jumping) { 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) { void trytoshoot(sprite_t *pl) {
if ((!pl->netting) && (!pl->slamming)) { if ((!pl->netting) && (!pl->slamming)) {
if (keydown(SDLK_DOWN)) { if ((pl->netcaught < pl->netmax) && (pl->climbing == B_FALSE)) {
/* slam */ // handle cannon
if ((!pl->slamming) && (isonground(pl) && !pl->climbing)) { if (pl->powerup == PW_CANNON) {
playfx(FX_SLAM); playfx(FX_CANNON);
pl->slamming = B_TRUE; pl->powerup = PW_CANNONFIRE;
pl->slamangle = 0; pl->timer3 = CANNONSIZE+5; // use this for size
pl->netxstart = pl->x - (pl->img->w/2)*pl->dir; } else {
/* shoot net */
playfx(FX_SHOOT);
pl->netting = 1;
adjustx(pl, F_SLAM1); adjustx(pl, F_SHOOT);
pl->netystart = pl->y; if (pl->powerup == PW_ACCORDION) {
pl->netspeed = ACCNETSPEED;
/* handle mace */ } else if (pl->netbig) {
if (pl->powerup == PW_MACE) { pl->netspeed = BIGNETSPEED;
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
} else { } else {
/* shoot net */ pl->netspeed = NETSPEED;
playfx(FX_SHOOT); }
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) { /* handle boxing glove */
pl->netspeed = ACCNETSPEED; if (pl->powerup == PW_BOXING) {
} else if (pl->netbig) { sprite_t *s;
pl->netspeed = BIGNETSPEED; int found;
} else { // use existing glove if it is there
pl->netspeed = NETSPEED; 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;
} }
if (!found) {
/* handle boxing glove */ addsprite(P_GLOVE, pl->x,
if (pl->powerup == PW_BOXING) { pl->y - (imageset[pl->id].img[F_SHOOT]->h / 2) + 5,
sprite_t *s; "glove");
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");
}
} }
} }
} }
@ -7155,7 +7169,8 @@ int keydown(int checkfor) {
} }
// check for joystick // check for joystick
if (havejoysticks) { 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_UP) && (joyy <= -6000)) return B_TRUE;
if ((checkfor == SDLK_DOWN) && (joyy >= 6000)) return B_TRUE; if ((checkfor == SDLK_DOWN) && (joyy >= 6000)) return B_TRUE;
if ((checkfor == SDLK_LEFT) && (joyx <= -6000)) return B_TRUE; if ((checkfor == SDLK_LEFT) && (joyx <= -6000)) return B_TRUE;
@ -7573,6 +7588,8 @@ void setjoymappings(void) {
// mame (directions are joystick) // mame (directions are joystick)
joymap[0] = SDLK_z; joymap[0] = SDLK_z;
joymap[1] = SDLK_x; joymap[1] = SDLK_x;
joymap[2] = SDLK_c;
joymap[3] = SDLK_c;
} }
} }
@ -7581,6 +7598,15 @@ int joybuttontokey(int buttonnum) {
return joymap[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 keytojoybutton(int key) {
int i; int i;
for (i = 0; i < joybuttons; i++) { for (i = 0; i < joybuttons; i++) {
@ -7588,6 +7614,7 @@ int keytojoybutton(int key) {
} }
return -1; return -1;
} }
*/
void handletitleinput(int key) { void handletitleinput(int key) {
@ -7950,11 +7977,9 @@ void checkhiscores(void){
// wait for a key... // wait for a key...
if (SDL_PollEvent(&event)) { if (SDL_PollEvent(&event)) {
int key = -1; int key = -1;
int keyval;
switch (event.type) { switch (event.type) {
case SDL_KEYUP: case SDL_KEYUP:
key = event.key.keysym.sym; key = event.key.keysym.sym;
keyval = event.key.keysym.unicode & 0x7F;
break; break;
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
key = joybuttontokey(event.jbutton.button); key = joybuttontokey(event.jbutton.button);

4
rc.h
View File

@ -77,6 +77,7 @@ char *getpokermsg2(int effect, char *buf);
void handleinput(void); void handleinput(void);
int keydown(int checkfor); int keydown(int checkfor);
void trytojump(sprite_t *pl); void trytojump(sprite_t *pl);
void trytoslam(sprite_t *pl);
void trytoshoot(sprite_t *pl); void trytoshoot(sprite_t *pl);
void docannoneffect(void); void docannoneffect(void);
void dotitlescreen(void); void dotitlescreen(void);
@ -85,7 +86,8 @@ void uncatch(sprite_t *s);
void makeinvuln(sprite_t *s); void makeinvuln(sprite_t *s);
void handletitleinput(int key); void handletitleinput(int key);
void setjoymappings(void); void setjoymappings(void);
int keytojoybutton(int key); //int keytojoybutton(int key);
int joybuttondown(int key);
int joybuttontokey(int buttonnum); int joybuttontokey(int buttonnum);
void drawcredits(void); void drawcredits(void);
int drawoutlinetext(SDL_Surface *where,int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol); int drawoutlinetext(SDL_Surface *where,int x, int y, int size, char *msg, SDL_Color *col, SDL_Color *bgcol);