PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Collision mask usage -newbie question

tremorJones · 19 Apr 2005, 21:42 UTC
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?
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
tremorJones · 27 Apr 2005, 20:12 UTC
Yes, I think I get what you are saying , Thanks!
Now, If I understand correctly , you normally wouldn't display the mask surface at all (unlike what's done in the sample mask demo program included in the Gapi distribution)
indeed the collision surface is just for the testing in the background, not supposed to be for showing (unless you want to of course ;))