First off, I have an image class, which looks something like this (in psuedo code):
Image-------------------VideoSurface source, *destinationRect source, dest-------------------virtual Load(filename)virtual Draw()SetDestination(Screen)SetLocation(x, y)SetSourceRect(x, y, w, h)SetColorKey(r, g, b)Ctor(filename, screen)virtual Dtor
I will use an image as just a static image that wraps SDL's surface and blitting functions. Later I shall derive a Sprite class from it (hence the virtuals).
The screen they draw to is not actually an SDL_Surface, but a screen class that I created:
Screen-----------------VideoSurface surfacefriend Image, ApplicationFlip() <- these are called by "Update()"Clear()Lock()Unlock()-----------------SetVideoMode(width, height, bpp, vidMem, hwPal, dBuf, fs)Update()-----------------
Then there is the "StratusGame" class (the game engine is 'Stratus', yes I know it's corny), which should be inherited
from so that you can create your own SDL_Event handlers and
DrawScene() function.
StratusGame-----------------MainLoop() <-Called every frame, not called by the user-----------------Screen screenEvent eventbool running?-----------------static StratusGame* Initialize();bool SetVideoMode("same as above");void Uninitialize();virtual void DrawScene();virtual void HandleKeyboard();virtual void HandleWindow();----------------
That's all for now. I'm kind of worried that I'm doing something wrong, but I'm going to keep going.
Again, please comment, since most of you are more knowledgable than I.
Edit: I'll probably end up removing the Application stuff, and just writing a bunch of sprite libraries. Then I'll write sprite managers and map handling classes and see how they fit in with an Application layer.