From 310637b4eb26750f4e56e9281a1a08834dc69cb7 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 14 Dec 2015 11:41:43 +0000 Subject: [PATCH] Merged from v0.41. --- src/battle/battle.c | 2 ++ src/battle/player.c | 48 ++++++++++++++++++++++++++++++++-------- src/galaxy/galacticMap.c | 2 ++ src/system/input.c | 11 +++++++-- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/battle/battle.c b/src/battle/battle.c index 71c02cc..ead67a0 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -57,6 +57,8 @@ void initBattle(void) initStars(); + initBullets(); + initBackground(); initEffects(); diff --git a/src/battle/player.c b/src/battle/player.c index 4781dc2..8551671 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -32,6 +32,7 @@ static void activateECM(void); static void handleKeyboard(void); static void faceMouse(void); static void handleMouse(void); +static void preFireMissile(void); static int selectedPlayerIndex; static int availableGuns[BT_MAX]; @@ -152,6 +153,27 @@ static void handleKeyboard(void) { applyFighterBrakes(); } + + if (app.keyboard[SDL_SCANCODE_Z]) + { + switchGuns(); + + app.keyboard[SDL_SCANCODE_Z] = 0; + } + + if (app.keyboard[SDL_SCANCODE_X]) + { + cycleRadarZoom(); + + app.keyboard[SDL_SCANCODE_X] = 0; + } + + if (app.keyboard[SDL_SCANCODE_SPACE]) + { + preFireMissile(); + + app.keyboard[SDL_SCANCODE_SPACE] = 0; + } } } @@ -174,16 +196,9 @@ static void handleMouse(void) } } - if (app.mouse.button[SDL_BUTTON_MIDDLE] && player->missiles && player->target) + if (app.mouse.button[SDL_BUTTON_MIDDLE]) { - if (getDistance(player->x, player->y, player->target->x, player->target->y) <= SCREEN_WIDTH) - { - fireMissile(player); - } - else - { - addHudMessage(colors.white, "Target not in range"); - } + preFireMissile(); app.mouse.button[SDL_BUTTON_MIDDLE] = 0; } @@ -225,6 +240,21 @@ static void faceMouse(void) } } +static void preFireMissile(void) +{ + if (player->missiles && player->target) + { + if (getDistance(player->x, player->y, player->target->x, player->target->y) <= SCREEN_WIDTH) + { + fireMissile(player); + } + else + { + addHudMessage(colors.white, "Target not in range"); + } + } +} + void initPlayerSelect(void) { Entity *e; diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 640c640..4849b57 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -105,6 +105,8 @@ void initGalacticMap(void) updateStarSystemMissions(); + setMouse(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + endSectionTransition(); playMusic("music/Pressure.ogg"); diff --git a/src/system/input.c b/src/system/input.c index 6f4e4dc..a80ad0c 100644 --- a/src/system/input.c +++ b/src/system/input.c @@ -56,9 +56,16 @@ void doMouseWheel(SDL_MouseWheelEvent *event) void setMouse(int x, int y) { - app.mouse.x = x; - app.mouse.y = y; + SDL_Event event; + + app.mouse.x = x * app.scaleX; + app.mouse.y = y * app.scaleY; + SDL_WarpMouseInWindow(app.window, x, y); + + while (SDL_PollEvent(&event)) + { + } } void drawMouse(void)