PDA

View Full Version : Pixel perfect collision of a sprite with a mouse


MagNet
10-20-2006, 09:35 PM
Simply, do I have to make a "dummy" sprite that will move with the mouse or is there some way without using it?

kornalius
10-20-2006, 09:39 PM
Yes you can use the Collide() function. It will check to see if there is a collision at certain pixel on the screen. You can get the mouse location at check. The return value is the sprite's handle.

MagNet
10-20-2006, 09:46 PM
I tried this before making this thread actually:
if (Collide(col$, wParam$, lParam$, cx$, cy$) <> NULL)
ShowMessage("lol");
end;

Didn't work, what's wrong there?
It's being called in the WM_LBUTTONDOWN event and it always returns a null value.

The sprite has a pixelcheck option of course.

kornalius
10-21-2006, 04:35 AM
Sorry try SpriteAt(wParam$, lParam$, True), this should work. I don't remember by heart if it does pixel-perfect checking though. Let me know.

MagNet
10-21-2006, 04:25 PM
Oh, cool.
It actually does pixel-perfect collision.

Thanks.

Oh and you could add the G_ShowMessage fucntion to the manual.

MagNet
10-21-2006, 05:04 PM
And because you were so helpful to me, I provide you with a sneak-peek at my new game - MAGKNIFE!:
http://magnetpwns.com/games/screenshots/magknife1.gif
And after a little operation...
http://magnetpwns.com/games/screenshots/magknife2.gif

kornalius
10-22-2006, 08:12 PM
HEHE! Very funny looking game. Cool. :))

PointOfLight
10-23-2006, 03:33 AM
Oh and you could add the G_ShowMessage fucntion to the manual.


The reason G_SHOWMESSAGE is not currently in the help file is because it is not a native PPL function. Rather, it is a wrapper for a set of PPL functions useful for displaying a messagebox when the GameAPI is running. However, I have added it to the manual.