#include "SDL/SDL.h"

SDL_Surface *load_image( const char * filename )
{
    //Temporary storage for the image that's loaded
    SDL_Surface* loadedImage = NULL;

    //The optimized image that will be used
    SDL_Surface* optimizedImage = NULL;

    //Load the image
    loadedImage = SDL_LoadBMP( filename );

    //If nothing went wrong in loading the image
    if( loadedImage != NULL )
    {
        //Create an optimized image
        optimizedImage = SDL_DisplayFormat( loadedImage );

        //Free the old image
        SDL_FreeSurface( loadedImage );
    }

    //Return the optimized image
    return optimizedImage;
}

int main()
{
    SDL_Init( SDL_INIT_EVERYTHING );

    SDL_Event event;

    SDL_Surface * screen = SDL_SetVideoMode( 512, 256, 8, SDL_SWSURFACE );

    SDL_Surface * wall = load_image("wall.bmp");
    SDL_Surface * door = load_image("door.bmp");
    SDL_Surface * stair = load_image("stair.bmp");

    bool quit = false;
    while( quit == false )
    {
        //While there's an event to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        SDL_Rect where = {0,0,64,32};
        SDL_BlitSurface( wall, 0, screen, &where );


        SDL_Flip( screen )
    }

    return 0;
}
