collision refactoring questions

BlitzMax Forums/BlitzMax Beginners Area/collision refactoring questions

Walla(Posted 2012) [#1]
Hello blitzmax folks,

I have recently been unentangling an old beast of a pet project.

From this process I have learned many things, but still I have a thorny problem to solve.

I am mindful of the idea that there is often various approaches which can work, but I'm interested in the patterns involved, the oop ness and whether I am doing things the right way around.

So I have tentity.bmx, with my entity type. Like everyone, I expect?

I handle the collisions of all the derived class objects in the tentity type, and I was trying to put a collision(_other:Tentity) nto every derived entity type to handle the collisions in wat I thought was a more oo-way, unfortunately this causes me to hit circular references as you can imagine.


Anyway, if there is any hints or anyone wants to pile in with opinions and ideas I would be very grateful.


col(Posted 2012) [#2]
Hiya,

I'd personally separate the collision code from your TEntity code and only store collision bounding data with the TEntity. Each frame build a list of possible colliders ( which is whole topic in its own right ;-) ) using the bounding data, then send the list into the collision detection code from which you can either retrieve the results so you can then update accordingly or have the collision code do the updating for you.

BTW... Bmax does have some kind of collision detection builtin that you can use with images. I'm not sure on the performance of it, but it is there to be used :

ImagesCollide
ImagesCollide2
CollideImage
CollideRect
ResetCollisions


Walla(Posted 2012) [#3]
So a sort of collision manager?

I was thinking about this kind of approach, handling things via a type completely detached - the collision manager type can import all the entity types and do all the collision management stuff.

I will go imlement this and report back! Thanks for the tip. :)