Collision detection ponderings
Hi,
I''m currently creating a game where there won''t be that many objects on screen at once and those that are will be stationary (baring the main object - a vehicle).
Basically, the conventional collision detection techniques (ie. bounding boxes) aren''t appropriate as the main sprite has numerous degrees of rotation etc. etc. and accuracy is the key.
Basically, what I was thinking of doing is defining obstacles/sprites in terms of lines; each with (x0,y0),(x1,y1) style coordinates. Then having a function to detect if two lines intersect, and if so where, to see if there objects have indeed colided.
Would this be feasible? If not, how would I go about collision detection with this sort of game. I have a car sprite, rendered in x number of different rotations. What sort of techniques would be best for detecting collisions between this and other cars/obstacles?
Any pointers, tips appreciated
--
Russ
You could write some complex routines to map a collision outline to your sprite, if you want really accurate collision detection, you might want to go to polys; if that isn''t an option then you might consider sacrificing accuracy.
I''m pretty sure it would suffice to encompass the sprite in a box, and how would you go about doing it in terms of lines?
-Mezz
I''m pretty sure it would suffice to encompass the sprite in a box, and how would you go about doing it in terms of lines?
-Mezz
Why dont you use an orient bounding box... rotate the collision box along with the sprite.
There is some stuff on obb''s on www.magic-software.com I think, unless they took it down... I know I have a rather extensive pdf document on obb''s somewhere... I can dig for it if you want.
Another source is this article by Miguel Gomez at gamasutra
==============================
"What if Bill Gates hade a penny everytime windows crashed?
Oh wait, he does!"
-Dont know who said that, but it's funny :)
-Joacim Jacobsson
There is some stuff on obb''s on www.magic-software.com I think, unless they took it down... I know I have a rather extensive pdf document on obb''s somewhere... I can dig for it if you want.
Another source is this article by Miguel Gomez at gamasutra
==============================
"What if Bill Gates hade a penny everytime windows crashed?
Oh wait, he does!"
-Dont know who said that, but it's funny :)
-Joacim Jacobsson
=============================="What if Bill Gates hade a penny everytime windows crashed? Oh wait, he does!"-Dont know who said that, but it's funny :)-Joacim Jacobsson
This kind of 2d system is not really too difficult to achieve, I know, I've done it!
Your lines on the screen need to define the boundaries that the player cannot cross, but for ease of use/design, why not group them into 4 sided polygons.
Then, you will need to calculate two points for the opposite FRONT corners of the car, depending on it's position and rotation, and see if either of these points have entered one of the boundaries. Easy really.
I devised my own system for 2d AABB (Arbitrarily Aligned Bounding Box) collision detection. It's hardly revolutionary, but at least it's mine! I'd recommend you have a go at it- you'll learn a lot, and you can always prod us for more information if you get really stuck!
Matt
Check out my project at: www.btinternet.com/~Matthew.Bennett
Edited by - 3dmodelman on May 26, 2000 6:12:22 PM
Your lines on the screen need to define the boundaries that the player cannot cross, but for ease of use/design, why not group them into 4 sided polygons.
Then, you will need to calculate two points for the opposite FRONT corners of the car, depending on it's position and rotation, and see if either of these points have entered one of the boundaries. Easy really.
I devised my own system for 2d AABB (Arbitrarily Aligned Bounding Box) collision detection. It's hardly revolutionary, but at least it's mine! I'd recommend you have a go at it- you'll learn a lot, and you can always prod us for more information if you get really stuck!
Matt
Check out my project at: www.btinternet.com/~Matthew.Bennett
Edited by - 3dmodelman on May 26, 2000 6:12:22 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement