Thoughts on SpritePixelCollision

Advanced game related topics
whertz
Enthusiast
Enthusiast
Posts: 124
Joined: Sat Jun 25, 2005 2:16 pm
Location: United Kingdom

Thoughts on SpritePixelCollision

Post by whertz »

While checking for collisions, would it be best to check for SpriteCollision instead of SpritePixelCollision, and if there is a SpriteCollision, then check for SpritePixelCollision? Would this make a huge difference speed wise?

While I'm on the subject of SpritePixelCollision, has Linux PB been updated to support it? I haven't got a PC set up with Linux at the moment so I can't test it. I found this routine programmed in PB: http://www.purebasic.fr/english/viewtopic.php?t=13377 but it's pretty slow.
Fred
Administrator
Administrator
Posts: 18442
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

SpritePixelCollision() already do a SpriteCollision() internally before doing the pixel comparison.
whertz
Enthusiast
Enthusiast
Posts: 124
Joined: Sat Jun 25, 2005 2:16 pm
Location: United Kingdom

Post by whertz »

Ah! You think of everything Fred! Thanks again.
User avatar
IceSoft
Addict
Addict
Posts: 1702
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

Fred wrote:SpritePixelCollision() already do a SpriteCollision() internally before doing the pixel comparison.
Should be part of the documentation too.

In my past I used
SpriteCollision and SpritePixelCollision() behind.

As I read now.
That is not really a performant way because SpritePixelCollision() does it too.
Belive! C++ version of Puzzle of Mystralia
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Does SpritePixelCollison() and SpriteCollison() work with ClipSprite()?
The Human Code Machine / Masters' Design Group
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

in my experience, yes
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post by Heathen »

THCM wrote:Does SpritePixelCollison() and SpriteCollison() work with ClipSprite()?
Yes, I use it in my project without problems.
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Thanx, good to know!
The Human Code Machine / Masters' Design Group
User avatar
IceSoft
Addict
Addict
Posts: 1702
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

Fred wrote:SpritePixelCollision() already do a SpriteCollision() internally before doing the pixel comparison.
Maybe one of the reasons why it is slower as DX9?
Belive! C++ version of Puzzle of Mystralia
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
BriceManuel
Enthusiast
Enthusiast
Posts: 195
Joined: Thu Nov 29, 2007 8:23 am

Post by BriceManuel »

IceSoft wrote:
Fred wrote:SpritePixelCollision() already do a SpriteCollision() internally before doing the pixel comparison.
Maybe one of the reasons why it is slower as DX9?
No, it would be MUCH, MUCH slower if it didn't do box collision before checking for pixel collision.

I am pretty sure that DX9 does box collision before doing pixel collision, it would be a lot slower if it didn't.

If you are using PB's native commands, for speed you can try using the regular box collision and then doing shrunken rectangle collision instead of using the pixelperfect collision. It should be much faster if you need to test against a lot of sprites.
User avatar
IceSoft
Addict
Addict
Posts: 1702
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

It will be usefull if this info:
... SpritePixelCollision() using SpriteCollision() before it check with pixel perfect algorithmus....

In some of my games I use SpriteCollision() before I use SpritePixelCollision().

Of course it is a novice problem...but not all PB user can be a PB insider...
Online help can be a help in this case to optimize a game.
Belive! C++ version of Puzzle of Mystralia
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
BriceManuel
Enthusiast
Enthusiast
Posts: 195
Joined: Thu Nov 29, 2007 8:23 am

Post by BriceManuel »

I think most who knew this, knew it because it has become a "standard" among gaming languages as to how the "pixel collision" function works.

Yes, it should be in the docs, but I cut them some slack since the docs are a bit rough around the edges due to English not being the first language of whoever wrote them.
Post Reply