🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

simple colision detection system

Started by
0 comments, last by Delisk 24 years, 4 months ago
I created a very simple colosion detetion system. So would like so comments of it. Im macking (just an engine for now) a game were the player can not touch the ennemie. So there is 2 type of objects involved in a colision. 1=The active (ex: missile) 2=The inactive (ex: the target) The colosion system is run at ec 100 milisecond) The active has a contact poin (ex: the head of the missile), wich corespond to a singlr location (x 45, y 30). The inactive his diferent, hit as a contact zone(the entire spirit)The conact zone is calculated this way: I take the base location of the target (x 67, y 54) and i add the size of the image (x 10, y 10). There come the detection. The engine make a check for and and y (both are independant) but both work the same way. Ex: The engine take the x value of the the missile( contact point) let say 35, than it take the values of the target (x location plus x size) let say : 30 and 40, and check if the value of the missile is within the range. If the missile value is betwen the range,it return as true. if both x and y are true, than the colosion test is positive. this is all. Please writte comments on this Ps- this is the first time i make a colision test.
Advertisement
What happens if the missile moves at speed >100 pixels/sec? There is a possibility that the collision detection will fail as the missile 'jumps' over the sprite.

Running the collisiondetection at a higher rate than the framerate would mean that you have make some loop between each frame (or possibly another thread) to move and test each object. This is not a very good tactic.

Instead I suggest that you check if the line between the missile's old and new position intersects the box of the sprite. If it does then collision has occurred.

Edited by - Spellbound on 2/11/00 11:46:43 AM

This topic is closed to new replies.

Advertisement