SDL key presses

It compiles, but isn't responding to key presses

#include "SDL.h"
#include <string>

using namespace std;

void applysurface(int x, int y, SDL_Surface *source, SDL_Surface *destination)
{
SDL_Rect offset;

offset.x = x;
offset.y = y;

SDL_BlitSurface (source, NULL, destination, &offset);
}

int main( int argc, char* args[] )
{
SDL_Surface *home;
SDL_Surface *up;
SDL_Surface *down;
SDL_Surface *left;
SDL_Surface *right;
SDL_Surface *screen;
bool quit=false;

SDL_Init (SDL_INIT_EVERYTHING);



screen = SDL_SetVideoMode (1000, 1200, 32, SDL_SWSURFACE);

up = SDL_LoadBMP ("up.bmp");
down =SDL_LoadBMP ("down.bmp");
left= SDL_LoadBMP ("left.bmp");
right =SDL_LoadBMP ("right.bmp");
home =SDL_LoadBMP ("home.bmp");

SDL_BlitSurface (home, NULL, screen, NULL);
SDL_Event event;


while (quit ==false)
{
if (SDL_PollEvent(&event))
{
if (event.type==SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
{
case SDLK_UP:

applysurface (0, 0, up, screen);
break;

case SDLK_DOWN:

applysurface (0, 0, down, screen);
break;

case SDLK_LEFT:

applysurface (0, 0, left, screen);
break;

case SDLK_RIGHT:

applysurface (0, 0, right, screen);
break;


}
}

if (event.type==SDL_QUIT)
{
quit= true;
}

if( SDL_Flip( screen ) == -1 )
{
return 1;
}
}

}

return 0;
}

This program still has the console loaded, right? My first step would be to do some simple cout instead of applySurface. This would at least tell me that the error wasn't in that function.
There is nothing wrong with the code (except you forgot to call SDL_Quit). Do you see the home image being dawn? If not, the problem is most likely that it couldn't find the image files.
Topic archived. No new replies allowed.