[SOLVED]Structuring my 2D game engine/framework
Posted: Fri Mar 12, 2010 7:41 pm
Yes, I know I've been posting a few different posts and questions tonight, but hey, I'm working on my first engine/framework and it's not easy. This topic has been brought up in different threads and I've read some of you guys' views on this, but I'm still not certain on how to do this.
I'm using a mac and SDL for this, but this is really a cross-platform/cross-library subject so don't worry about the mac part. I know SDL isn't that great for drawing but I want to get comfortable with it before moving on to SDL+OpenGL. Thanks to avansc and his video, I was able to set up a static library in a nice way inside XCode.
I want to have a simple and clean setup, this is a pretty simple 2D project and doesn't require as much drawing, math or physics code as bigger 2D/3D projects like Elysian Shadows or GroundUpEngine. I have no intention of implementing advanced collision detection and physics.
This is what I have so far:
I know how to implement, and have implemented most of these "components" in different projects before, but I have no idea how to structure this in a good way.
Some important concepts:
Math functions will be accessed from almost every part of the engine/framework, as well as the executable(s)
Communication between Graphics<->Input<->GUI
So, here are my questions:
1. Should all of these be classes? To me it seems more reasonable to have the math part as just a collection of functions, how about the others?
2. Should any of these classes be implemented as singletons? Where does the user of my framework access these objects and when are they created?
I'm using a mac and SDL for this, but this is really a cross-platform/cross-library subject so don't worry about the mac part. I know SDL isn't that great for drawing but I want to get comfortable with it before moving on to SDL+OpenGL. Thanks to avansc and his video, I was able to set up a static library in a nice way inside XCode.
I want to have a simple and clean setup, this is a pretty simple 2D project and doesn't require as much drawing, math or physics code as bigger 2D/3D projects like Elysian Shadows or GroundUpEngine. I have no intention of implementing advanced collision detection and physics.
This is what I have so far:
Things I need:zaCoreLib.h (constants, includes, typedefs, enum and pointer to screen surface)
^
zaCoreFunc.h (basic initialization, surface loading, drawing and quit function)
^
zaEngine.h (Nothing Implemented here yet)
^ (Includes)
(User)
Better graphics handling - Textures, spritesheets and animation
Input and SDL_Event handling - Keyboard, Mouse, main loop
My own math functions - average, simple 2D non-oriented rectangle collision, random number generator and more
Sound - Sound effects and music
GUI - GUI, buttons and text
(Window class ?)
I know how to implement, and have implemented most of these "components" in different projects before, but I have no idea how to structure this in a good way.
Some important concepts:
Math functions will be accessed from almost every part of the engine/framework, as well as the executable(s)
Communication between Graphics<->Input<->GUI
So, here are my questions:
1. Should all of these be classes? To me it seems more reasonable to have the math part as just a collection of functions, how about the others?
2. Should any of these classes be implemented as singletons? Where does the user of my framework access these objects and when are they created?