#include <iostream>
#include <cstdlib>
#include <SDL/SDL.h>
#include "eventLoop.h"
#include "menuFire.h"

int main ( int argc, char** argv )
{
    int error(0);
    while (optionsFire::continuer)
/* */{
    //Menu
    error=menuFire();

    // Initialisation de la SDL
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        error=1;
    }

    // Lorsque le programme ferme, la SDL se ferme automatiquement.
    atexit(SDL_Quit);

    // create a new window
    SDL_WM_SetIcon(SDL_LoadBMP("Images/Icone Prog D.bmp"),NULL);//Icone en haut à droite de la fenêtre.
    SDL_Surface* screen =0;
    if(optionsFire::pleinEcran)
    {
        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);//Création de la fenêtre plein ecran
    }
    else
    {
        screen = SDL_SetVideoMode(640, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF);//Création de la fenêtre
    }

    SDL_WM_SetCaption("Fire !!!",NULL);//Nom de la fenêtre
    if ( !screen )
    {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        error=1;
    }

    if (!error)
    {
        eventLoop(screen);
    }
    else if(error==2)
    {
        error=0;
    }

/* */}

    // all is well ;)
    printf("Exited cleanly\n");
    return error;
}
