forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

what's crashing...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Energy



Joined: 26 Mar 2005
Posts: 133
Location: uk/beds/flitwick

PostPosted: Sun Jan 08, 2006 2:28 am    Post subject: what's crashing... Reply with quote

Hey all

I'm pulling my hair out over this... Here's my code:
Code:

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;
         }

      }
   }
}


Now, whenever the :
Code:

if(true_distance <= poss_distance)
{
   //e_missiles[q].active = 0;
   //missile_count--;
   printf("X");
}


is reached the system will run the code in the brackets and freeze.
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 >_>
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Energy



Joined: 26 Mar 2005
Posts: 133
Location: uk/beds/flitwick

PostPosted: Sun Jan 08, 2006 8:52 am    Post subject: Reply with quote

oh dear... can I really be that stupid????
I guess I can... another thread you can all ignore. Suppose the best way to learn is trial and error... :(

Don't exactly know why it fixes it, but if you put the correct maths in, it does help a lot. AKA try using the sqrt function instead of (radius_squared - distance_squared) / (radius_squared - distance_squared).

I'm what is known as a idiot.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group