PDA

View Full Version : Collision and Spriteengine



pstudio
20-08-2007, 09:36 PM
I've just started on a small breakout game to test out Phoenix and I'm a bit puzzled now.
Phoenix has a pretty good collision engine using polygons, but the sprite engine doesn't make use of it as far as I can see. It just checks on bounding rects which it gets from the sprites given pattern.
Why is that?
I suppose I'll now have to mantain my own collisionengine as well now and make synced with the sprite engine, or have I overlooked something.

chronozphere
20-08-2007, 11:22 PM
I recall that i read somewhere that the sprite-engine was made similair to the delphix sprite engine, so you could easily port your project over to Phoenix. Delphix has no polygon collision checking so the sprite-engine hasn't it either :)

Think you have to expand the sprite-engine or just write it from scratch. :?

BTW: I remenber the TestCollision method that delphix had (think it was in the TSprite class).
This was used to intergrate extra collision checking methods (other then bounding rect). It first checks the bouding rect, if the test passes "Testcollsion" is called, wich normally returns true until you override it in a TSprite descendant. :)

You could add the extra polygon collsion there, maybe :P

Hope to have helped you ;)

pstudio
20-08-2007, 11:35 PM
OK - I'll take a closer look at it tomorrow.
However I still think it's weird since one of the earlier releases of Phoenix used polygonal collision in the sprite engine as far as I remember.

Andreaz
21-08-2007, 04:54 AM
The collision engine and sprite engine isn't connected to make things easier (and faster). Just let you'r sprites have a collision object that you add to the collision engine and you're set.

pstudio
21-08-2007, 02:02 PM
I don't know if it's easier, but it's probably faster.

OK I have added collisionobjects to my Sprites and it works fine. Now I'm wondering if there is an easy way to see which line of the collision polygon there has been a collision? It would be a nice an easy way to locate where exactly the collision happened.

btw. I rendered the collision objects for debugging purposes and used the fill color clrNone. I may be wrong, but I thought that it would mean that my drawn objects only where outlined, but instead they had a white fill colour.

Andreaz
21-08-2007, 02:32 PM
clrNone is transparent, so by enabling blending or alpha testing they will be invisible.

For the sprites i'm refering easy as in a design and extension point of view, not necessary user code :)

I'm working on improving theese areas with quadtrees and other optimizations.

pstudio
21-08-2007, 03:33 PM
clrNone is transparent, so by enabling blending or alpha testing they will be invisible. Seems reasonable. Just assumed that blending was on by default.

But there is no way right now in the collisionobjects that tell you were exactly the collision happened? If not it would be a nice feature in a future release. Sometimes it doesn't matter, but sometimes it's nice to know exactly where two objects collided.

Andreaz
21-08-2007, 05:27 PM
But there is no way right now in the collisionobjects that tell you were exactly the collision happened? If not it would be a nice feature in a future release. Sometimes it doesn't matter, but sometimes it's nice to know exactly where two objects collided.

Sadly not, that is not as easy as it first may seem, i've spent alot of time getting that to work but without any satisfying results. Detecting the collisions is quite easy, getting the location, vectors and time of the collision is not that trivial...

pstudio
21-08-2007, 07:03 PM
Detecting the collisions is quite easy, getting the location, vectors and time of the collision is not that trivial...
I know. That's why I hoped that it was already implemented ;)

Well, it's not that crucial for this small game, so I'm just gonna do without it.