2D physics and collision

Started by
0 comments, last by mds_79 21 years, 1 month ago
I am having trouble incorporating physics and collision detection into my 2D, SDL based "engine". I am doing this as an exercise in OO design and C++. My trouble is not the physic or collision algorithms, it''s how to integrate them in a OO fashion into my "engine". For that matter does a 2D game engine need a separte renderer or should all drawing be done within a graphic class which all sprites contain? Any advice would be much appreciated. "Discipline is never an end itself, only a means to an end." - Robert Fripp
"Discipline is never an end itself, only a means to an end." - Robert Fripp
Advertisement
A OO implementation is quite personal and stems from the coder that makes it. You can however follow some guidelines.

Such as make a surface class that holds a surface and its neccecary methods (blit, colorize, get color, etc...)

Then you incorporate the surface class into a sprite/object class by either containment or private derivation.

To get an idea of how it can be done, check out the sourcecode of my project. (Link in my signature)

Get the source code and especially check graphics.h, there you will see a (good?) way of implementing OO into 2D games. units.h might be of interest to you as well.

-----------------------------
Final Frontier Trader
-----------------------------Final Frontier Trader

This topic is closed to new replies.

Advertisement