scene_loader.c
void ShouldProjectileExplode(SceneData* scene_data){

	// Load projectile
	Projectile* projectile = &(scene_data[SCENE_GAME_MAP].projectile);
	
	// Iterate for each living tank and decide if the projectile should explode
	int p1_tanks_total = scene_data[SCENE_GAME_MAP].player_1_tanks;
	int p2_tanks_total = scene_data[SCENE_GAME_MAP].player_2_tanks;

	for(int t = 0; t < p1_tanks_total; t++){
		Tank* temp_tank = &(scene_data[SCENE_GAME_MAP].player_1_tanks_obj[t]);
		
		if(temp_tank->is_alive == true){ // Is the tank alive?
			if((temp_tank->distance_from_projectile) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER){
				// EXPLODE
				printf("Projectile should explode!!!\n");
				projectile->to_explode = true; 
				return;
			}
		}
	}
	for(int t = 0; t < p2_tanks_total; t++){
		Tank* temp_tank = &(scene_data[SCENE_GAME_MAP].player_2_tanks_obj[t]);
		
		if(temp_tank->is_alive == true){ // Is the tank alive?
			if((temp_tank->distance_from_projectile) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER){
				// EXPLODE
				printf("Projectile should explode!!!\n");
				projectile->to_explode = true; 
				return;
			}
		}
	}
	///////////////////////////////////////////////////////////////////////////
	
	// Check the ground distance and decide if the projectile should explode
	if((projectile->distance_from_ground) < PROJECTILE_GROUND_DISTANCE_EXPLOSION_TRIGER){
		// EXPLODE
		printf("Projectile should explode!!!\n");
		projectile->to_explode = true;
		return; 
	}
	return;
}
/*  This function will decide if the projectile should explode.
	If it should, 'to_explode' variable in projectile will be set to true*/
This function will decide if the projectile should explode.
If it should, 'to_explode' variable in projectile will be set to true
This function will decide if the projectile should explode . If it should ' to_explode ' variable in projectile will be set to true
void ShouldProjectileExplode(SceneData* scene_data){
	Projectile* projectile = &(scene_data[SCENE_GAME_MAP].projectile);
	int p1_tanks_total = scene_data[SCENE_GAME_MAP].player_1_tanks;
	int p2_tanks_total = scene_data[SCENE_GAME_MAP].player_2_tanks;
	for(int t = 0; t < p1_tanks_total; t++){
		Tank* temp_tank = &(scene_data[SCENE_GAME_MAP].player_1_tanks_obj[t]);
		if(temp_tank->is_alive == true){ 
			if((temp_tank->distance_from_projectile) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER){
				printf("Projectile should explode!!!\n");
				projectile->to_explode = true; 
				return;
			}
		}
	}
	for(int t = 0; t < p2_tanks_total; t++){
		Tank* temp_tank = &(scene_data[SCENE_GAME_MAP].player_2_tanks_obj[t]);
		if(temp_tank->is_alive == true){ 
			if((temp_tank->distance_from_projectile) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER){
				printf("Projectile should explode!!!\n");
				projectile->to_explode = true; 
				return;
			}
		}
	}
	if((projectile->distance_from_ground) < PROJECTILE_GROUND_DISTANCE_EXPLOSION_TRIGER){
		printf("Projectile should explode!!!\n");
		projectile->to_explode = true;
		return; 
	}
	return;
}
void ShouldProjectileExplode ( SceneData * scene_data ) { Projectile * projectile = & ( scene_data [ SCENE_GAME_MAP ] . projectile ) ; int p1_tanks_total = scene_data [ SCENE_GAME_MAP ] . player_1_tanks ; int p2_tanks_total = scene_data [ SCENE_GAME_MAP ] . player_2_tanks ; for ( int t = 0 ; t < p1_tanks_total ; t ++ ) { Tank * temp_tank = & ( scene_data [ SCENE_GAME_MAP ] . player_1_tanks_obj [ t ] ) ; if ( temp_tank -> is_alive == true ) { if ( ( temp_tank -> distance_from_projectile ) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER ) { printf ( " \n " ) ; projectile -> to_explode = true ; return ; } } } for ( int t = 0 ; t < p2_tanks_total ; t ++ ) { Tank * temp_tank = & ( scene_data [ SCENE_GAME_MAP ] . player_2_tanks_obj [ t ] ) ; if ( temp_tank -> is_alive == true ) { if ( ( temp_tank -> distance_from_projectile ) < PROJECTILE_TANK_DISTANCE_EXPLOSION_TRIGER ) { printf ( " \n " ) ; projectile -> to_explode = true ; return ; } } } if ( ( projectile -> distance_from_ground ) < PROJECTILE_GROUND_DISTANCE_EXPLOSION_TRIGER ) { printf ( " \n " ) ; projectile -> to_explode = true ; return ; } return ; }
This function will decide if the projectile should explode.
This function will decide if the projectile should explode .
// Load projectile // Iterate for each living tank and decide if the projectile should explode // Is the tank alive? // EXPLODE // Is the tank alive? // EXPLODE /////////////////////////////////////////////////////////////////////////// // Check the ground distance and decide if the projectile should explode // EXPLODE