I'm pulling my hair out over this... Here's my code:
Code: Select all
void update_player_explosions()
{
int i, q;
int poss_distance;
int radius_squared;
int distance_squared;
int true_distance;
for(i=0; i<50; i++)
{
if(p_missiles[i].active == 2)
{
PlotCircle(p_missiles[i].final_x, p_missiles[i].final_y, (int) p_missiles[i].radius, 0x0000FF);
for(q=0; q<50; q++)
{
if(e_missiles[q].active == 1)
{
poss_distance = 0;
radius_squared = ((int)p_missiles[i].radius * (int)p_missiles[i].radius);
distance_squared = (abs(e_missiles[q].current_x - p_missiles[i].final_x)) * (abs(e_missiles[q].current_x - p_missiles[i].final_x));
poss_distance = (radius_squared - distance_squared) / (radius_squared - distance_squared);
true_distance = abs(e_missiles[q].current_y - p_missiles[i].final_y);
if(true_distance <= poss_distance)
{
//e_missiles[q].active = 0;
//missile_count--;
printf("X");
}
}
}
p_missiles[i].radius = p_missiles[i].radius - 0.2;
if(p_missiles[i].radius <= 0)
{
p_missiles[i].active = 0;
}
}
}
}
Code: Select all
if(true_distance <= poss_distance)
{
//e_missiles[q].active = 0;
//missile_count--;
printf("X");
}
I'm just trying to find whether a point is within a circle. I'm testing every drawn explosion and every missile on the screen.
Any ideas? I'm on a 2.0 system, could it be possible that it's that what is making it crash? If I comment out that if statment, then there are no problems.... argh!!!!
The reason those two lines are commented out are to show that it doesn't matter what's in there it will still crash. If you shoot and no missiles are in the explosion then there is uaully no problem... :/
help >_>