scene_loader.c
void RefreshScene(SceneData* scene_data, Canvas* game_canvas){

	// Load background
	RGB transparent = {.R = 0, .G = 0, .B = 0}; // Wont have effect on scene
	Canvas2CanvasFull(&(scene_data[CURRENT_SCENE].scene_canvas), game_canvas, 0, 0, false, &transparent);
	///////////////////
		

	if(CURRENT_SCENE == SCENE_MENU){ // We are currenty in main menu
		//////////// Draw text
		RGB color_black = {.R = 0, .G = 0, .B = 0};
		DrawText(game_canvas, "PLAY", 350, 70, 5, &color_black);
		DrawText(game_canvas, "WIND", 320, 110, 5, &color_black);
		if(scene_data[SCENE_MENU].wind_on == true){
			DrawText(game_canvas, "ON", 403, 110, 5, &color_black);
		}else{
			DrawText(game_canvas, "OFF", 390, 110, 5, &color_black);
		}
		DrawText(game_canvas, "TANKS", 340, 220, 5, &color_black);
		DrawText(game_canvas, "PLAYER 1:", 305, 250, 5, &color_black);
		DrawText(game_canvas, "PLAYER 2:", 305, 280, 5, &color_black);
		
		// Convert tanks count to string and draw text
		char p_1_tanks[4], p_2_tanks[4];
		sprintf(p_1_tanks, "%d\n", scene_data[SCENE_MENU].player_1_tanks);
		sprintf(p_2_tanks, "%d\n", scene_data[SCENE_MENU].player_2_tanks);
		DrawText(game_canvas, p_1_tanks, 440, 250, 5, &color_black);
		DrawText(game_canvas, p_2_tanks, 440, 280, 5, &color_black);
		/////////////////////////////////////////////////
		
		// Draw scope
		// Scope transparent background
		transparent.R = 254; transparent.G = 254; transparent.B = 254; 
		
		switch(scene_data[CURRENT_SCENE].knob_menu_position){
			case (KNOB_MENU_PLAY):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 300, 58, true, &transparent);
				break;
			case (KNOB_MENU_WIND):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 270, 98, true, &transparent);
				break;
			case (KNOB_MENU_PLAYER_1):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 250, 238, true, &transparent);
				break;
			case (KNOB_MENU_PLAYER_2):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 250, 268, true, &transparent);
				break;
		}
	}else if(CURRENT_SCENE == SCENE_GAME_MAP){
		
		// Fill map with sand
		FillCavnasWithMapArray(scene_data, game_canvas);
		
		// Set position for tanks
		SetAllTanksPosition(scene_data);
		
		// Add tank images to canvas 'game_canvas'
		FillCanvasWithTanks(scene_data, game_canvas);
		
		// Draw the text with current chosen projectile of active tank
		RGB color_black = {.R = 0, .G = 0, .B = 0};
		if(scene_data[SCENE_GAME_MAP].active_tank->chosen_projectile == PROJECTILE_TYPE_TYPE_CANNON){
			DrawText(game_canvas, "Weapon: Cannon", 160, 20, 3, &color_black);
		}else if(scene_data[SCENE_GAME_MAP].active_tank->chosen_projectile == PROJECTILE_TYPE_TYPE_SNIPER){
			DrawText(game_canvas, "Weapon: Sniper", 160, 20, 3, &color_black);
		}
		
		// Draw parabolic aiming path
		DrawAimPath(scene_data, game_canvas, &color_black);
		
		// Draw health bars
		DrawAllHealthBars(scene_data, game_canvas);
		
		// If we are animating, display the flying projectile
		if(scene_data[SCENE_GAME_MAP].animating){
			DrawProjectile(scene_data, game_canvas, &color_black);
		}
		
		// If wind is on, draw wind speed information
		if(scene_data[SCENE_GAME_MAP].wind_on){
			DrawWindSpeeds(scene_data, game_canvas, &color_black);
		}
	}
	return;
}
/*  This function will refresh entire scene, map, players, shot...  */
This function will refresh entire scene, map, players, shot
This function will refresh entire scene map players shot
void RefreshScene(SceneData* scene_data, Canvas* game_canvas){
	RGB transparent = {.R = 0, .G = 0, .B = 0}; 
	Canvas2CanvasFull(&(scene_data[CURRENT_SCENE].scene_canvas), game_canvas, 0, 0, false, &transparent);
	if(CURRENT_SCENE == SCENE_MENU){ 
		RGB color_black = {.R = 0, .G = 0, .B = 0};
		DrawText(game_canvas, "PLAY", 350, 70, 5, &color_black);
		DrawText(game_canvas, "WIND", 320, 110, 5, &color_black);
		if(scene_data[SCENE_MENU].wind_on == true){
			DrawText(game_canvas, "ON", 403, 110, 5, &color_black);
		}else{
			DrawText(game_canvas, "OFF", 390, 110, 5, &color_black);
		}
		DrawText(game_canvas, "TANKS", 340, 220, 5, &color_black);
		DrawText(game_canvas, "PLAYER 1:", 305, 250, 5, &color_black);
		DrawText(game_canvas, "PLAYER 2:", 305, 280, 5, &color_black);
		char p_1_tanks[4], p_2_tanks[4];
		sprintf(p_1_tanks, "%d\n", scene_data[SCENE_MENU].player_1_tanks);
		sprintf(p_2_tanks, "%d\n", scene_data[SCENE_MENU].player_2_tanks);
		DrawText(game_canvas, p_1_tanks, 440, 250, 5, &color_black);
		DrawText(game_canvas, p_2_tanks, 440, 280, 5, &color_black);
		///////////
		transparent.R = 254; transparent.G = 254; transparent.B = 254; 
		switch(scene_data[CURRENT_SCENE].knob_menu_position){
			case (KNOB_MENU_PLAY):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 300, 58, true, &transparent);
				break;
			case (KNOB_MENU_WIND):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 270, 98, true, &transparent);
				break;
			case (KNOB_MENU_PLAYER_1):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 250, 238, true, &transparent);
				break;
			case (KNOB_MENU_PLAYER_2):
				Canvas2CanvasFull(&(scene_data[SCENE_MENU].scope_canvas), game_canvas, 250, 268, true, &transparent);
				break;
		}
	}else if(CURRENT_SCENE == SCENE_GAME_MAP){
		FillCavnasWithMapArray(scene_data, game_canvas);
		SetAllTanksPosition(scene_data);
		FillCanvasWithTanks(scene_data, game_canvas);
		RGB color_black = {.R = 0, .G = 0, .B = 0};
		if(scene_data[SCENE_GAME_MAP].active_tank->chosen_projectile == PROJECTILE_TYPE_TYPE_CANNON){
			DrawText(game_canvas, "Weapon: Cannon", 160, 20, 3, &color_black);
		}else if(scene_data[SCENE_GAME_MAP].active_tank->chosen_projectile == PROJECTILE_TYPE_TYPE_SNIPER){
			DrawText(game_canvas, "Weapon: Sniper", 160, 20, 3, &color_black);
		}
		DrawAimPath(scene_data, game_canvas, &color_black);
		DrawAllHealthBars(scene_data, game_canvas);
		if(scene_data[SCENE_GAME_MAP].animating){
			DrawProjectile(scene_data, game_canvas, &color_black);
		}
		if(scene_data[SCENE_GAME_MAP].wind_on){
			DrawWindSpeeds(scene_data, game_canvas, &color_black);
		}
	}
	return;
}
void RefreshScene ( SceneData * scene_data , Canvas * game_canvas ) { RGB transparent = { . R = 0 , . G = 0 , . B = 0 } ; Canvas2CanvasFull ( & ( scene_data [ CURRENT_SCENE ] . scene_canvas ) , game_canvas , 0 , 0 , false , & transparent ) ; if ( CURRENT_SCENE == SCENE_MENU ) { RGB color_black = { . R = 0 , . G = 0 , . B = 0 } ; DrawText ( game_canvas , " " , 350 , 70 , 5 , & color_black ) ; DrawText ( game_canvas , " " , 320 , 110 , 5 , & color_black ) ; if ( scene_data [ SCENE_MENU ] . wind_on == true ) { DrawText ( game_canvas , " " , 403 , 110 , 5 , & color_black ) ; } else { DrawText ( game_canvas , " " , 390 , 110 , 5 , & color_black ) ; } DrawText ( game_canvas , " " , 340 , 220 , 5 , & color_black ) ; DrawText ( game_canvas , " " , 305 , 250 , 5 , & color_black ) ; DrawText ( game_canvas , " " , 305 , 280 , 5 , & color_black ) ; char p_1_tanks [ 4 ] , p_2_tanks [ 4 ] ; sprintf ( p_1_tanks , " \n " , scene_data [ SCENE_MENU ] . player_1_tanks ) ; sprintf ( p_2_tanks , " \n " , scene_data [ SCENE_MENU ] . player_2_tanks ) ; DrawText ( game_canvas , p_1_tanks , 440 , 250 , 5 , & color_black ) ; DrawText ( game_canvas , p_2_tanks , 440 , 280 , 5 , & color_black ) ; transparent . R = 254 ; transparent . G = 254 ; transparent . B = 254 ; switch ( scene_data [ CURRENT_SCENE ] . knob_menu_position ) { case ( KNOB_MENU_PLAY ) : Canvas2CanvasFull ( & ( scene_data [ SCENE_MENU ] . scope_canvas ) , game_canvas , 300 , 58 , true , & transparent ) ; break ; case ( KNOB_MENU_WIND ) : Canvas2CanvasFull ( & ( scene_data [ SCENE_MENU ] . scope_canvas ) , game_canvas , 270 , 98 , true , & transparent ) ; break ; case ( KNOB_MENU_PLAYER_1 ) : Canvas2CanvasFull ( & ( scene_data [ SCENE_MENU ] . scope_canvas ) , game_canvas , 250 , 238 , true , & transparent ) ; break ; case ( KNOB_MENU_PLAYER_2 ) : Canvas2CanvasFull ( & ( scene_data [ SCENE_MENU ] . scope_canvas ) , game_canvas , 250 , 268 , true , & transparent ) ; break ; } } else if ( CURRENT_SCENE == SCENE_GAME_MAP ) { FillCavnasWithMapArray ( scene_data , game_canvas ) ; SetAllTanksPosition ( scene_data ) ; FillCanvasWithTanks ( scene_data , game_canvas ) ; RGB color_black = { . R = 0 , . G = 0 , . B = 0 } ; if ( scene_data [ SCENE_GAME_MAP ] . active_tank -> chosen_projectile == PROJECTILE_TYPE_TYPE_CANNON ) { DrawText ( game_canvas , " " , 160 , 20 , 3 , & color_black ) ; } else if ( scene_data [ SCENE_GAME_MAP ] . active_tank -> chosen_projectile == PROJECTILE_TYPE_TYPE_SNIPER ) { DrawText ( game_canvas , " " , 160 , 20 , 3 , & color_black ) ; } DrawAimPath ( scene_data , game_canvas , & color_black ) ; DrawAllHealthBars ( scene_data , game_canvas ) ; if ( scene_data [ SCENE_GAME_MAP ] . animating ) { DrawProjectile ( scene_data , game_canvas , & color_black ) ; } if ( scene_data [ SCENE_GAME_MAP ] . wind_on ) { DrawWindSpeeds ( scene_data , game_canvas , & color_black ) ; } } return ; }
This function will refresh entire scene, map, players, shot...
This function will refresh entire scene map players shot ...
// Load background // Wont have effect on scene /////////////////// // We are currenty in main menu //////////// Draw text // Convert tanks count to string and draw text ///////////////////////////////////////////////// // Draw scope // Scope transparent background // Fill map with sand // Set position for tanks // Add tank images to canvas 'game_canvas' // Draw the text with current chosen projectile of active tank // Draw parabolic aiming path // Draw health bars // If we are animating, display the flying projectile // If wind is on, draw wind speed information