Collision mask usage -newbie question

Posted:
Apr 19, 2005 @ 10:42pm
by tremorJones
I've recently started exploring gapidraw and I've been playing with the collision masks, and I feel there's something I'm just not getting: The mask ID assigned to a mask also sets its color. What I don't quite see is how this is useful in a game since, presumably one might want to set the color of a mask independently of the mask ID, so that you can match masks to elements of the game's graphics and still be able to differentiate between masks that have arbitrary colors or perhaps the same colors. I feel like I'm missing something big here. Can they be made invisible or something like that?

Posted:
Apr 21, 2005 @ 10:04am
by muff
lets say we want to check for collision between our player's ship with all the enemy bullets...
you first create a collision surface, then you 'blit' the bullets to that collision surface with a specific MaskId for each bullet (i.e. first bullet has MaskID 1, second has 2 etc)
then you do a collision check with your 'ship' graphic against this collision surface and it will return the MaskID of the first bullet that is touching your ship (or it will tell you nothing is touching the ship obviously) - note it returns the first collision, not ALL collisions
so now you know which specific bullet is touching your ship so you can remove it from the list, apply damage to the ship etc
------------------------
the colour of the masks is set to the MaskID as that's how it works - you wouldn't normally actually view the collision surface on screen, the 'colour' data is just the stored MaskID shown as a 'colour' on screen
hopefully that makes some sense
muff