Merge remote-tracking branch 'origin/sdl2'

Conflicts:
	src/player.cpp
This commit is contained in:
Guus Sliepen 2014-05-13 16:22:11 +02:00
commit 36f0e7a85d
20 changed files with 209 additions and 174 deletions

View File

@ -1,9 +1,9 @@
CXXFLAGS ?= -O2 -Wall -g CXXFLAGS ?= -O2 -Wall -g
CXXFLAGS += `sdl-config --cflags` -DLINUX CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer` -DLINUX
LIBS = `sdl-config --libs` -lSDL_mixer -lSDL_image -lstdc++ LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer`
OBJS = ai.o aliens.o audio.o bullets.o cargo.o collectable.o comms.o debris.o events.o explosions.o game.o globals.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o shop.o Starfighter.o title.o unpack.o weapons.o OBJS = ai.o aliens.o audio.o bullets.o cargo.o collectable.o comms.o debris.o events.o explosions.o game.o globals.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o shop.o Starfighter.o title.o unpack.o weapons.o
VERSION = 1.2 VERSION = 1.2-SDL2
PROG = starfighter PROG = starfighter
PACK = starfighter.pak PACK = starfighter.pak
DOCS = docs/* DOCS = docs/*

View File

@ -1,4 +1,4 @@
SONGS = space warm-up SONGS = space warm-up number2
OGG = $(SONGS:%=%.ogg) OGG = $(SONGS:%=%.ogg)
WAV = $(SONGS:%=%.wav) WAV = $(SONGS:%=%.wav)
MID = $(SONGS:%=%.mid) MID = $(SONGS:%=%.mid)

View File

@ -29,9 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <SDL/SDL.h> #include <SDL2/SDL.h>
#include <SDL/SDL_image.h> #include <SDL2/SDL_image.h>
#include <SDL/SDL_mixer.h> #include <SDL2/SDL_mixer.h>
#include "defs.h" #include "defs.h"
#include "structs.h" #include "structs.h"

View File

@ -129,7 +129,7 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
void doComms(SDL_Surface *comms) void doComms(SDL_Surface *comms)
{ {
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
if (engine.commsSection == 0) if (engine.commsSection == 0)
{ {
@ -138,7 +138,7 @@ void doComms(SDL_Surface *comms)
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 180 + (i * 60), 430, 50)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 180 + (i * 60), 430, 50))
{ {
createMissionDetailSurface(comms, i); createMissionDetailSurface(comms, i);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
} }
} }
@ -147,7 +147,7 @@ void doComms(SDL_Surface *comms)
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 440, 160, 20)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 440, 160, 20))
{ {
createCommsSurface(comms); createCommsSurface(comms);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
} }
} }

View File

@ -31,7 +31,7 @@ bool checkPauseRequest()
{ {
getPlayerInput(); getPlayerInput();
if (engine.keyState[SDLK_ESCAPE]) if (engine.keyState[KEY_ESCAPE])
{ {
engine.paused = false; engine.paused = false;
engine.done = 1; engine.done = 1;
@ -39,10 +39,10 @@ bool checkPauseRequest()
return true; return true;
} }
if (engine.keyState[SDLK_p]) if (engine.keyState[KEY_PAUSE])
{ {
engine.paused = false; engine.paused = false;
engine.keyState[SDLK_p] = 0; engine.keyState[KEY_PAUSE] = 0;
} }
return false; return false;

View File

@ -145,7 +145,7 @@ int mainGameLoop()
// Default to no aliens dead... // Default to no aliens dead...
engine.allAliensDead = 0; engine.allAliensDead = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
flushInput(); flushInput();
while (engine.done != 1) while (engine.done != 1)

View File

@ -51,7 +51,7 @@ void defineGlobals()
engine.commsSection = 0; engine.commsSection = 0;
for (int i = 0 ; i < 350 ; i++) for (int i = 0; i < KEY_LAST; i++)
engine.keyState[i] = 0; engine.keyState[i] = 0;
engine.eventTimer = 0; engine.eventTimer = 0;

View File

@ -38,6 +38,9 @@ Uint32 black;
Uint32 white; Uint32 white;
Uint32 lightGrey; Uint32 lightGrey;
Uint32 darkGrey; Uint32 darkGrey;
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
SDL_Surface *screen, *background; SDL_Surface *screen, *background;
SDL_Surface *shape[MAX_SHAPES]; SDL_Surface *shape[MAX_SHAPES];
SDL_Surface *shipShape[MAX_SHIPSHAPES]; SDL_Surface *shipShape[MAX_SHIPSHAPES];
@ -132,7 +135,7 @@ void initGraphics()
SDL_Surface *setTransparent(SDL_Surface *sprite) SDL_Surface *setTransparent(SDL_Surface *sprite)
{ {
SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0)); SDL_SetColorKey(sprite, SDL_TRUE, SDL_MapRGB(sprite->format, 0, 0, 0));
return sprite; return sprite;
} }
@ -351,7 +354,9 @@ void clearScreen(Uint32 color)
void updateScreen() void updateScreen()
{ {
SDL_Flip(screen); SDL_UpdateTexture(texture, NULL, screen->pixels, screen->w * 4);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
} }
/* /*
@ -514,7 +519,7 @@ void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
SDL_Surface *createSurface(int width, int height) SDL_Surface *createSurface(int width, int height)
{ {
SDL_Surface *surface, *newImage; SDL_Surface *surface;
Uint32 rmask, gmask, bmask, amask; Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend /* SDL interprets each pixel as a 32-bit number, so our masks must depend
@ -538,11 +543,7 @@ SDL_Surface *createSurface(int width, int height)
showErrorAndExit(2, ""); showErrorAndExit(2, "");
} }
newImage = SDL_DisplayFormat(surface); return surface;
SDL_FreeSurface(surface);
return newImage;
} }
SDL_Surface *textSurface(const char *inString, int color) SDL_Surface *textSurface(const char *inString, int color)
@ -584,7 +585,7 @@ SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue)); SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue));
SDL_SetAlpha(surface, SDL_SRCALPHA|SDL_RLEACCEL, 128); SDL_SetSurfaceAlphaMod(surface, 128);
return surface; return surface;
} }
@ -680,7 +681,7 @@ SDL_Surface *loadImage(const char *filename)
showErrorAndExit(0, filename); showErrorAndExit(0, filename);
} }
newImage = SDL_DisplayFormat(image); newImage = SDL_ConvertSurface(image, screen->format, 0);
if ( newImage ) { if ( newImage ) {
SDL_FreeSurface(image); SDL_FreeSurface(image);
} else { } else {

View File

@ -33,6 +33,9 @@ extern Uint32 black;
extern Uint32 white; extern Uint32 white;
extern Uint32 lightGrey; extern Uint32 lightGrey;
extern Uint32 darkGrey; extern Uint32 darkGrey;
extern SDL_Window *window;
extern SDL_Renderer *renderer;
extern SDL_Texture *texture;
extern SDL_Surface *screen, *background; extern SDL_Surface *screen, *background;
extern SDL_Surface *shape[MAX_SHAPES]; extern SDL_Surface *shape[MAX_SHAPES];
extern SDL_Surface *shipShape[MAX_SHIPSHAPES]; extern SDL_Surface *shipShape[MAX_SHIPSHAPES];

View File

@ -96,9 +96,9 @@ void showErrorAndExit(int errorId, const char *name)
updateScreen(); updateScreen();
engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_ALTFIRE] = 0;
while (!engine.keyState[SDLK_SPACE]) while (!engine.keyState[KEY_ALTFIRE])
{ {
getPlayerInput(); getPlayerInput();
delayFrame(); delayFrame();
@ -184,16 +184,36 @@ void initSystem()
engine.useSound = useSound; engine.useSound = useSound;
engine.useMusic = useMusic; engine.useMusic = useMusic;
SDL_WM_SetCaption("Project: Starfighter", "starfighter"); screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
SDL_WM_SetIcon(loadImage("gfx/alienDevice.png"), NULL);
if (engine.fullScreen) if (!screen) {
screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); printf("Couldn't create %ix%ix32 surface: %s\n", screenWidth, screenHeight, SDL_GetError());
else exit(1);
screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); }
if (screen == NULL) { window = SDL_CreateWindow("Project: Starfighter", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen->w, screen->h, 0);
printf("Couldn't set %ix%ix16 video mode: %s\n", screenWidth, screenHeight, SDL_GetError());
if (window == NULL) {
printf("Could not create window: %s\n", SDL_GetError());
exit(1);
}
SDL_SetWindowIcon(window, loadImage("gfx/alienDevice.png"));
SDL_SetWindowFullscreen(window, engine.fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
printf("Could not create renderer: %s\n", SDL_GetError());
exit(1);
}
SDL_RenderSetLogicalSize(renderer, screen->w, screen->h);
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen->w, screen->h);
if (!texture) {
printf("Couldn't create %ix%ix32 texture: %s\n", screen->w, screen->h, SDL_GetError());
exit(1); exit(1);
} }

View File

@ -275,7 +275,7 @@ static bool showSystem(float x, float y, bool selectable)
if (selectable && collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, r.x, r.y, systemPlanet[planet].image->w, systemPlanet[planet].image->h)) if (selectable && collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, r.x, r.y, systemPlanet[planet].image->w, systemPlanet[planet].image->h))
{ {
drawString(systemPlanet[planet].name, -1, 545, FONT_WHITE); drawString(systemPlanet[planet].name, -1, 545, FONT_WHITE);
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
if (currentGame.system == 0) if (currentGame.system == 0)
{ {
@ -291,7 +291,7 @@ static bool showSystem(float x, float y, bool selectable)
} }
rtn = true; rtn = true;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
} }
@ -314,9 +314,9 @@ static void showStatus(SDL_Surface *infoSurface)
{ {
float speed = 0.25; float speed = 0.25;
if(engine.keyState[SDLK_DOWN]) if(engine.keyState[KEY_DOWN])
speed = 1; speed = 1;
else if(engine.keyState[SDLK_UP]) else if(engine.keyState[KEY_UP])
speed = -1; speed = -1;
blit(infoSurface, 100, 80); blit(infoSurface, 100, 80);
@ -407,7 +407,7 @@ static void createOptions(SDL_Surface *optionsSurface)
static void showOptions(SDL_Surface *optionsSurface) static void showOptions(SDL_Surface *optionsSurface)
{ {
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 172, 45, 22)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 172, 45, 22))
engine.useSound = true; engine.useSound = true;
@ -439,13 +439,7 @@ static void showOptions(SDL_Surface *optionsSurface)
{ {
if (!engine.fullScreen) if (!engine.fullScreen)
{ {
#if LINUX SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_WM_ToggleFullScreen(screen);
#else
screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
drawBackground();
flushBuffer();
#endif
engine.fullScreen = true; engine.fullScreen = true;
} }
} }
@ -454,13 +448,7 @@ static void showOptions(SDL_Surface *optionsSurface)
{ {
if (engine.fullScreen) if (engine.fullScreen)
{ {
#if LINUX SDL_SetWindowFullscreen(window, 0);
SDL_WM_ToggleFullScreen(screen);
#else
screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
drawBackground();
flushBuffer();
#endif
engine.fullScreen = false; engine.fullScreen = false;
} }
} }
@ -468,7 +456,7 @@ static void showOptions(SDL_Surface *optionsSurface)
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 322, 100, 22)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 322, 100, 22))
{ {
wrapChar(&(++currentGame.autoSaveSlot), -1, 4); wrapChar(&(++currentGame.autoSaveSlot), -1, 4);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
createOptions(optionsSurface); createOptions(optionsSurface);
@ -534,7 +522,7 @@ int galaxyMap()
shape[FACE_KLINE] = loadImage("gfx/face_kline.png"); shape[FACE_KLINE] = loadImage("gfx/face_kline.png");
engine.done = 0; engine.done = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
engine.ssx = engine.ssy = 0; engine.ssx = engine.ssy = 0;
SDL_Rect r; SDL_Rect r;
@ -611,7 +599,7 @@ int galaxyMap()
player.shield = player.maxShield; player.shield = player.maxShield;
flushInput(); flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
engine.done = 0; engine.done = 0;
while (!engine.done) while (!engine.done)
@ -695,10 +683,10 @@ int galaxyMap()
break; break;
case 1: case 1:
if (engine.keyState[SDLK_SPACE]) if (engine.keyState[KEY_ALTFIRE])
{ {
movePlanets = !movePlanets; movePlanets = !movePlanets;
engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_ALTFIRE] = 0;
} }
if (movePlanets) if (movePlanets)
@ -830,17 +818,17 @@ int galaxyMap()
blit(iconInfo[11].image, (int)iconInfo[i].x, 545); blit(iconInfo[11].image, (int)iconInfo[i].x, 545);
} }
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
redrawBackGround = true; redrawBackGround = true;
section = i; section = i;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
} }
} }
} }
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
doCursor(); doCursor();
delayFrame(); delayFrame();

View File

@ -153,7 +153,7 @@ void saveGame(int slot)
// Recall to update the save slots... (lazy, yes) // Recall to update the save slots... (lazy, yes)
initSaveSlots(); initSaveSlots();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot) void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
@ -203,7 +203,7 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
break; break;
} }
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
} }
/* /*
@ -221,7 +221,7 @@ int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot)
int clickedSlot = -1; int clickedSlot = -1;
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
for (int i = 0 ; i < 5 ; i++) for (int i = 0 ; i < 5 ; i++)
{ {

View File

@ -396,7 +396,7 @@ void doInfo()
if (player.shield < 1) if (player.shield < 1)
return; return;
if ((!engine.keyState[SDLK_SPACE]) && (player.weaponType[1] == W_LASER) && (engine.eventTimer % 8 == 1)) if ((!engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] == W_LASER) && (engine.eventTimer % 8 == 1))
limitCharAdd(&player.ammo[1], -1, 1, 255); limitCharAdd(&player.ammo[1], -1, 1, 255);
if ((engine.eventTimer < 30) && (player.shield <= engine.lowShield)) if ((engine.eventTimer < 30) && (player.shield <= engine.lowShield))

View File

@ -792,13 +792,13 @@ void missionBriefScreen()
flushInput(); flushInput();
engine.done = 0; engine.done = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
while (true) while (true)
{ {
delayFrame(); delayFrame();
getPlayerInput(); getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
break; break;
} }
@ -890,13 +890,13 @@ void missionFinishedScreen()
flushInput(); flushInput();
engine.done = 0; engine.done = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
while (true) while (true)
{ {
delayFrame(); delayFrame();
getPlayerInput(); getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
break; break;
} }
} }

View File

@ -86,10 +86,10 @@ void doPlayer()
{ {
if (player.shield > 0) if (player.shield > 0)
{ {
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
fireBullet(&player, 0); fireBullet(&player, 0);
if ((engine.keyState[SDLK_SPACE]) && (player.weaponType[1] != W_NONE)) if ((engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] != W_NONE))
{ {
if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER) && (player.ammo[1] > 0)) if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER) && (player.ammo[1] > 0))
{ {
@ -113,7 +113,7 @@ void doPlayer()
if (player.weaponType[1] == W_CHARGER) if (player.weaponType[1] == W_CHARGER)
{ {
if (engine.keyState[SDLK_SPACE] && !(currentGame.gamePlay == GAMEPLAY_ONPON && (engine.keyState[SDLK_LCTRL] || engine.keyState[SDLK_RCTRL]))) if (engine.keyState[KEY_ALTFIRE] && !(currentGame.gamePlay == GAMEPLAY_ONPON && engine.keyState[KEY_FIRE]))
{ {
limitCharAdd(&player.ammo[1], 1, 0, 200); limitCharAdd(&player.ammo[1], 1, 0, 200);
} }
@ -125,7 +125,7 @@ void doPlayer()
} }
} }
if ((engine.keyState[SDLK_LSHIFT]) || (engine.keyState[SDLK_RSHIFT])) if ((engine.keyState[KEY_SWITCH]))
{ {
if(weapon[0].ammo[0] >= 3 && weapon[0].ammo[0] <= currentGame.maxPlasmaOutput) if(weapon[0].ammo[0] >= 3 && weapon[0].ammo[0] <= currentGame.maxPlasmaOutput)
{ {
@ -141,39 +141,39 @@ void doPlayer()
} }
} }
engine.keyState[SDLK_LSHIFT] = engine.keyState[SDLK_RSHIFT] = 0; engine.keyState[KEY_SWITCH] = 0;
} }
limitCharAdd(&player.reload[0], -1, 0, 999); limitCharAdd(&player.reload[0], -1, 0, 999);
limitCharAdd(&player.reload[1], -1, 0, 999); limitCharAdd(&player.reload[1], -1, 0, 999);
if (engine.keyState[SDLK_UP]) if (engine.keyState[KEY_UP])
{ {
player.y -= player.speed; player.y -= player.speed;
engine.ssy += 0.1; engine.ssy += 0.1;
} }
if (engine.keyState[SDLK_DOWN]) if (engine.keyState[KEY_DOWN])
{ {
player.y += player.speed; player.y += player.speed;
engine.ssy -= 0.1; engine.ssy -= 0.1;
} }
if (engine.keyState[SDLK_LEFT]) if (engine.keyState[KEY_LEFT])
{ {
player.x -= player.speed; player.x -= player.speed;
engine.ssx += 0.1; engine.ssx += 0.1;
player.face = 1; player.face = 1;
} }
if (engine.keyState[SDLK_RIGHT]) if (engine.keyState[KEY_RIGHT])
{ {
player.x += player.speed; player.x += player.speed;
engine.ssx -= 0.1; engine.ssx -= 0.1;
player.face = 0; player.face = 0;
} }
if (engine.keyState[SDLK_ESCAPE]) if (engine.keyState[KEY_ESCAPE])
{ {
if ((engine.done == 0) && (engine.gameSection == SECTION_GAME) && (currentMission.remainingObjectives1 == 0)) if ((engine.done == 0) && (engine.gameSection == SECTION_GAME) && (currentMission.remainingObjectives1 == 0))
{ {
@ -183,13 +183,13 @@ void doPlayer()
} }
} }
if (engine.keyState[SDLK_p] || !(SDL_GetAppState() & SDL_APPINPUTFOCUS)) if (engine.keyState[KEY_PAUSE])
{ {
engine.paused = true; engine.paused = true;
engine.keyState[SDLK_p] = 0; engine.keyState[KEY_PAUSE] = 0;
} }
if ((engine.keyState[SDLK_t]) && (currentGame.area != 10)) if ((engine.keyState[KEY_TARGET]) && (currentGame.area != 10))
{ {
if (engine.targetArrowTimer == -1 && currentGame.difficulty < DIFFICULTY_HARD) { if (engine.targetArrowTimer == -1 && currentGame.difficulty < DIFFICULTY_HARD) {
engine.targetArrowTimer = -2; engine.targetArrowTimer = -2;
@ -202,7 +202,7 @@ void doPlayer()
setInfoLine("Showing mission target", FONT_WHITE); setInfoLine("Showing mission target", FONT_WHITE);
} }
engine.keyState[SDLK_t] = 0; engine.keyState[KEY_TARGET] = 0;
} }
if ((engine.missionCompleteTimer == 0) && (engine.targetArrowTimer == -1)) if ((engine.missionCompleteTimer == 0) && (engine.targetArrowTimer == -1))
@ -261,7 +261,7 @@ void doPlayer()
playSound(SFX_EXPLOSION, player.x); playSound(SFX_EXPLOSION, player.x);
} }
engine.keyState[SDLK_UP] = engine.keyState[SDLK_DOWN] = engine.keyState[SDLK_LEFT] = engine.keyState[SDLK_RIGHT] = 0; engine.keyState[KEY_UP] = engine.keyState[KEY_DOWN] = engine.keyState[KEY_LEFT] = engine.keyState[KEY_RIGHT] = 0;
if ((rand() % 3) == 0) if ((rand() % 3) == 0)
addExplosion(player.x + rrand(-10, 10), player.y + rrand(-10, 10), E_BIG_EXPLOSION); addExplosion(player.x + rrand(-10, 10), player.y + rrand(-10, 10), E_BIG_EXPLOSION);
if (player.shield == -99) if (player.shield == -99)
@ -291,12 +291,43 @@ void doPlayer()
void flushInput() void flushInput()
{ {
for (int i = 0 ; i < 350 ; i++) for (int i = 0; i < KEY_LAST; i++)
engine.keyState[i] = 0; engine.keyState[i] = 0;
while (SDL_PollEvent(&engine.event)){} while (SDL_PollEvent(&engine.event)){}
} }
static enum keys mapkey(uint32_t code) {
switch (code) {
case SDLK_UP:
return KEY_UP;
case SDLK_DOWN:
return KEY_DOWN;
case SDLK_LEFT:
return KEY_LEFT;
case SDLK_RIGHT:
return KEY_RIGHT;
case SDLK_LCTRL:
case SDLK_RCTRL:
return KEY_FIRE;
case SDLK_SPACE:
return KEY_ALTFIRE;
case SDLK_t:
return KEY_TARGET;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
return KEY_SWITCH;
case SDLK_p:
return KEY_PAUSE;
case SDLK_ESCAPE:
return KEY_ESCAPE;
case SDLK_F11:
return KEY_FULLSCREEN;
default:
return KEY_DUMMY;
}
}
void getPlayerInput() void getPlayerInput()
{ {
while (SDL_PollEvent(&engine.event)) while (SDL_PollEvent(&engine.event))
@ -310,16 +341,17 @@ void getPlayerInput()
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if (engine.gameSection == SECTION_INTERMISSION) if (engine.gameSection == SECTION_INTERMISSION)
{ {
if (engine.event.button.button == SDL_BUTTON_LEFT) engine.keyState[SDLK_LCTRL] = 1; if (engine.event.button.button == SDL_BUTTON_LEFT) engine.keyState[KEY_FIRE] = 1;
if (engine.event.button.button == SDL_BUTTON_RIGHT) engine.keyState[SDLK_SPACE] = 1; if (engine.event.button.button == SDL_BUTTON_RIGHT) engine.keyState[KEY_ALTFIRE] = 1;
} }
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
if (engine.gameSection == SECTION_TITLE) //TODO: reenable somehow?
addKeyEvent(SDL_GetKeyName(engine.event.key.keysym.sym)); //if (engine.gameSection == SECTION_TITLE)
// addKeyEvent(SDL_GetKeyName(engine.event.key.keysym.sym));
engine.keyState[engine.event.key.keysym.sym] = 1; engine.keyState[mapkey(engine.event.key.keysym.sym)] = 1;
if (engine.gameSection != SECTION_GAME) if (engine.gameSection != SECTION_GAME)
engine.paused = false; engine.paused = false;
@ -327,8 +359,8 @@ void getPlayerInput()
break; break;
case SDL_KEYUP: case SDL_KEYUP:
if (engine.event.key.keysym.sym != SDLK_p) if (engine.event.key.keysym.sym != SDLK_p && engine.event.key.keysym.sym != SDLK_t)
engine.keyState[engine.event.key.keysym.sym] = 0; engine.keyState[mapkey(engine.event.key.keysym.sym)] = 0;
break; break;
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
@ -336,25 +368,25 @@ void getPlayerInput()
switch (engine.event.jbutton.button) switch (engine.event.jbutton.button)
{ {
case 0: case 0:
engine.keyState[SDLK_LCTRL] = engine.event.jbutton.state; engine.keyState[KEY_FIRE] = engine.event.jbutton.state;
break; break;
case 1: case 1:
engine.keyState[SDLK_SPACE] = engine.event.jbutton.state; engine.keyState[KEY_ALTFIRE] = engine.event.jbutton.state;
break; break;
case 2: case 2:
engine.keyState[SDLK_LSHIFT] = engine.event.jbutton.state; engine.keyState[KEY_SWITCH] = engine.event.jbutton.state;
break; break;
case 3: case 3:
engine.keyState[SDLK_t] = engine.event.jbutton.state; engine.keyState[KEY_TARGET] = engine.event.jbutton.state;
break; break;
} }
break; break;
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:
engine.keyState[SDLK_UP] = engine.event.jhat.value & SDL_HAT_UP; engine.keyState[KEY_UP] = engine.event.jhat.value & SDL_HAT_UP;
engine.keyState[SDLK_DOWN] = engine.event.jhat.value & SDL_HAT_DOWN; engine.keyState[KEY_DOWN] = engine.event.jhat.value & SDL_HAT_DOWN;
engine.keyState[SDLK_LEFT] = engine.event.jhat.value & SDL_HAT_LEFT; engine.keyState[KEY_LEFT] = engine.event.jhat.value & SDL_HAT_LEFT;
engine.keyState[SDLK_RIGHT] = engine.event.jhat.value & SDL_HAT_RIGHT; engine.keyState[KEY_RIGHT] = engine.event.jhat.value & SDL_HAT_RIGHT;
break; break;
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
@ -363,28 +395,30 @@ void getPlayerInput()
bool joyup = engine.event.jaxis.value < -16384; bool joyup = engine.event.jaxis.value < -16384;
bool joydown = engine.event.jaxis.value >= 16384; bool joydown = engine.event.jaxis.value >= 16384;
if(joyup != prevjoyup) if(joyup != prevjoyup)
engine.keyState[SDLK_UP] = prevjoyup = joyup; engine.keyState[KEY_UP] = prevjoyup = joyup;
if(joydown != prevjoydown) if(joydown != prevjoydown)
engine.keyState[SDLK_DOWN] = prevjoydown = joydown; engine.keyState[KEY_DOWN] = prevjoydown = joydown;
} else { } else {
bool joyleft = engine.event.jaxis.value < -16384; bool joyleft = engine.event.jaxis.value < -16384;
bool joyright = engine.event.jaxis.value >= 16384; bool joyright = engine.event.jaxis.value >= 16384;
if(joyleft != prevjoyleft) if(joyleft != prevjoyleft)
engine.keyState[SDLK_LEFT] = prevjoyleft = joyleft; engine.keyState[KEY_LEFT] = prevjoyleft = joyleft;
if(joyright != prevjoyright) if(joyright != prevjoyright)
engine.keyState[SDLK_RIGHT] = prevjoyright = joyright; engine.keyState[KEY_RIGHT] = prevjoyright = joyright;
} }
break; break;
default: case SDL_WINDOWEVENT:
if(engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
engine.paused = 1;
break; break;
} }
if ((engine.keyState[SDLK_F11]) || ((engine.keyState[SDLK_RETURN]) && (engine.keyState[SDLK_LALT]))) if (engine.keyState[KEY_FULLSCREEN])
{ {
SDL_WM_ToggleFullScreen(screen);
engine.fullScreen = !engine.fullScreen; engine.fullScreen = !engine.fullScreen;
engine.keyState[SDLK_F11] = engine.keyState[SDLK_LALT] = engine.keyState[SDLK_RETURN] = 0; SDL_SetWindowFullscreen(window, engine.fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
engine.keyState[KEY_FULLSCREEN] = 0;
} }
} }
@ -395,13 +429,13 @@ void getPlayerInput()
int x, y; int x, y;
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
if (px == x && py == y) { if (px == x && py == y) {
if(engine.keyState[SDLK_UP] && engine.cursor_y > 0) if(engine.keyState[KEY_UP] && engine.cursor_y > 0)
engine.cursor_y -= 4; engine.cursor_y -= 4;
if(engine.keyState[SDLK_DOWN] && engine.cursor_y < screen->h - 4) if(engine.keyState[KEY_DOWN] && engine.cursor_y < screen->h - 4)
engine.cursor_y += 4; engine.cursor_y += 4;
if(engine.keyState[SDLK_LEFT] && engine.cursor_x > 0) if(engine.keyState[KEY_LEFT] && engine.cursor_x > 0)
engine.cursor_x -= 4; engine.cursor_x -= 4;
if(engine.keyState[SDLK_RIGHT] && engine.cursor_x < screen->w - 4) if(engine.keyState[KEY_RIGHT] && engine.cursor_x < screen->w - 4)
engine.cursor_x += 4; engine.cursor_x += 4;
} else { } else {
engine.cursor_x = px = x; engine.cursor_x = px = x;
@ -413,8 +447,8 @@ void getPlayerInput()
void leaveSector() void leaveSector()
{ {
engine.keyState[SDLK_UP] = engine.keyState[SDLK_DOWN] = engine.keyState[SDLK_LEFT] = engine.keyState[SDLK_RIGHT] = 0; engine.keyState[KEY_UP] = engine.keyState[KEY_DOWN] = engine.keyState[KEY_LEFT] = engine.keyState[KEY_RIGHT] = 0;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
if (engine.done == 0) if (engine.done == 0)
engine.done = 3; engine.done = 3;

View File

@ -116,7 +116,7 @@ void loadGameGraphics()
} }
} }
SDL_SetColorKey(shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(shipShape[i]->format, 0, 0, 0)); SDL_SetColorKey(shipShape[i], SDL_TRUE, SDL_MapRGB(shipShape[i]->format, 0, 0, 0));
} }
strcpy(string, "data/resources_all.dat"); strcpy(string, "data/resources_all.dat");
@ -178,22 +178,6 @@ void freeSound()
} }
static void setFontColor(SDL_Surface *image, int red, int green, int blue)
{
SDL_Color colors[256];
colors[0].r = 0;
colors[0].g = 0;
colors[0].b = 0;
for (int i = 1 ; i < 256 ; i++)
{
colors[i].r = red;
colors[i].g = green;
colors[i].b = blue;
}
SDL_SetPalette(image, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
}
/* /*
Custom loading to alter the font color before doing Custom loading to alter the font color before doing
all other things all other things
@ -219,23 +203,23 @@ void loadFont()
switch(i) switch(i)
{ {
case 1: case 1:
setFontColor(image, 255, 0, 0); SDL_SetSurfaceColorMod(image, 255, 0, 0);
break; break;
case 2: case 2:
setFontColor(image, 255, 255, 0); SDL_SetSurfaceColorMod(image, 255, 255, 0);
break; break;
case 3: case 3:
setFontColor(image, 0, 255, 0); SDL_SetSurfaceColorMod(image, 0, 255, 0);
break; break;
case 4: case 4:
setFontColor(image, 0, 255, 255); SDL_SetSurfaceColorMod(image, 0, 255, 255);
break; break;
case 5: case 5:
setFontColor(image, 0, 0, 10); SDL_SetSurfaceColorMod(image, 0, 0, 10);
break; break;
} }
newImage = SDL_DisplayFormat(image); newImage = SDL_ConvertSurface(image, screen->format, 0);
fontShape[i] = setTransparent(newImage); fontShape[i] = setTransparent(newImage);

View File

@ -202,7 +202,7 @@ void doCutscene(int scene)
updateScreen(); updateScreen();
clearScreen(black); clearScreen(black);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
engine.ssx = -0.5; engine.ssx = -0.5;
engine.ssy = 0; engine.ssy = 0;
@ -314,7 +314,7 @@ void doCutscene(int scene)
delayFrame(); delayFrame();
if (engine.keyState[SDLK_ESCAPE]) if (engine.keyState[KEY_ESCAPE])
break; break;
} }

View File

@ -672,14 +672,14 @@ void showShop()
else if (currentGame.system == 2) else if (currentGame.system == 2)
icons = 15; icons = 15;
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) if ((engine.keyState[KEY_FIRE]))
{ {
for (int i = 0 ; i < icons ; i++) for (int i = 0 ; i < icons ; i++)
{ {
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, shopItems[i].x, shopItems[i].y, 32, 25)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, shopItems[i].x, shopItems[i].y, 32, 25))
{ {
shopSelectedItem = i; shopSelectedItem = i;
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
drawShop(); drawShop();
} }
} }
@ -689,14 +689,14 @@ void showShop()
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 60, 350, 24, 16)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 60, 350, 24, 16))
{ {
buy(shopSelectedItem); buy(shopSelectedItem);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
drawShop(); drawShop();
} }
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 700, 350, 24, 16)) if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 700, 350, 24, 16))
{ {
sell(shopSelectedItem); sell(shopSelectedItem);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = 0;
drawShop(); drawShop();
} }
} }

View File

@ -207,6 +207,21 @@ struct Planet {
char subject[100]; char subject[100];
}; };
enum keys {
KEY_UP,
KEY_DOWN,
KEY_LEFT,
KEY_RIGHT,
KEY_FIRE,
KEY_ALTFIRE,
KEY_TARGET,
KEY_SWITCH,
KEY_PAUSE,
KEY_ESCAPE,
KEY_FULLSCREEN,
KEY_DUMMY,
KEY_LAST
};
struct globalEngineVariables { struct globalEngineVariables {
@ -274,7 +289,7 @@ struct globalEngineVariables {
// This really only applies to Linux users. // This really only applies to Linux users.
char userHomeDirectory[1024]; char userHomeDirectory[1024];
char keyState[350]; char keyState[KEY_LAST];
bool cheat; // overall cheat bool cheat; // overall cheat
bool cheatShield; bool cheatShield;

View File

@ -265,7 +265,7 @@ int doTitle()
engine.done = 0; engine.done = 0;
flushInput(); flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
if ((engine.useMusic) && (engine.useAudio)) if ((engine.useMusic) && (engine.useAudio))
Mix_PlayMusic(engine.music, 1); Mix_PlayMusic(engine.music, 1);
@ -338,18 +338,18 @@ int doTitle()
if (redGlow <= 0) {redDir = 2; redGlow = 0;} if (redGlow <= 0) {redDir = 2; redGlow = 0;}
if (redGlow >= 255) {redDir = -2; redGlow = 255;} if (redGlow >= 255) {redDir = -2; redGlow = 255;}
if (engine.keyState[SDLK_UP]) if (engine.keyState[KEY_UP])
{ {
engine.keyState[SDLK_UP] = 0; engine.keyState[KEY_UP] = 0;
wrapChar(&(--selectedOption), 1, listLength + 1); wrapChar(&(--selectedOption), 1, listLength + 1);
if (menuType == 0) if (menuType == 0)
if ((selectedOption == 2) || (selectedOption == 3)) if ((selectedOption == 2) || (selectedOption == 3))
if (continueSaveSlot == 0) if (continueSaveSlot == 0)
selectedOption = 1; selectedOption = 1;
} }
if (engine.keyState[SDLK_DOWN]) if (engine.keyState[KEY_DOWN])
{ {
engine.keyState[SDLK_DOWN] = 0; engine.keyState[KEY_DOWN] = 0;
wrapChar(&(++selectedOption), 0, listLength); wrapChar(&(++selectedOption), 0, listLength);
if (menuType == 0) if (menuType == 0)
if ((selectedOption == 2) || (selectedOption == 3)) if ((selectedOption == 2) || (selectedOption == 3))
@ -382,7 +382,7 @@ int doTitle()
engine.cheatCredits = false; engine.cheatCredits = false;
} }
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE])) if ((engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE]))
{ {
if ((now - then <= 27500) && (!skip)) if ((now - then <= 27500) && (!skip))
{ {
@ -445,17 +445,7 @@ int doTitle()
else if (selectedOption == 3) else if (selectedOption == 3)
{ {
engine.fullScreen = !engine.fullScreen; engine.fullScreen = !engine.fullScreen;
#if LINUX SDL_SetWindowFullscreen(window, engine.fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
SDL_WM_ToggleFullScreen(screen);
#else
if (engine.fullScreen)
screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
else
screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
drawBackground();
flushBuffer();
#endif
} }
else if (selectedOption == 4) else if (selectedOption == 4)
wrapChar(&(++currentGame.autoSaveSlot), -1, 4); wrapChar(&(++currentGame.autoSaveSlot), -1, 4);
@ -499,7 +489,7 @@ int doTitle()
break; break;
} }
} }
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
} }
delayFrame(); delayFrame();
@ -510,7 +500,7 @@ int doTitle()
SDL_FreeSurface(prlogo); SDL_FreeSurface(prlogo);
SDL_FreeSurface(sflogo); SDL_FreeSurface(sflogo);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
resetLists(); resetLists();
@ -578,7 +568,7 @@ void showStory()
flushBuffer(); flushBuffer();
flushInput(); flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
while (true) while (true)
{ {
@ -587,7 +577,7 @@ void showStory()
getPlayerInput(); getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE])) if ((engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE]))
break; break;
if (textShape[8].y > (screen->h / 2) + 150) if (textShape[8].y > (screen->h / 2) + 150)
@ -617,7 +607,7 @@ void gameover()
freeGraphics(); freeGraphics();
SDL_FillRect(background, NULL, black); SDL_FillRect(background, NULL, black);
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
engine.gameSection = SECTION_INTERMISSION; engine.gameSection = SECTION_INTERMISSION;
loadMusic("music/Wybierak.mod"); loadMusic("music/Wybierak.mod");
@ -641,13 +631,13 @@ void gameover()
updateScreen(); updateScreen();
flushInput(); flushInput();
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
while (true) while (true)
{ {
getPlayerInput(); getPlayerInput();
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE])) if ((engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE]))
break; break;
updateScreen(); updateScreen();
@ -736,7 +726,7 @@ void doCredits()
lastCredit = numberOfCredits - 1; lastCredit = numberOfCredits - 1;
engine.keyState[SDLK_ESCAPE] = 0; engine.keyState[KEY_ESCAPE] = 0;
flushInput(); flushInput();
while (true) while (true)
@ -745,13 +735,13 @@ void doCredits()
unBuffer(); unBuffer();
getPlayerInput(); getPlayerInput();
if (engine.keyState[SDLK_ESCAPE]) if (engine.keyState[KEY_ESCAPE])
break; break;
float speed = 0.5; float speed = 0.5;
if(engine.keyState[SDLK_DOWN]) if(engine.keyState[KEY_DOWN])
speed = 2; speed = 2;
else if(engine.keyState[SDLK_UP]) else if(engine.keyState[KEY_UP])
speed = -2; speed = -2;
for (int i = 0 ; i < numberOfCredits ; i++) for (int i = 0 ; i < numberOfCredits ; i++)