scene_loader.c
void RefreshProjectilePlayersDistance(SceneData* scene_data){
	// Load projectile and get the x and y coordinates
	Projectile* projectile = &(scene_data[SCENE_GAME_MAP].projectile);
	int aim_path_index = projectile->projectile_path_pairs_index;
	Parabola* projectile_parabola = projectile->parabola;
	
	int projectile_x = projectile_parabola->parabolic_path[aim_path_index*2];
	int projectile_y = projectile_parabola->parabolic_path[aim_path_index*2 + 1];
	//////////////////////////////////////////////////		
	
	// Check only those tanks which are alive, others will have distance -1
	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 the tank is dead, set distance to -1;
		if(temp_tank->is_alive == false){
			temp_tank->distance_from_projectile = -1;
		}else{
			// Calculate distance
			int tank_x = temp_tank->x;
			int tank_y = temp_tank->y;

			temp_tank->distance_from_projectile = GetDistance(tank_x, DISPLAY_HEIGHT-tank_y, projectile_x, projectile_y);

		}
		printf("Player 1 distances from projectile: %.2f\n",temp_tank->distance_from_projectile);
		
	}
	for(int t = 0; t < p2_tanks_total; t++){
		Tank* temp_tank = &(scene_data[SCENE_GAME_MAP].player_2_tanks_obj[t]);
		
		// If the tank is dead, set distance to -1;
		if(temp_tank->is_alive == false){
			temp_tank->distance_from_projectile = -1;
		}else{
			// Calculate distance
			int tank_x = temp_tank->x;
			int tank_y = temp_tank->y;

			temp_tank->distance_from_projectile = GetDistance(tank_x, DISPLAY_HEIGHT-tank_y, projectile_x, projectile_y);

		}
		printf("Player 2 distances from projectile: %.2f\n",temp_tank->distance_from_projectile);
	}
	
	return;
}
/*  This function calculates distance of projectile from players and saves it to	
	each tank  */
This function calculates distance of projectile from players and saves it to
each tank
This function calculates distance of projectile from players and saves it to each tank
void RefreshProjectilePlayersDistance(SceneData* scene_data){
	Projectile* projectile = &(scene_data[SCENE_GAME_MAP].projectile);
	int aim_path_index = projectile->projectile_path_pairs_index;
	Parabola* projectile_parabola = projectile->parabola;
	int projectile_x = projectile_parabola->parabolic_path[aim_path_index*2];
	int projectile_y = projectile_parabola->parabolic_path[aim_path_index*2 + 1];
	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 == false){
			temp_tank->distance_from_projectile = -1;
		}else{
			int tank_x = temp_tank->x;
			int tank_y = temp_tank->y;
			temp_tank->distance_from_projectile = GetDistance(tank_x, DISPLAY_HEIGHT-tank_y, projectile_x, projectile_y);
		}
		printf("Player 1 distances from projectile: %.2f\n",temp_tank->distance_from_projectile);
	}
	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 == false){
			temp_tank->distance_from_projectile = -1;
		}else{
			int tank_x = temp_tank->x;
			int tank_y = temp_tank->y;
			temp_tank->distance_from_projectile = GetDistance(tank_x, DISPLAY_HEIGHT-tank_y, projectile_x, projectile_y);
		}
		printf("Player 2 distances from projectile: %.2f\n",temp_tank->distance_from_projectile);
	}
	return;
}
void RefreshProjectilePlayersDistance ( SceneData * scene_data ) { Projectile * projectile = & ( scene_data [ SCENE_GAME_MAP ] . projectile ) ; int aim_path_index = projectile -> projectile_path_pairs_index ; Parabola * projectile_parabola = projectile -> parabola ; int projectile_x = projectile_parabola -> parabolic_path [ aim_path_index * 2 ] ; int projectile_y = projectile_parabola -> parabolic_path [ aim_path_index * 2 + 1 ] ; 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 == false ) { temp_tank -> distance_from_projectile = -1 ; } else { int tank_x = temp_tank -> x ; int tank_y = temp_tank -> y ; temp_tank -> distance_from_projectile = GetDistance ( tank_x , DISPLAY_HEIGHT - tank_y , projectile_x , projectile_y ) ; } printf ( " \n " , temp_tank -> distance_from_projectile ) ; } 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 == false ) { temp_tank -> distance_from_projectile = -1 ; } else { int tank_x = temp_tank -> x ; int tank_y = temp_tank -> y ; temp_tank -> distance_from_projectile = GetDistance ( tank_x , DISPLAY_HEIGHT - tank_y , projectile_x , projectile_y ) ; } printf ( " \n " , temp_tank -> distance_from_projectile ) ; } return ; }
This function calculates distance of projectile from players and saves it to
each tank
This function calculates distance of projectile from players and saves it to each tank
// Load projectile and get the x and y coordinates //////////////////////////////////////////////////		 // Check only those tanks which are alive, others will have distance -1 // If the tank is dead, set distance to -1; // Calculate distance // If the tank is dead, set distance to -1; // Calculate distance