ImagesCollide problem

BlitzMax Forums/BlitzMax Beginners Area/ImagesCollide problem

Rooster(Posted 2016) [#1]
I've run into a problem with ImagesCollide always returning true, even when the overlap is supposed to be masked. It only seems to happen with big images (like 3000 * 450 is what I'm using.)

This is how I've been using the command.
If ImagesCollide (imag1,x1,y1,0,imag2,x2,y2,0)
 gg =1
EndIf 


So is this just something that happens or do I need to do something different? is there a alternative method to ImagesCollide?


skidracer(Posted 2016) [#2]
I would be happy to test the collision commands with your large image if you email it to me and see if I can pinpoint the issue.


Rooster(Posted 2016) [#3]
I've tested this with three different images, and it will happen even if the image is blank. All it needs is to be around that size.

Btw here is the code I was using to test this.




dw817(Posted 2016) [#4]
You mentioned 3000 pixels across, Rooster ? Is your actual screen smaller than that ?

That could be one reason it's not working. It may be that the ImagesCollide() routine was only equipped to handle images that could appear fully on-screen.

You might try it with an image that fits fully on the screen and see if you are still having the same problem.


Rooster(Posted 2016) [#5]
dw817-
I tried to test that but noticed that the image is not masking. Blitz3D did this automatically, and I assumed that BlitzMax was the same. So do I need to run a command to do the masking, or am I really messing up?

edit- my screen is 1366 X 768 btw.


skidracer(Posted 2016) [#6]
Instead of a mask colour, BlitzMax uses the alpha channel of the image so you need to use png files where your masked pixels are set to transparent.

Try running the CollideImage example in the docs as an example.


dw817(Posted 2016) [#7]
Ah, masking, that's not difficult. :) Let me see if I can catch up with you.

If you press F1 on ImagesCollide() you'll see there are several variables getting passed to it.

[1] pointer to the first image to check for collision
[2] x-coordinate of this image
[3] y-coordinate of this image
[4] don't forget this, frame number (usually zero)
[5] pointer to the SECOND image to check for collision
[6] x-coordinate of 2nd image
[7] y-coordinate of 2nd image
[8] frame number of 2nd image (usually zero)

So you can see that there are =8= values you pass to ImagesCollide() to check for collision. If you do all this, your program should work just fine, and to answer another question, yes this is VERY accurate.

Try hitting the wall with the corner of your ship, an edge of the triangle. You will see it won't register a hit until one pixel crosses another. Really good for games of this caliber.

Hope This Helps !


Rooster(Posted 2016) [#8]
Okay, it seems that the alpha channel was messing me up. XD

Thanks for your time and help. :)


dw817(Posted 2016) [#9]
Good deal, and yes - alpha is a tricky thing - I hadn't considered it for collisions. If all else fails put your lit up pixels at 255 ALPHA and blank spaces (black pixels) at zero.