Best Place to Put Collision Detection?

BlitzMax Forums/BlitzMax Programming/Best Place to Put Collision Detection?

zoqfotpik(Posted 2012) [#1]
Is there anything wrong with having the root level of the game handle collision detection and similar interaction between objects? Or should all objects and object lists live under an objectmanager class? Having collision detection split out into functions seems just as good for organizational purposes.


ImaginaryHuman(Posted 2012) [#2]
For me personally I want speed and efficiency, so I'm not sure how that translates well to splitting everything up into objects. I'd rather for example have a simple array or 2d array to act as a grid acceleration structure and then hardcode the object movements/collisions to work as fast as possible. But that might be at the expense of coding ease, so it's up to you. And I'm sure some people will say OOP code can be fast too. Whatever.


zoqfotpik(Posted 2012) [#3]
"And I'm sure some people will say OOP code can be fast too. Whatever. "

That may be true but for almost two decades the dominant style in game programming was "c with classes" and I think that's probably the best way of doing it-- in other words the manager is oldstyle procedural programming and handles visitor pattern to delve into the objects. I like compartmentalizing things in objects but you have to ask yourself whether decoupling things is always going to be necessary (am I going to need to subclass my object manager!?)

Binning can obviously be done separately and for my purposes a grid is probably fine.

Last edited 2012