Ejemplo n.º 1
0
void pollEvent() {
  SDL_Event e;
  while(SDL_PollEvent(&e) != 0) {
    switch(e.type) {
      case SDL_QUIT:
        quitSDL();
        break;
      case SDL_KEYDOWN:
        if(e.key.keysym.scancode == SDL_SCANCODE_F12) {
          rb_raise(rb_eRGSSReset, "F12 pressed");
        }
        break;
      case SDL_KEYUP:
      case SDL_WINDOWEVENT:
      case SDL_TEXTEDITING:
      case SDL_TEXTINPUT:
      case SDL_MOUSEMOTION:
      case SDL_MOUSEBUTTONDOWN:
      case SDL_MOUSEBUTTONUP:
      case SDL_MOUSEWHEEL:
        // don't do anything
        break;
      default:
        fprintf(stderr, "Unknown event\n");
        break;
    }
  }
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
	app = new App();
	app->video.width = 1024;
	app->video.height = 640;
	app->video.pixel_scale = 1.0f;

	// set preferences_filepath and read preferences
	char *pref_path = SDL_GetPrefPath(COMPANY_NAME, APPLICATION_NAME);

	size_t preferences_ini_str_len = strlen(pref_path)+strlen("preferences.ini")+1;
	app->preferences_filepath = new char[preferences_ini_str_len];
	strcpy(app->preferences_filepath, pref_path);
	strcat(app->preferences_filepath, "preferences.ini");
	size_t session_ini_str_len = strlen(pref_path)+strlen("session.ini")+1;
	app->session_filepath = new char[session_ini_str_len];
	strcpy(app->session_filepath, pref_path);
	strcat(app->session_filepath, "session.ini");
	size_t imgui_ini_str_len = strlen(pref_path)+strlen("imgui.ini")+1;
	ImGuiIO& io = ImGui::GetIO();
	char *imgui_ini_filepath = new char[imgui_ini_str_len];
	strcpy(imgui_ini_filepath, pref_path);
	strcat(imgui_ini_filepath, "imgui.ini");
	io.IniFilename = imgui_ini_filepath;

	SDL_free(pref_path);
	app->readPreferences();
	app->readSession();

	initSDL(&app->video);

	ImGui_ImplSdlGL2_Init(sdl_window);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	app->init();

	// init this last for sake of last_ticks
	frametime.init();

	do {
		Uint32 beginTicks = SDL_GetTicks();
		mainLoop();
		// hack for when vsync isn't working
		Uint32 elapsedTicks = SDL_GetTicks() - beginTicks;
		if (elapsedTicks < 16) {
			SDL_Delay(16 - elapsedTicks);
		}
	} while(!app->quit);

	app->beforeQuit();

	ImGui_ImplSdlGL2_Shutdown();
	quitSDL();

	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {

	if (!initSDL())
		return 1;

	MyWindow *window = new MyWindow("Running animation");
	window->show();

	quitSDL();
	return 0;
}
Ejemplo n.º 4
0
int main(int argc, char* argv[])
{
    initializeSDL();
    // Start Menu
    titleSurface = TTF_RenderText_Solid(silkscreen, "Simple Pong", white);
    titleTexture = SDL_CreateTextureFromSurface(renderer, titleSurface);
    titleRect.w = 512;
    titleRect.h = 128;
    titleRect.x = SCREEN_WIDTH / 2 - titleRect.w / 2;
    titleRect.y = 25;
    // Start Button
    startButtonSurface = TTF_RenderText_Solid(silkscreen, "Start", white);
    startButtonTexture = SDL_CreateTextureFromSurface(renderer, startButtonSurface);
    startButtonRect.w = 128;
    startButtonRect.h = 48;
    startButtonRect.x = SCREEN_WIDTH / 2 - startButtonRect.w / 2;
    startButtonRect.y = SCREEN_HEIGHT / 2;

    defineRects();

    while(!quit) // Main Loop
    {
        while(SDL_PollEvent(&e) != 0)
        {
            if(e.type == SDL_QUIT) quit = 1;
        }

        getKeystates();

        switch(screen)
        {
            case 0: // Start Menu
                clearScreen();
                renderStartMenu();
                break;
            case 1: // Game
                ballPhysics();
                clearScreen();
                renderGame();
                break;
            case 2: // Pause Menu
                clearScreen();
                SDL_RenderCopy(renderer, startMessageTexture, NULL, &startMessageRect);
                renderGame();
                break;
        }

        SDL_Delay(2); // Slow down the loop.
    }

    quitSDL(); // Quit all SDL subsystems and free memory.
    return 0;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[]) {
	printf("%s %d",argv[0],argc);
	dataStore *test = calloc(1,sizeof(dataStore));
	highscoreTestdata(test);
	SDL_Surface* screen=initSDL();
	readDataStore(test);
	menuStart(screen, test);
	saveDataStore(test);
	/* just for testing*/
	makeTestData(test);
	//createRandomField(test);
	updateGraphics(screen,test);
	graphicLoop(screen,test);
//	gameloop(test,screen);
	quitSDL();
//	free(test);
	return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv) {

	if (!initSDL())
		return 1;

	if (!loadMedia())
		return 2;

	initViewportRect();

	bool running = true;
	SDL_Event e;

	while (running) {
		while (SDL_PollEvent(&e)) {
			if (e.type == SDL_QUIT)
				running = false;
		}

		SDL_RenderClear(renderer);

		SDL_RenderSetViewport(renderer, &topLeftViewport);
		SDL_RenderCopy(renderer, texture, NULL, NULL);

		SDL_RenderSetViewport(renderer, &topRightViewport);
		SDL_RenderCopy(renderer, texture, NULL, NULL);

		SDL_RenderSetViewport(renderer, &bottomViewport);
		SDL_RenderCopy(renderer, texture, NULL, NULL);

		SDL_RenderPresent(renderer);
	}

	quitSDL();
	return 0;
}
Ejemplo n.º 7
0
int displayAbout(SDL_Surface *screen, dataStore *data)
{
	int done, mouseX, mouseY;
	SDL_Event event;

	SDL_Color textColor = { 255, 255, 255,0};
	
	SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ));

	myButton button;
	button.rect.x = screen->clip_rect.w/2-BUTTONWIDTH/2;
	button.rect.y = screen->clip_rect.h-BUTTONHEIGHT-100;
	button.rect.w = BUTTONWIDTH;
	button.rect.h = BUTTONHEIGHT;
	button.name="Back";
	
	drawButton(screen, &button);
	
	TTF_Font *font = theFont(20);
	char aboutText[10][100] = {"Hedgewood is a game written by:"," - toco"," - tk"," - JTR"," "," we hope you enjoy it."," ","Thanks to:"," - friend of tk for the grapics"," - our great tutor Arne"};
	
	if (!(renderMultiLineText(font, 150, 100, &aboutText[0],10, textColor,screen)))
		printf("%s\n",TTF_GetError());
	
	
	SDL_Flip(screen);
	TTF_CloseFont(font);

