CollideRect - somebody explain it please

BlitzMax Forums/BlitzMax Beginners Area/CollideRect - somebody explain it please

GfK(Posted 2006) [#1]
I don't get how this command is to be used.

What is the CollideMask parameter for? And how about WriteMask?? What the hell is a collision layer?? I can't find a single example in the entire BlitzMax forum that explains this.


skidracer(Posted 2006) [#2]
Think of them as 32 separate playfields, the writemask dictates which playfields the shape is drawn on, the collidemask dictates which of the 32 playfields the rectangle or shape is tested against for collisions with shapes that have already been drawn on those fields.

When a shape is drawn to a collision playfield an Object can be attached with the "imprint" which means when a subsequent collide occurs with it's imprint the collision can report a list of objects so you can tell which objects you collided with.

It would have been more logical (and easier to understand) to separate the commands into write mask and readmask but there are certain optimisations that can be done for those wanting to perform both operations at once.


Dreamora(Posted 2006) [#3]
There is more than only 1 example. Assassari has written a series of 3 tutorials that explain how the collision system works. At best check them out that will bring you quite far.

http://www.2dgamecreators.com/blitzmax/resources/assari.html


GfK(Posted 2006) [#4]
Ah right, I sort of get it now.

I'm not really sure how I've managed to get through ten games in Blitz/Blitz3D without using any native 2D collision commands until now... :/


Dreamora(Posted 2006) [#5]
The old blitz didn't have such a powerfull collision system, thats why you haven't seen that or similar things so far.


(tu) ENAY(Posted 2006) [#6]
Don't worry about it Dave, I struggled across the same problems. I found it easier to just write my own collision detection functions instead.


dan_upright(Posted 2006) [#7]
i'd only glanced at the collision commands until gfk asked about them yesterday but they're pretty excellent tbh - they really deserve better explanation in the docs because for most cases, i imagine they're all anyone will need


Grey Alien(Posted 2006) [#8]
The old BlitzPlus ones were OK, the pixel perfect ones and the rectangle collision type ones were fine - worked well. The BMax one took a bit of figuring out with the write to layer stuff, but once I figured it out it's really cool and easy to use - seems to be fast too; but yeah, needs better doc!


slenkar(Posted 2008) [#9]
whats faster? imagescollide or collideimages?


tonyg(Posted 2008) [#10]
Not sure why you chose to resurrect this thread for your question but
ImagesCollide wraps CollideImage :
Function ImagesCollide(image1:TImage,x1,y1,frame1,image2:TImage,x2,y2,frame2)
	ResetCollisions COLLISION_LAYER_32
	CollideImage image1,x1,y1,frame1,0,COLLISION_LAYER_32
	If CollideImage(image2,x2,y2,frame2,COLLISION_LAYER_32,0) Return True
End Function

If you're testing multiple images then CollideImage is better to use.


slenkar(Posted 2008) [#11]
thanks.