diff --git a/src/mission.cpp b/src/mission.cpp index 9fa293f..26bb298 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -84,8 +84,6 @@ This is where all the missions are defined. */ void mission_init() { - mission_clearAll(); - // Seconds to wait between attempting to add an enemy static const int SOMETIMES = 40 * 60; static const int NORMAL = 15 * 60; @@ -93,6 +91,7 @@ void mission_init() static const int ALWAYS = 1 * 60; static const int NEVER = -1; + mission_clearAll(); sprintf(missions[MISN_START].primaryObjective[0], "Escape from WEAPCO Persuit"); diff --git a/src/player.cpp b/src/player.cpp index 6184115..177e8fd 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -234,6 +234,11 @@ static enum keys mapkey(int code) { void player_getInput() { + static int prevjoyup, prevjoydown, prevjoyleft, prevjoyright; + int joyup, joydown, joyleft, joyright; + static int px = -1, py = -1; + int x, y, w, h; + while (SDL_PollEvent(&engine.event)) { switch (engine.event.type) @@ -299,20 +304,19 @@ void player_getInput() break; case SDL_JOYAXISMOTION: - static int prevjoyup, prevjoydown, prevjoyleft, prevjoyright; if (engine.event.jaxis.axis & 1) { - int joyup = engine.event.jaxis.value < -16384; - int joydown = engine.event.jaxis.value >= 16384; - if(joyup != prevjoyup) + joyup = engine.event.jaxis.value < -16384; + joydown = engine.event.jaxis.value >= 16384; + if (joyup != prevjoyup) engine.keyState[KEY_UP] = prevjoyup = joyup; - if(joydown != prevjoydown) + if (joydown != prevjoydown) engine.keyState[KEY_DOWN] = prevjoydown = joydown; } else { - int joyleft = engine.event.jaxis.value < -16384; - int joyright = engine.event.jaxis.value >= 16384; - if(joyleft != prevjoyleft) + joyleft = engine.event.jaxis.value < -16384; + joyright = engine.event.jaxis.value >= 16384; + if (joyleft != prevjoyleft) engine.keyState[KEY_LEFT] = prevjoyleft = joyleft; - if(joyright != prevjoyright) + if (joyright != prevjoyright) engine.keyState[KEY_RIGHT] = prevjoyright = joyright; } break; @@ -335,8 +339,6 @@ void player_getInput() if (engine.gameSection == SECTION_INTERMISSION) { // Get the current mouse position - static int px = -1, py = -1; - int x, y, w, h; SDL_GetMouseState(&x, &y); SDL_GetWindowSize(window, &w, &h); x = screen->w * x / w;