//	SDL_FreeSurface(message);
	unsigned int startTime, stopTime, diffTime;
	unsigned int innerStartTime, innerStopTime;
	
	done = 0;
	while ( !done ) {
		startTime = SDL_GetTicks();
		/* Check for events */
		while ( SDL_PollEvent(&event) ) {
			innerStartTime = SDL_GetTicks();
			switch (event.type) {
					
				case SDL_MOUSEMOTION:
					break;
				case SDL_MOUSEBUTTONUP:
					
					SDL_GetMouseState(&mouseX,&mouseY);
					if (isButtonClicked(&button, mouseX, mouseY)) {
						
						done = 1;
					}
#if (DEBUG==1)
					printf("Cusor-Position x: %d y: %d\n",mouseX,mouseY);
#endif
					break;
				case SDL_KEYDOWN:
					/* Any keypress quits the app... */
					switch( event.key.keysym.sym )
				{
					case SDLK_f:
						break;
						
					case SDLK_0:
						printf ("Music off\n");
						Mix_HaltMusic();
						Mix_HaltChannel(-1);
						data->soundEnabled=0;
						break;
					case 	SDLK_m:
						printf ("Music on /Pause\n");				
						if( Mix_PlayingMusic() == 0 )  
							Mix_PlayMusic( data->ingamemusic, -1);			
						if( Mix_PausedMusic() == 1 )
							Mix_ResumeMusic(); 
						else Mix_PauseMusic();						
						break;
					case SDLK_ESCAPE:
					case SDLK_q:
						done = 1;
						quitSDL(data);
						break;
					default:
						break;
						
				}	
					break;
/*				case SDL_QUIT:
					done = 1;
					break;
*/				default:
					break;
			}
			innerStopTime = SDL_GetTicks();
			diffTime=(innerStopTime-innerStartTime);
			//25 Frames per second (40 Milliseconds per frame)
			if (MS_FRAMETIME>diffTime) 
				SDL_Delay(MS_FRAMETIME-diffTime);
		}
		stopTime = SDL_GetTicks();
		diffTime = (stopTime-startTime);
		//25 Frames per second (40 Milliseconds per frame)
		if (MS_FRAMETIME>diffTime) 
			SDL_Delay(MS_FRAMETIME-diffTime);
		
	}
	return 0;
}
Ejemplo n.º 8
0
int main (int argc, char** argv)
{
	if(argc>1)
	{
		OSCConn::setServer(argv[1]);
		if(argc>2)
		{
			OSCConn::setPort(atoi(argv[2])); 
		}
	}
	else
	{
		if(getSCPath() && launchSuperCollider());
		else
		{
			fprintf(stderr, "Cant get sclang patch - exiting\n");
			exit(0);
		}
	}
	
	registerEffects();
	registerControllers();
	
	if(!OSCConn::connect()) exit(1);
	
	if(!OSCConn::startServer()) exit(2);
	
	if(!checkEffectsList()) {OSCConn::quitServer(); exit(3);}
	
	saveSCPath();
	
	initSDL();
	
	effectCreator.init();
	
	recordingInfoTex=generateText("Recording", COLOR_SELECTED_TEXT);
	
	auto effectInstanceList=getEffectInstanceList();
	
	auto controllerInstanceList=getControllerInstanceList();
	
	
	while (!checkInputs())
	{
		for(auto it=controllerInstanceList->rbegin();it!=controllerInstanceList->rend();++it)
		{
			it->second->step();
		}
		
		setColor(COLOR_CLEARCOLOR);
		SDL_RenderClear(render);
		drawRecordingInfo();
		
		for(auto it=effectInstanceList->begin();it!=effectInstanceList->end();++it)
		{
			it->second->doSomething();
		}
		
		for(auto it=effectInstanceList->begin();it!=effectInstanceList->end();++it)
		{
			it->second->draw();
		}
		
		for(auto it=controllerInstanceList->rbegin();it!=controllerInstanceList->rend();++it)
		{
			it->second->draw();
		}

		drawConnections();
		
		int screen_width;
		SDL_GetWindowSize(window, &screen_width, NULL);

		effectCreator.draw(screen_width-EffectCreator::menu_period, 0);
		
		SDL_RenderPresent(render);
	}
	
	Effect::saveToFile("last_session.cello");
	
	Effect::clearAll();
	
	quitSDL();
	
	OSCConn::quitServer();
	fprintf(stderr, "Done\n");
}
Ejemplo n.º 9
0
int gameloop(dataStore *data,SDL_Surface *screen) {
	createRandomField(data);
	clock_t innerStartTime, innerStopTime, startTime, stopTime, diffTime,mouseTime,mT,mousetimewait=500;
	int done=0,i=0,aVal,motionPath=0,runPath=0,drawPath=0,mouseDown=0,ownpath=0;
	position *lastmouse=NULL,*mouse_pos=NULL,*tmp=NULL,*lastpath=NULL;
	SDL_Event event;

	// MUSIC FADEOUT AND IN
	//Mix_HaltMusic();	 
		Mix_PlayMusic( data->ingamemusic, -1);
	
	
	GraphicUpdate(screen,data);
	while (!done) {
		
		/* Check for events */
		startTime = SDL_GetTicks();
		while ( SDL_PollEvent(&event) ) {
			innerStartTime = SDL_GetTicks();
			switch (event.type) {
				case SDL_QUIT:
					done = 1;
					quitSDL(data);
					break;
				case SDL_MOUSEMOTION:
					//Prüft ob sich die Maus aus dem 50x50 Feld bewegt hat
					mouse_pos=calloc(1,sizeof(struct position));
					SDL_GetMouseState(&mouse_pos->x,&mouse_pos->y);
					if(mouse_pos->x > 24 && 226 > mouse_pos->x && mouse_pos->y > 24 && 51 >  mouse_pos->y) {
						aStar(data,&(data->home));
						GraphicUpdate(screen,data);
						positionListDelete(data);
						break;
					} else if(mouse_pos->x > 574 && 776 > mouse_pos->x && mouse_pos->y > 24 && 51 > mouse_pos->y) {
						aStar(data,&(data->stash));
						GraphicUpdate(screen,data);
						positionListDelete(data);
						break;
					} else {
						mouse_pos=pixelToGrid(mouse_pos);
						if(lastmouse!=NULL && mouseDown) {
							if(lastmouse->x!=mouse_pos->x || lastmouse->y!=mouse_pos->y || ownpath==0) {
								tmp=calloc(1,sizeof(struct position));
								tmp->x=mouse_pos->x+data->horizontalScroll;
								tmp->y=mouse_pos->y+data->verticalScroll;
								if(data->player.anfang!=NULL&& data->hedgewood[tmp->y][tmp->x].aStarValue*data->hedgewood[tmp->y][tmp->x].visible>-1 && aStarManhatten(*lastpath,*tmp)==AVGASTAR) {
									lastpath=tmp;
									positionQListAdd(data,tmp);
									ownpath++;
									GraphicUpdate(screen,data);
								} else {
									if(tmp->x==data->player.p_pos.x && tmp->y==data->player.p_pos.y) {
										lastpath=tmp;
										positionQListAdd(data,tmp);
										ownpath++;
										GraphicUpdate(screen,data);
									} else if(lastmouse->x!=mouse_pos->x || lastmouse->y!=mouse_pos->y)printf("Die Startposition muss die Spielerposition sein\n");
								}
								//free(tmp);
							}
						} else if(lastmouse!=NULL && ownpath==0) {
							if(lastmouse->x!=mouse_pos->x || lastmouse->y!=mouse_pos->y)mouseTime=SDL_GetTicks(),drawPath=1;
							else {
								if(drawPath) {
									mT=SDL_GetTicks();
									if((mouseTime + mousetimewait)< mT) {
										motionPath=1;
									}
								}
							}
						} else if(ownpath==0) {
							mouseTime = SDL_GetTicks();
							drawPath=1;
							if((lastmouse=calloc(1,sizeof(position))) == NULL) {
								printf("Kein Speicherplatz vorhanden fuer position\n");
								return -1;
							}
						}
						memcpy(lastmouse,mouse_pos,sizeof(position));
					}
					free(mouse_pos);
					break;
				case SDL_MOUSEBUTTONDOWN:
					mouseDown=1;
					if(DEBUG)printf("MOUSE DOWN\n");
					break;
				case SDL_MOUSEBUTTONUP:
					if(ownpath>0) {
						runPath=1;
						mouseDown=0;
						break;
					}
					mouseDown=0;
					mouse_pos=calloc(1,sizeof(struct position));
					SDL_GetMouseState(&mouse_pos->x,&mouse_pos->y);
					printf("Cusor-Position x: %d y: %d\n",mouse_pos->x,mouse_pos->y);
					if(mouse_pos->x > 24 && 226 > mouse_pos->x && mouse_pos->y > 24 && 51 >  mouse_pos->y) {
						aStar(data,&(data->home));
						runPath=1;
						break;
					} else if(mouse_pos->x > 574 && 776 > mouse_pos->x && mouse_pos->y > 24 && 51 > mouse_pos->y) {
						aStar(data,&(data->stash));
						runPath=1;
						break;
					} else {
						mouse_pos=pixelToGrid(mouse_pos);
						if(DEBUG)printf("Cusor-Feld x: %d y: %d\n",mouse_pos->x,mouse_pos->y);
						if(lastmouse==NULL) {
							if((lastmouse=calloc(1,sizeof(position))) == NULL) {
								printf("Kein Speicherplatz vorhanden fuer position\n");
								return -1;
							}
						}
						memcpy(lastmouse,mouse_pos,sizeof(position));
						free(mouse_pos);
						mouse_pos=NULL;
						motionPath=1;
						runPath=1;
						break;
					}
					
				case SDL_KEYDOWN:
					switch( event.key.keysym.sym ) {
						case 	SDLK_m:
							
							if( Mix_PlayingMusic() == 0 )  
								Mix_PlayMusic( data->ingamemusic, -1);
							
							if( Mix_PausedMusic() == 1 )
								Mix_ResumeMusic(); 
							else Mix_PauseMusic(); 
							
							break;
						case SDLK_s:
							if (data->soundEnabled) {
								Mix_HaltChannel(-1);
							}
							data->soundEnabled=!data->soundEnabled;
							
							break;

						case SDLK_0:
							printf ("Music off\n");
							Mix_HaltMusic();
							Mix_HaltChannel(-1);
							data->soundEnabled=0;
							
							break;
							
							
						case SDLK_ESCAPE:
							done = ingameMenuStart(screen, data);
							if (!done)
								GraphicUpdate(screen, data);
							break;
						case SDLK_q:
							done = 1;
							break;
						default:
							break;
					}
					break;
				default:
					break;
			}
			innerStopTime = SDL_GetTicks();
			diffTime=(innerStopTime-innerStartTime);
			if (MS_FRAMETIME>diffTime)SDL_Delay(MS_FRAMETIME-diffTime);
		}
		mT=SDL_GetTicks();
		if((mouseTime + mousetimewait)< mT && lastmouse!=NULL && ownpath==0 &&runPath==0) {
			motionPath=1;
		}
		if((motionPath || runPath) && !done) {
			if(motionPath) {
				lastmouse->y+=data->verticalScroll;
				lastmouse->x+=data->horizontalScroll;
				aStar(data,lastmouse);
				if(DEBUG)printf("Player-Feld x: %d y: %d\n",data->player.p_pos.x,data->player.p_pos.y);
				GraphicUpdate(screen, data);
				free(lastmouse);
				lastmouse=NULL;
				motionPath=0;
				drawPath=0;
			}
			if(runPath) {
				i=1;
				tmp=data->player.anfang;
				/*sound*/
				if(data->soundEnabled&&data->player.cutSpeed>=2)
					Mix_PlayChannel(CHAINSAWCHANNEL1, data->chainpause, -1);
				while(tmp!=NULL&&i) {
					//Schleife um die Laufbewegung Abzubrechen
					while ( SDL_PollEvent(&event) ) {
						switch (event.type) {
							case SDL_MOUSEBUTTONUP:
								i=0;
								break;
							case SDL_KEYDOWN:
								switch( event.key.keysym.sym ) {
										
										
									case 	SDLK_m:
										printf ("Music on /Pause\n");				
										if( Mix_PlayingMusic() == 0 )  
											Mix_PlayMusic( data->ingamemusic, -1);			
										if( Mix_PausedMusic() == 1 )
											Mix_ResumeMusic(); 
										else Mix_PauseMusic();						
										break;
									case SDLK_s:
										if (data->soundEnabled) {
											Mix_HaltChannel(-1);
										}
										data->soundEnabled=!data->soundEnabled;

										break;
									case SDLK_0:
										printf ("Music off\n");
										Mix_HaltMusic();
										Mix_HaltChannel(-1);
										data->soundEnabled=0;
										break;
									case SDLK_ESCAPE:
										i=0;
										break;
									default:
										break;
								}
							default:
								break;
						}
					}
					tmp=positionListRead(data);
					if(tmp!=NULL) {
						if(DEBUG)printf("Position Stack x: %d y: %d\n",tmp->x,tmp->y);						
						if(headPositionUpdate(data,tmp,screen)) {
							aVal=data->hedgewood[data->player.p_pos.y][data->player.p_pos.x].aStarValue;
							if(aVal>0) {
								data->player.currentEnergy-=aVal;
								if(data->player.currentEnergy<0) {
									printf("YOU ARE DEAD\nNEW GAME\n");
									done=1;
									i=0;
								} else {
									data->hedgewood[data->player.p_pos.y][data->player.p_pos.x].type=6;
									data->hedgewood[data->player.p_pos.y][data->player.p_pos.x].aStarValue=2;
									data->player.bp.currentVolume+=data->hedgewood[data->player.p_pos.y][data->player.p_pos.x].currency;
									if(data->player.bp.currentVolume > data->player.bp.maxVolume) data->player.bp.currentVolume=data->player.bp.maxVolume;
									data->hedgewood[data->player.p_pos.y][data->player.p_pos.x].currency=0;
								}
							}
							if(!done)GraphicUpdate(screen,data);
						} else positionListDelete(data);
					}
				}
				/*sound off*/
				Mix_HaltChannel(CHAINSAWCHANNEL1);

				runPath=0;
				ownpath=0;
			}
			positionListDelete(data);
		}
		stopTime = SDL_GetTicks();
		diffTime = (stopTime-startTime);
		if (MS_FRAMETIME>diffTime)SDL_Delay(MS_FRAMETIME-diffTime);
	}

	addHighscore(screen,data,calcHighscore(data));	
	return 0;
	
	
}
Ejemplo n.º 10
0
//MAIN//
int main( int argc, char* args[] ) {
	//Init Rand to clock 
	srand ( time(NULL) );	
    //Initialize Window
    initSDLWindow( SCREENWIDTH, SCREENHEIGHT, SCREENBPP );
	
    //Load Files
	loadFiles();
	//Create Text
	createText();
	
	//Init classes
    Timer fps;
	Level *theLevel;


    //GAME LOOP//
    while( run ) {
        //Start the frame timer
        fps.start();

		//Init Events for keyboard 
		initSDLEvents();
		
        //Apply the background
        applySurface( 0, 0, background, screen, NULL );
		//MENU
		if ( menu ) {
			applySurface( ( SCREENWIDTH - menuTitle->w ) / 2, (SCREENHEIGHT / 5), menuTitle, screen, NULL );
			applySurface( ( SCREENWIDTH - menuScreen->w ) / 2, (SCREENHEIGHT / 6)*4, menuScreen, screen, NULL );
			if (initSDLEvents() == 'e') {
				menu = 0;
				game = 1;
				theLevel = new Level(screen, SCREENWIDTH, SCREENHEIGHT);
			}
	
		}//MENU END
		//GAME
		if ( game ) {
			
			if ((theLevel->play(frame)) == true) {
				menu = 1;
				game = 0;
				delete theLevel;
			}
			
		}//GAME END

        //Update the screen
        if( SDL_Flip( screen ) == -1 ) {
            return 1;
        }
		//Set frame rate
		setTimer( fps, FRAMESPERSECOND, frame, true );
		
		//check for quit
		checkQuit(initSDLEvents());	
    }//GAME LOOP END//
	
    //Clean up
	quitSDL();
	
    return 0;
}//END MAIN//
Ejemplo n.º 11
0
int chargerSimulation (Simulation *sim, char* saveName)
{
    FILE* saveFile = NULL;
    int map_charger, espece_charger;
    char chaine [TAILLE_MAX];
    int taille=0, i=0;
    char** tab;
    char* nomSimulation;
    CHARGEMENT* sdl_chargement;

    if(sim->sdlInitialisee == 0)
    {
        nomSimulation=enleverChemin(saveName);
        if(strcmp(nomSimulation,"nouvelle simulation") == 0)
        {
            free(sim->nomSimulation);
        }
        strcpy(sim->nomSimulation,nomSimulation);

        initSDL(sim,true);
        sdl_chargement=initChargement();
        actualiserChargement(sim,sdl_chargement,"chargement...","...des diiférentes espèces et différents individus",10,1);

        //vidage de la memoire atribué à la map, si c'est le cas
        if(sim->map.mapInitialisee == true)
        {
            deleteMap (&(sim->map));
        }

        //vidage de la memoire attribué aux especes et individus
        supprimerEspeceEtIndividu(&(sim->premiereEspece));

        //On ouvre le fichier
        saveFile = fopen(saveName, "r");

        if(saveFile != NULL)
        {
            // initialisation de la liste
            sim->premiereEspece = NULL;
            sim->nombreEspeces = 0;

            sim->genererNouvelleMap = 0;
            sim->genererPosEspeces = 0;

            tab=initTableauChaineCaractrere();

            for(i=0;i<3;i++)
            {
                fgets(chaine, TAILLE_MAX, saveFile);
                tab=augmenterTailleTabChaineCaractere((i+1),tab,1);

                strcpy(tab[i],chaine);
            }

            sim->tempsPasse=atof(tab[0]);
            sim->annee=atof(tab[1]);
            sim->mois=atof(tab[2]);

            supprimerTabChaineCaractere(tab,taille,1);

            espece_charger=chargerEspece(&sim->premiereEspece,saveFile);
            SDL_Delay(100);

            actualiserChargement(sim,sdl_chargement,"chargement...","...du terrain de la simulation",10,1);
            SDL_Delay(100);
            map_charger=chargerMap(sim, &(sim->map), saveFile, sdl_chargement);

            actualiserChargement(sim,sdl_chargement,"chargement...","...incorporation des animaux et végétaux sur le terrain",100,1);
            SDL_Delay(500);

            supprimerChargement(sdl_chargement);

            //On ferme le fichier
            fclose(saveFile);

            quitSDL(sim,true);


            if(map_charger == 0 || espece_charger == 0)
            {
                return 0;
            }

            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 0;
    }
}