Use CONTROL_NEXT_FIGHTER / CONTROL_PREV_FIGHTER to select fighters during epic missions.

This commit is contained in:
Steve 2016-03-27 08:55:58 +01:00
parent d33bcf9414
commit 06f7867013
3 changed files with 20 additions and 6 deletions

View File

@ -362,27 +362,27 @@ void initPlayerSelect(void)
void doPlayerSelect(void)
{
if (app.keyboard[SDL_SCANCODE_A] || app.mouse.button[SDL_BUTTON_X1])
if (isControl(CONTROL_PREV_FIGHTER))
{
selectNewPlayer(-1);
app.mouse.button[SDL_BUTTON_X1] = app.keyboard[SDL_SCANCODE_A] = 0;
clearControl(CONTROL_PREV_FIGHTER);
}
if (app.keyboard[SDL_SCANCODE_D] || app.mouse.button[SDL_BUTTON_X2])
if (isControl(CONTROL_NEXT_FIGHTER))
{
selectNewPlayer(1);
app.mouse.button[SDL_BUTTON_X2] = app.keyboard[SDL_SCANCODE_D] = 0;
clearControl(CONTROL_NEXT_FIGHTER);
}
if (player->health > 0 && app.mouse.button[SDL_BUTTON_LEFT])
if (player->health > 0 && isAcceptControl())
{
battle.playerSelect = 0;
initPlayer();
app.mouse.button[SDL_BUTTON_LEFT] = 0;
resetAcceptControls();
}
}

View File

@ -42,6 +42,8 @@ extern int isControl(int type);
extern void clearControl(int type);
extern long lookup(char *name);
extern Entity *spawnFighter(char *name, int x, int y, int side);
extern int isAcceptControl(void);
extern void resetAcceptControls(void);
extern App app;
extern Battle battle;

View File

@ -80,6 +80,11 @@ int isControl(int type)
return ((key != -1 && app.keyboard[key]) || (btn != -1 && app.mouse.button[btn]));
}
int isAcceptControl(void)
{
return (app.keyboard[SDL_SCANCODE_SPACE] ||app.keyboard[SDL_SCANCODE_RETURN] || isControl(CONTROL_FIRE));
}
void clearControl(int type)
{
int key = app.keyControls[type];
@ -96,6 +101,13 @@ void clearControl(int type)
}
}
void resetAcceptControls(void)
{
app.keyboard[SDL_SCANCODE_SPACE] = app.keyboard[SDL_SCANCODE_RETURN] = 0;
clearControl(CONTROL_FIRE);
}
void updateControlKey(char *name)
{
app.keyControls[lookup(name)] = app.lastKeyPressed;