Page 1 of 1
Thoughts on SpritePixelCollision
Posted: Sun Nov 11, 2007 11:30 pm
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.
Posted: Mon Nov 12, 2007 12:00 am
by Fred
SpritePixelCollision() already do a SpriteCollision() internally before doing the pixel comparison.
Posted: Mon Nov 12, 2007 12:02 am
by whertz
Ah! You think of everything Fred! Thanks again.
Posted: Mon Nov 12, 2007 7:08 am
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.
Posted: Mon Nov 12, 2007 11:27 am
by THCM
Does SpritePixelCollison() and SpriteCollison() work with ClipSprite()?
Posted: Mon Nov 12, 2007 11:47 pm
by citystate
in my experience, yes
Posted: Tue Nov 13, 2007 1:28 am
by Heathen
THCM wrote:Does SpritePixelCollison() and SpriteCollison() work with ClipSprite()?
Yes, I use it in my project without problems.
Posted: Tue Nov 13, 2007 9:16 am
by THCM
Thanx, good to know!
Posted: Wed Jan 02, 2008 12:36 pm
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?
Posted: Wed Jan 02, 2008 12:39 pm
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.
Posted: Wed Jan 02, 2008 1:42 pm
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.
Posted: Wed Jan 02, 2008 2:35 pm
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.