Collision system!

BlitzMax Forums/BlitzMax Beginners Area/Collision system!

Regular K(Posted 2005) [#1]
Im utterly confused on the collision system Max2D has! I have no clue how it works, the example isn't all that good at explaining why the paramters are.

Can anyone please shed some light on this?

if its any use, im using the latest demo, although my full copy of BlitzMax should arrive in the next few days (in case if the collision system has been updated?)

EDIT: I got it to work but I still dont understand why things work like they do, can anyone explain?


Dreamora(Posted 2005) [#2]
The write flag defines to which layers this object is written for further collision check (only collisions with object that test their collision with this layers will "see" this object)

the read flag defines with which layers the object is tested for collision (it won't collide with object in other layers not defined here)

the last :object parameter is the best one: If a collision with this object happens, the data you give the collision system there will be returned to the collision data array.
This means you can return the "player object" itself as return instead of just some handle which you have to transform later again. Very powerfull for clean design.


Matt McFarland(Posted 2005) [#3]
what about "assumed collision?"

If you use delta timing and the person playing your game has a slow computer, it is very possible that the bullet will "skip" the target. How would you code it to "assume" it has hit the object, when it's layer has not in fact collided?


Ferminho(Posted 2005) [#4]
If you use a fixed time check that shouldn't happen. I mean, instead of doing:

X time has passed in last frame. Move according to X, check collisions

do this:

X time has passed in last frame.
Divide X in n prefixed length time chunks and repeat:
Move according to chunk n, check collisions

This makes each frame more time-consuming but avoids the problem you mention, and makes the behaviour of collisions almost equal in different computers


Matt McFarland(Posted 2006) [#5]
Hmm.. I'm trying to figure out how to do this. Would it be possible if you could create a small code snippet? Thanks! :)


FlameDuck(Posted 2006) [#6]
I'm trying to figure out how to do this.
You can use a bresenham line algorithm to check all integer points along an objects path (ie. between its last position, and it's new position) or you could use linear interpolation if you need to check fractions of a pixel.

I have an example, but it needs some major cleaning up. I'm pretty sure there's a bresenham implementation in the code archives somewhere.


hub(Posted 2006) [#7]
@dreamora : could you post an example ? I'm also confused with max2d collisions !
Thanks !


Matt McFarland(Posted 2006) [#8]
Mikkel I'm looking forward to seeing your example, otherwise I'll be forced to use the "image" collision system which I guess is OKAY :)


Matt McFarland(Posted 2006) [#9]
or not? :P


smilertoo(Posted 2006) [#10]
The bmax collision system isn't very good, once it hits about 30 onjects the performance starts to plummet.