- Removed usage of debug keys without cheat mode

- Modified display of hiscores on title screen
- Code to make joystick work during hiscore entry
This commit is contained in:
Rob Pearce 2008-10-23 03:27:54 +00:00
parent 14b9b25098
commit 7ed58e0d65
2 changed files with 60 additions and 67 deletions

126
rc.c
View File

@ -6765,27 +6765,7 @@ char *getpokermsg2(int effect, char *buf) {
void handleinput(void) { void handleinput(void) {
int i;
SDL_Event event; SDL_Event event;
/*
if (levelcomplete == LV_HELPFREEZE) {
// handle keys differently
// we only care about a single keyup event
SDL_PumpEvents();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_KEYUP) {
if (event.key.keysym.sym == SDLK_z) {
levelcomplete = oldlevelcomplete;
}
}
}
return;
}
*/
/* check for key releases */ /* check for key releases */
SDL_PumpEvents(); SDL_PumpEvents();
@ -6812,17 +6792,8 @@ void handleinput(void) {
// don't accept other input in helpfreeze state // don't accept other input in helpfreeze state
if (levelcomplete == LV_HELPFREEZE) return; if (levelcomplete == LV_HELPFREEZE) return;
// now handle key preses // now handle key preses /joystick
keys = SDL_GetKeyState(NULL); getinput();
// check for joystick
if (havejoysticks) {
joyx = SDL_JoystickGetAxis(joy,0);
joyy = SDL_JoystickGetAxis(joy,1);
for (i = 0; i < joybuttons; i++) {
joybut[i] = SDL_JoystickGetButton(joy,i);
}
}
@ -6830,39 +6801,7 @@ void handleinput(void) {
These keys can always be pressed These keys can always be pressed
************************************************************/ ************************************************************/
if (keydown(SDLK_d)) {
sprite_t *s2,*nexts;
// set powerup
player->powerup = PW_PHONE;
skiplevels = 4;
// kill all enemies
for (s2 = sprite; s2 ; s2 = nexts) {
nexts = s2->next;
if (isbullet(s2->id) || ismonster(s2->id)) {
s2->dead = D_FINAL;
if (s2->caughtby) {
uncatch(s2);
player->netcaught--;
}
}
}
}
if (keydown(SDLK_c)) { // cheat
if (toggletimer == 0) {
// all powerups
playfx(FX_POWERUP);
player->netmax = 4; // all nets
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;
}
}
// toggle fullscreen // toggle fullscreen
if (keydown(SDLK_f)) { if (keydown(SDLK_f)) {
if (toggletimer == 0) { if (toggletimer == 0) {
@ -6913,6 +6852,20 @@ if (cheat) {
toggletimer = 30; toggletimer = 30;
} }
} }
if (keydown(SDLK_c)) { // cheat
if (toggletimer == 0) {
// all powerups
playfx(FX_POWERUP);
player->netmax = 4; // all nets
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;
}
}
if (keydown(SDLK_n)) { if (keydown(SDLK_n)) {
if (toggletimer == 0) { if (toggletimer == 0) {
// nextlevel(); // nextlevel();
@ -6951,6 +6904,24 @@ if (cheat) {
toggletimer = 50; toggletimer = 50;
} }
} }
if (keydown(SDLK_d)) {
sprite_t *s2,*nexts;
// set powerup
player->powerup = PW_PHONE;
skiplevels = 4;
// kill all enemies
for (s2 = sprite; s2 ; s2 = nexts) {
nexts = s2->next;
if (isbullet(s2->id) || ismonster(s2->id)) {
s2->dead = D_FINAL;
if (s2->caughtby) {
uncatch(s2);
player->netcaught--;
}
}
}
}
} }
@ -7961,7 +7932,9 @@ void checkhiscores(void){
timer = 0; timer = 0;
} }
keys = SDL_GetKeyState(NULL);
getinput();
if (keytimer == 0) { if (keytimer == 0) {
// check for scrolling // check for scrolling
if (keydown(SDLK_UP)) { // scroll through letters if (keydown(SDLK_UP)) { // scroll through letters
@ -8092,13 +8065,12 @@ void showhiscores(void){
drawhiscores(); drawhiscores();
// wait for a key... // check for a key...
if (SDL_PollEvent(&event)) { if (SDL_PollEvent(&event)) {
int key = -1; int key = -1;
switch (event.type) { switch (event.type) {
case SDL_KEYUP: case SDL_KEYUP:
key = event.key.keysym.sym; key = event.key.keysym.sym;
break; break;
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
key = joybuttontokey(event.jbutton.button); key = joybuttontokey(event.jbutton.button);
@ -8109,7 +8081,8 @@ void showhiscores(void){
if (key == SDLK_ESCAPE) { if (key == SDLK_ESCAPE) {
// quit // quit
exit(0); exit(0);
} else if ((key == SDLK_1) || (key == SDLK_2) || (key == SDLK_RETURN) || (key == SDLK_z)) { } else if ((key == SDLK_1) || (key == SDLK_2)) {
// 1up buttons
finished = B_TRUE; finished = B_TRUE;
} }
} }
@ -8251,3 +8224,22 @@ void drawhiscores(void) {
} }
} }
// read keyboard info
void getinput(void) {
int i;
keys = SDL_GetKeyState(NULL);
if (havejoysticks) {
joyx = SDL_JoystickGetAxis(joy,0);
joyy = SDL_JoystickGetAxis(joy,1);
for (i = 0; i < joybuttons; i++) {
joybut[i] = SDL_JoystickGetButton(joy,i);
}
}
}

1
rc.h
View File

@ -96,3 +96,4 @@ void checkhiscores(void);
int gethiscores(void); int gethiscores(void);
void drawhiscores(void); void drawhiscores(void);
int submithiscore(int score,int level, char *name); int submithiscore(int score,int level, char *name);
void getinput(void);