From 10b85b9fd5238d34a7f9ac2330623d6b8240847c Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 26 Nov 2015 09:53:49 +0000 Subject: [PATCH] Updated keyboard controls. --- src/battle/player.c | 31 +++++++++++++++++++------------ src/battle/player.h | 2 ++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/battle/player.c b/src/battle/player.c index 0ac54b4..ce429bc 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -70,6 +70,8 @@ void initPlayer(void) game.stats[STAT_EPIC_KILL_STREAK] = MAX(game.stats[STAT_EPIC_KILL_STREAK], battle.stats[STAT_EPIC_KILL_STREAK]); battle.stats[STAT_EPIC_KILL_STREAK] = 0; + + setMouse(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); } void doPlayer(void) @@ -123,27 +125,32 @@ static void handleKeyboard(void) { if (battle.status == MS_IN_PROGRESS) { - if (app.keyboard[SDL_SCANCODE_W]) - { - cycleRadarZoom(); - - app.keyboard[SDL_SCANCODE_W] = 0; - } - - if (app.keyboard[SDL_SCANCODE_D] && battle.boostTimer == BOOST_RECHARGE_TIME) + if (app.keyboard[SDL_SCANCODE_W] && battle.boostTimer == BOOST_RECHARGE_TIME) { playSound(SND_BOOST); activateBoost(); + app.keyboard[SDL_SCANCODE_W] = 0; + } + + if (app.keyboard[SDL_SCANCODE_A]) + { + selectTarget(); + + app.keyboard[SDL_SCANCODE_A] = 0; + } + + if (app.keyboard[SDL_SCANCODE_D]) + { + activateECM(); + app.keyboard[SDL_SCANCODE_D] = 0; } if (app.keyboard[SDL_SCANCODE_S] && battle.ecmTimer == ECM_RECHARGE_TIME) { - activateECM(); - - app.keyboard[SDL_SCANCODE_S] = 0; + applyFighterBrakes(); } } } @@ -190,7 +197,7 @@ static void handleMouse(void) if (app.mouse.button[SDL_BUTTON_X2]) { - selectTarget(); + cycleRadarZoom(); app.mouse.button[SDL_BUTTON_X2] = 0; } diff --git a/src/battle/player.h b/src/battle/player.h index c353682..f761733 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void fireGuns(Entity *owner); extern void fireMissile(Entity *owner); extern void applyFighterThrust(void); +extern void applyFighterBrakes(void); extern int getDistance(int x1, int y1, int x2, int y2); extern void addHudMessage(SDL_Color c, char *format, ...); extern int mod(int n, int x); @@ -36,6 +37,7 @@ extern void playSound(int id); extern void failMission(void); extern float getAngle(int x1, int y1, int x2, int y2); extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); +extern void setMouse(int x, int y); extern App app; extern Battle battle;