Collision Help

Hey, I am making a game in my computer science class and I’m trying to figure out how what code i could use for collision. I’ve seen a lot of ways but they are all very complicated. Something very simple that detects when two canvases touch together would be a great help. I’ve tried something like if canvas1.left - canvas1.width < canvas2.left - canvas2.width then msgbox "hit" end if
but I’ve had no success, any help would be very much appreciated. Here is a drop box link if you’d like to see the game.
Thanks a lot! :slight_smile:

The version of the game i’ve been running on the dropbox is 3.4 STABLE :slight_smile:

First off… I would highly suggest that you don’t move multiple canvas objects… but have ONE canvas and draw all of your objects directly (or indirectly using an off screen PICTURE object)
As for “collisions”, mathematically compare the overlap of two rectangles… or measure the distance between the centers.
If you have irregular shapes (asteroids for example)… then it gets more complex as you have to check for intersection of line segments.

and how would one do this? Sorry i only have a small knowledge about xojo scripting.

This is a good place to learn the canvas control (collisions are covered)

You might also want to watch the Retro Gaming webinar which shows how to deal with multiple objects within a single Canvas and how you can detect collisions using Rect.Intersects.