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

Username:   Password: 
 RegisterRegister   
 Bullets/Barriers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chaos




PostPosted: Fri Dec 31, 2010 2:15 pm   Post subject: Bullets/Barriers

[How do u get bullets to work with barriers?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Dec 31, 2010 2:29 pm   Post subject: RE:Bullets/Barriers

Try to be more specific with your questions.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
TokenHerbz




PostPosted: Fri Dec 31, 2010 2:31 pm   Post subject: RE:Bullets/Barriers

if bullet position is at barrier, stop bullet else bullet keeps movies.
TerranceN




PostPosted: Fri Dec 31, 2010 3:11 pm   Post subject: RE:Bullets/Barriers

@TokenHerbz: The only problem with that is bullets tend to move really fast.

The best collision method I have found for things that are really small and move really fast, has been linear collision. Your barrier is represented by a line, and the bullets path is represented by a line from where it was last update call, to where it is now. Then you can use grade 9 math to calculate where the lines crossed. If that point is within the rectangle defined by the barrier's line, and is within the rectangle defined by the bullet's path, collision occurred, and you even have the point it happened too.

A much simpler way is rectangular collision, you can find a tutorial here. This method might fail if your bullet is going too fast, but will usually work just fine.
TokenHerbz




PostPosted: Fri Dec 31, 2010 6:19 pm   Post subject: RE:Bullets/Barriers

you can easily do a check to incorporate any speed jump.. rectangle collision isn't the best especially if your not even using them, but should be easy enough to start with.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: