| 1 |
#ifndef _CSDLGAME_ |
| 2 |
#define _CSDLGAME_ |
| 3 |
|
| 4 |
#include <string> |
| 5 |
#include <vector> |
| 6 |
#include <ctime> |
| 7 |
#include "CAnimation.h" |
| 8 |
#include "CImgLoader.h" |
| 9 |
#include "CSprite.h" |
| 10 |
#include "CVector.h" |
| 11 |
using namespace std; |
| 12 |
|
| 13 |
//! CSDLGame implements the game looop, tracks sprites, adds sprites, etc |
| 14 |
class CSDLGame |
| 15 |
{ |
| 16 |
public: |
| 17 |
//! A constructor |
| 18 |
/*! The constructor inits SDL and sets up the resolution/bit |
| 19 |
depth of the screen. |
| 20 |
\param screenX x value of resolution |
| 21 |
\param screenY y value of resolution |
| 22 |
\param bitDepth bit depth of screen (in bits) |
| 23 |
\exception ex_sdlInitFailed { SDL initialization failed } |
| 24 |
\exception ex_sdlSurfaceCreationFailed { Changing resolution/bit-depth of screen failed } |
| 25 |
\exception ex_sdlGenFail { Something went wrong with SDL, check error string and error value } |
| 26 |
*/ |
| 27 |
CSDLGame(int screenX, int screenY, int bitDepth, bool fullscreen = true, const string &title = ""); |
| 28 |
|
| 29 |
//! A desctructor |
| 30 |
/*! Cleans up SDL */ |
| 31 |
virtual ~CSDLGame(); |
| 32 |
|
| 33 |
/* virtual void pause(); |
| 34 |
virtual void stop();*/ |
| 35 |
virtual void start(); |
| 36 |
virtual void update() { gameLoop(false); } |
| 37 |
void resize(int screenX, int screenY, int bitDepth, bool fullscreen); |
| 38 |
|
| 39 |
protected: |
| 40 |
virtual bool gameLoop(bool infinite = true) = 0; //! Main game loop |
| 41 |
CSurface* screen; //! Holds actual surface representing screen in memory |
| 42 |
|
| 43 |
private: |
| 44 |
/* void animateSprites(); //! Animates sprites (based on the animation they are on) |
| 45 |
void moveSprites(); //! Moves sprites (based on velocity vector)*/ |
| 46 |
// vector<CSprite*> sprites; //! vector containing all active sprites (dead, invisible sprites are removed) |
| 47 |
}; |
| 48 |
|
| 49 |
#endif |