PocketMatrix forums

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

Intersect question/suggestion

Last night I had occassion to try and do a sprite collision test between a sprite and another that I was blitting using colorize (specifically, it was an alien space ship that I wanted to have a red, green and blue version of without having multiple image resources, hence colorize).

It seems that intersect didn't work as expected with the colorized image (i.e., no collision detected). Before anyone goes nuts trying to figure it out, it could have been something screwy in my own code, I haven't had a chance to go back to it to be sure.

In any case, the question(s) are: when you do a blit with colorize, does it alter the original surface? If not, does Intersect work against what's been blitted on the target surface (i.e., backbuffer usually) or against the source surface itself? The point of course is that I believe it should work whether you colorize an image or not (assuming it wasn't my code of course, but all I can say is that collisions where working before I did the colorize, then not).
Hi,

When you do a blit with colorize, does it alter the original surface?


It does not alter the original surface.

If not, does Intersect work against what's been blitted on the target surface (i.e., backbuffer usually) or against the source surface itself?


Intersect is meant to be used with two color keyed surfaces ("sprites"). Since a surface is "dumb" it does not hold a history of the sprites that have been drawn to it - or the z-order of the previous blits.

The point of course is that I believe it should work whether you colorize an image or not (assuming it wasn't my code of course, but all I can say is that collisions where working before I did the colorize, then not).


They should work in the colorized destination surface. Just make sure that: (1) You have filled the target surface with the correct color key before you blit with colorize, and (2) that you use a color key as you colorize (so you don't colorize the color key). :)

Ps. By the way, CGapiSurface::Intersect supports negative (signed) coordinates in GD 2.02 (when it's released that is)... DS.
Ah, good info! And I have a strong suspision it was my error after reading your reply... I think I probably did colorize the color key. That makes perfect sense from what I saw happen. Thanks Johan!