scene_loader.c
SceneData* GetInnitialScenesData(){
	// Mallocate array. Data space for every scene
	SceneData* InnitScenesData = malloc(SCENE_TOTAL_COUNT * sizeof(SceneData)); // WILL HAVE TO BE DESTOYED ON QUIT
	
	if(InnitScenesData == NULL){ // Check malloc
		printf("ERROR: Could not mallocate 'InnitScenesData'\n");
		exit(EXIT_FAILURE);
	}
	
	// Load background images and others for every scene. Look 'scene_loader.h' for more info
	// MAIN MENU
	LoadPNG2Canvas(PATH_TO_IMG_SCENE_MENU, &(InnitScenesData[SCENE_MENU].scene_canvas));
	LoadPNG2Canvas(PATH_TO_IMG_SCOPE, &(InnitScenesData[SCENE_MENU].scope_canvas));
	
	// GAME MAP
	LoadPNG2Canvas(PATH_TO_GAME_MAP, &(InnitScenesData[SCENE_GAME_MAP].scene_canvas));
	LoadPNG2Canvas(PATH_TO_PLAYER_1_TANK, &(InnitScenesData[SCENE_GAME_MAP].player_1_tank));
	LoadPNG2Canvas(PATH_TO_PLAYER_2_TANK, &(InnitScenesData[SCENE_GAME_MAP].player_2_tank));
	// GAME MAP -> explosion	
	//LoadPNG2Canvas(PATH_TO_EXPLOSION_IMG, &(InnitScenesData[SCENE_GAME_MAP].explosion));
	
	InnitScenesData[1].scene_id = SCENE_MENU;
	
	// Malloc map array
	InnitScenesData[SCENE_GAME_MAP].game_map_array = malloc(DISPLAY_WIDTH*sizeof(unsigned int));
	
	// Set initial scene to unknown
	CURRENT_SCENE = -1;
	
	return 	InnitScenesData;
}
// Load all images to SceneData struct and return
Load all images to SceneData struct and return
Load all images to SceneData struct and return
SceneData* GetInnitialScenesData(){
	SceneData* InnitScenesData = malloc(SCENE_TOTAL_COUNT * sizeof(SceneData)); 
	if(InnitScenesData == NULL){ 
		printf("ERROR: Could not mallocate 'InnitScenesData'\n");
		exit(EXIT_FAILURE);
	}
	LoadPNG2Canvas(PATH_TO_IMG_SCENE_MENU, &(InnitScenesData[SCENE_MENU].scene_canvas));
	LoadPNG2Canvas(PATH_TO_IMG_SCOPE, &(InnitScenesData[SCENE_MENU].scope_canvas));
	LoadPNG2Canvas(PATH_TO_GAME_MAP, &(InnitScenesData[SCENE_GAME_MAP].scene_canvas));
	LoadPNG2Canvas(PATH_TO_PLAYER_1_TANK, &(InnitScenesData[SCENE_GAME_MAP].player_1_tank));
	LoadPNG2Canvas(PATH_TO_PLAYER_2_TANK, &(InnitScenesData[SCENE_GAME_MAP].player_2_tank));
	 -> explosion	
	InnitScenesData[1].scene_id = SCENE_MENU;
	InnitScenesData[SCENE_GAME_MAP].game_map_array = malloc(DISPLAY_WIDTH*sizeof(unsigned int));
	CURRENT_SCENE = -1;
	return 	InnitScenesData;
}
SceneData * GetInnitialScenesData ( ) { SceneData * InnitScenesData = malloc ( SCENE_TOTAL_COUNT * sizeof ( SceneData ) ) ; if ( InnitScenesData == NULL ) { printf ( " \n " ) ; exit ( EXIT_FAILURE ) ; } LoadPNG2Canvas ( PATH_TO_IMG_SCENE_MENU , & ( InnitScenesData [ SCENE_MENU ] . scene_canvas ) ) ; LoadPNG2Canvas ( PATH_TO_IMG_SCOPE , & ( InnitScenesData [ SCENE_MENU ] . scope_canvas ) ) ; LoadPNG2Canvas ( PATH_TO_GAME_MAP , & ( InnitScenesData [ SCENE_GAME_MAP ] . scene_canvas ) ) ; LoadPNG2Canvas ( PATH_TO_PLAYER_1_TANK , & ( InnitScenesData [ SCENE_GAME_MAP ] . player_1_tank ) ) ; LoadPNG2Canvas ( PATH_TO_PLAYER_2_TANK , & ( InnitScenesData [ SCENE_GAME_MAP ] . player_2_tank ) ) ; InnitScenesData [ 1 ] . scene_id = SCENE_MENU ; InnitScenesData [ SCENE_GAME_MAP ] . game_map_array = malloc ( DISPLAY_WIDTH * sizeof ( unsigned int ) ) ; CURRENT_SCENE = -1 ; return InnitScenesData ; }
Load all images to SceneData struct and return
Load all images to SceneData struct and return
// Mallocate array. Data space for every scene // WILL HAVE TO BE DESTOYED ON QUIT // Check malloc // Load background images and others for every scene. Look 'scene_loader.h' for more info // MAIN MENU // GAME MAP // GAME MAP -> explosion	 //LoadPNG2Canvas(PATH_TO_EXPLOSION_IMG, &(InnitScenesData[SCENE_GAME_MAP].explosion)); // Malloc map array // Set initial scene to unknown