SDL Game Template

Talk about programming, or anything else related to game development here!

SDL Game Template

Postby anihex on Tue Jul 27, 2010 4:20 pm

Hi,

I was thinking about a(nother) SDL Game Template. I also want make a tutorial on how to get to this point and on how to use/expand it.
The current version of the template is hosted on my "website". You can find it -> Here.

Any ideas on how to improve it (except of the documentation)?
"There are only 10 different kinds of humans. Those who understand the binary code and thos who don't."

Image
User avatar
anihex
 
Posts: 205
Joined: Tue Jan 05, 2010 6:56 am
Location: Germany

Re: SDL Game Template

Postby WSP_SNIPER on Sat Jul 31, 2010 10:22 pm

looks really nice. depending on how far you want to take it my favorite way to handle game states is to create an abstract base class State then inherit from it to create the new game states.

Code: Select all
#ifndef _STATE_H_
#define _STATE_H_
#include "whatever.hpp"

class State
{
protected:
    State() {}
public:
    virtual ~State() {}
    virtual void HandleEvents(SDL_Event* event) = 0;
    virtual void Render(SDL_Surface* screen) = 0;
    // add the functions that are in your TGame class

};
#endif


ok the constructor is protected because i make it a singleton now just inherit from this and overload the functions to do what your state dose then create a vector of states in the game class and create a pushState and popState that put and take off states and in the render and handle event functions just call states.back().Render(screen) or states.back().handleEvents(event);

ok now some other things would to be to add an image class that can load an image and render it to the screen just to make your life easier
Image
User avatar
WSP_SNIPER
 
Posts: 152
Joined: Sun May 30, 2010 8:02 pm


Return to Game development discussion

Who is online

Users browsing this forum: No registered users and 1 guest