PocketMatrix forums

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

Sprite Collide question

directdance · 17 Mar 2006, 00:13 UTC
Hi,

I have a question re the collide function. In most of all cases I have to check the colission between only two sprites. But how can I check, if a sprite hits more than one sprite?

Example:

Taxi hits wall:

Code:

if (Collide(taxi$, x$, y$, nx$, ny$) == wall$)


This is working geat.

Next exampe, Taxi is in a storm (a sprite with colission, too) and hits at the same time the wall.

This is not working:

Code:

if (Collide(taxi$, x$, y$, nx$, ny$) == wall$ & storm$)


But even the first source,

Code:

if (Collide(taxi$, x$, y$, nx$, ny$) == wall$)


is not responding when the taxi hits the wall and the storm sprite at the same time.

How can I manage to check, if the taxi hits the wall and the storm sprite at the same time?

I thought using the bitwise-and & ...

Thanks a lot,
DirectDance
Hi,

There is a function that returns a list of objects that are colliding, can't remember the exact name I am not at the office and don't have the source codes intalled here at home. It must be around the Collide() function in the help file. This function will solve your problem.

I'll get back to you tomorrow with the exact name. It's very to use too. :)
directdance · 20 Mar 2006, 11:05 UTC
Hi Kornalius,

did not find anything in the help files re this.

So it would be nice if you can have a look into it. Maybe with an example ..., that would be very fine.

At the moment I am switching sprites to false for correct colission detection and a tick later to true again. By using this method, I can be shure that for a millisecond only the sprites wich I want for colission detection are available.

Thanks,
DirectDance
Hi,

Sorry I had the support internally but not in external functions.

I've just implemented a few new collision detection functions.

Code:
Collides(sprite$, x$, y$, List$) -> Count$

RectCollides(sprite$, x$, y$, x2$, y2$, List$) -> Count$

RectCollide(sprite$, x$, y$, x2$, y2$, nx$, ny$) -> SpriteHandle$


They will be part of the next release.