PocketMatrix forums

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

Collision Detection

I read on the docs that you can use the intersect function of CGapiSurface to test whether two surfaces collide.

I read over the function and have used a (non-gapi) collision detection function before, but Im mixing up my x and ys here.

So here are a few questions:

1.) Can the two surfaces be the same surface?
2.) I want to test if two images collide tha are blitted onto the BackBuffer. To do this I would set the x and y's in the Intersect function to 0, 0 correct? (Both)
3.) For the RECT type, I read the struct being top, left, bottom, right or something close to that. Is that the same as x, y (top left), width, height? That is what im used to.
1. Unless someone corrects me, no, they cannot be the same surface. Logically, since the intersect function works "virutally", i.e., you don't actually have to draw anything, you could simply ask "IF I drew surface A at coordinates X, Y and surface B at coordinates X1, Y1, would they intersect?" Actually putting either surface on the screen is not a prerequisite for using Intersect.

2. No, you would set X/Y to the coordinates of each surface.

3. That is correct, top and left are synonymous with X and Y. (but vice-versa of what I wrote :) ).