- 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

41
rc.c
View File

@ -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,9 +6980,18 @@ if (cheat) {
}
// Shoot
if (keydown(SDLK_z)) {
if (keydown(SDLK_DOWN)) {
trytoslam(player);
} else {
trytoshoot(player);
}
}
// Slam
if (keydown(SDLK_c)) {
trytoslam(player);
}
}
}
// ignore other events
while (SDL_PollEvent(&event)) {
@ -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,9 +7070,8 @@ void trytojump(sprite_t *pl) {
}
void trytoshoot(sprite_t *pl) {
void trytoslam(sprite_t *pl) {
if ((!pl->netting) && (!pl->slamming)) {
if (keydown(SDLK_DOWN)) {
/* slam */
if ((!pl->slamming) && (isonground(pl) && !pl->climbing)) {
playfx(FX_SLAM);
@ -7094,7 +7105,11 @@ void trytoshoot(sprite_t *pl) {
}
}
} else { // not holding down - try to shoot net
}
}
void trytoshoot(sprite_t *pl) {
if ((!pl->netting) && (!pl->slamming)) {
if ((pl->netcaught < pl->netmax) && (pl->climbing == B_FALSE)) {
// handle cannon
if (pl->powerup == PW_CANNON) {
@ -7145,7 +7160,6 @@ void trytoshoot(sprite_t *pl) {
}
}
}
}
}
int keydown(int checkfor) {
@ -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);

4
rc.h
View File

@ -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);