Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Question on collision detection
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dehu87




PostPosted: Sat Jun 07, 2008 9:51 am   Post subject: Question on collision detection

I have a game where the user controls a spaceship (picture) and if any asteroids hit the spaceship than there is a collision. My question is what type of collision detection method should I use for a pic and an oval?
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Jun 08, 2008 9:30 am   Post subject: RE:Question on collision detection

Use oval collision, here.
dehu87




PostPosted: Sun Jun 08, 2008 1:57 pm   Post subject: Re: Question on collision detection

but does this work for a rectangular picture Question
Tony




PostPosted: Sun Jun 08, 2008 2:11 pm   Post subject: RE:Question on collision detection

Yes. "How well" depends on how closely your circle of choice approximates the rectangular picture.

I'm assuming that circles should work alright for images of spaceships though. Definitely easier on the math Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
dehu87




PostPosted: Sun Jun 08, 2008 5:59 pm   Post subject: Re: RE:Question on collision detection

Tony @ Sun Jun 08, 2008 2:11 pm wrote:
Yes. "How well" depends on how closely your circle of choice approximates the rectangular picture.

I'm assuming that circles should work alright for images of spaceships though. Definitely easier on the math Wink


Sorry but I don't quite get this. How do you make a circle into a recangular picture? Embarassed
Tony




PostPosted: Sun Jun 08, 2008 6:09 pm   Post subject: RE:Question on collision detection

You align the circle's center with the rectangle's center, and then make the circle's radius large enough to cover most of the rectangle.

It might help if you draw this out on paper first.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jeffgreco13




PostPosted: Mon Jun 09, 2008 9:29 am   Post subject: Re: Question on collision detection

If you want use rectangular collision detection if your spaceship is closer to a rectangular shape. But there are more values to taek into account such as the height and width which must be added to the x and y coords to simluate the ship.

Think about it, circular is probably the easiest, but if your ship is rectangualr then the above collision detection would be most accurate.
dehu87




PostPosted: Mon Jun 09, 2008 10:42 pm   Post subject: Re: RE:Question on collision detection

Tony @ Sun Jun 08, 2008 6:09 pm wrote:

It might help if you draw this out on paper first.


Ya it's true that drawing it on paper first is useful. Thats a good tip, thx.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: