2D Collisions Help

Blitz3D Forums/Blitz3D Beginners Area/2D Collisions Help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Looking at the image, it looks like you intend to use that image for the scene in some sort of platform game. (Please let me know if my assumptions about what you are trying to do is incorrect.)

What I'm thinking is that your character will be moving around on top of the green bits and that he/she will be able to move through the blue bits (the "sky")

If that's correct, what I'd do is this - set the mask colour of your image to the rgb colours of the blue you have there.

You do this like:
image = loadimage()
maskimage image, r, g, b

Then draw your image to the screen. Now this will make the blue bits appear transparent, so just set your clscolor to the r, g, b of the blue you used:

clscolor r, g, b

Then to detect if your character has collided with the green bits of your image, you can just use a simple:

if imagescollide(map, 0, 0, 0, character, charx, chary,charframe)

endif


I hope this helps, but if I've assumed incorrectly, just let us know. I'm sure everyone here would be happy to help.