Understanding Max2D Collision Functions

BlitzMax Forums/BlitzMax Tutorials/Understanding Max2D Collision Functions

If you've been wondering how to use the Max2D collision functions, here's a good opportunity to learn. This tutorial covers all four Max2D functions; ImagesCollide, ImagesCollide2, CollideImage and CollideRect.

The tutorial is broken into 3 Parts:-
Max 2D Collision Part 1
Max 2D Collision Part 2
Max 2D Collision Part 3

This is actually part of my Learning 2D Game Programming Series.

Excellent! great work assari

(I also like the way the images load from your web page!)

very usefull. Many thanks !

Very nice.
I'm curious about why you pass images into a bank before loading them?

Neat, thanks for the tuts.

Superb as always. Just checking the first and you have a slight error when suggesting ImagesCollide2.
If ImagesCollide(Alien,150,200,Frame,0,AlienSize,AlienSizePlayer,MouseX(),MouseY(),0,0,PlayerSize,PlayerSize)

should be...
 If ImagesCollide2(Alien,150,200,Frame,0,AlienSize,AlienSize,Player,MouseX(),MouseY(),0,0,PlayerSize,PlayerSize)

(notice the function and 'aliensizeplayer' with the comma).
<edit> to take out rambling.

tonyg, well spotted. Thanks. It's now corrected.

@GW, when you loadimage from http::, you need to loadbank first otherwise the loadimage fails

Interesting.. That's good to know.

I've released a german translation.

=> http://simi.chat-blitz.de/tut_collision/

___________________________________________

Thread in the german forum:

=> http://www.blitzforum.de/forum/viewtopic.php?t=18500

The function CircRectsOverlap function is structured badly. In the function name, Circ comes first, but in the parameters, Rect comes first.

Confoozling.

Great job on the tutorial.

However, the ImagesCollide / ImagesCollide2 code on the page still has the error mentioned above:

If ImagesCollide(Alien,150,200,Frame,0,AlienSize,AlienSize,Player,MouseX(),MouseY(),0,0,PlayerSize,PlayerSize)


There is another error on that same line - it has the Y component of the alien's position off by 100 pixels, so the collision is happening well away from where it should.

NoBoDo, thanks for letting me the know the errors. They are fixed now.

Also noticed a bug in the exit condition, fixed that too :)

Here's russified version translated by JohnK:
http://blitzetc.boolean.name/articles/coll1.htm
http://blitzetc.boolean.name/articles/coll2.htm
http://blitzetc.boolean.name/articles/coll3.htm