| 1 | #ifndef _FRAMEWORK_H |
|---|
| 2 | #define _FRAMEWORK_H |
|---|
| 3 | |
|---|
| 4 | #include "vector.h" |
|---|
| 5 | #include "glincl.h" |
|---|
| 6 | #include "debug.h" |
|---|
| 7 | #include "graphics_engine.h" |
|---|
| 8 | |
|---|
| 9 | #ifdef GUI_MODULE |
|---|
| 10 | #include "gui_gtk.h" |
|---|
| 11 | #endif |
|---|
| 12 | |
|---|
| 13 | #define MOUSE_BUTTON_COUNT 3 |
|---|
| 14 | |
|---|
| 15 | #define TICK_SMOOTH_VALUE 10 |
|---|
| 16 | |
|---|
| 17 | class Camera; |
|---|
| 18 | |
|---|
| 19 | class Framework { |
|---|
| 20 | public: |
|---|
| 21 | virtual ~Framework(); |
|---|
| 22 | |
|---|
| 23 | /** \returns a Pointer to the only object of this Class */ |
|---|
| 24 | inline static Framework* getInstance(void) { if (!singletonRef) singletonRef = new Framework(); return singletonRef; }; |
|---|
| 25 | |
|---|
| 26 | public: |
|---|
| 27 | void moduleInit(int argc, char** argv); |
|---|
| 28 | #ifdef GUI_MODULE |
|---|
| 29 | void moduleInitGui(int argc, char** argv); |
|---|
| 30 | #endif |
|---|
| 31 | void moduleEventHandler(SDL_Event* event); |
|---|
| 32 | void moduleTick(float dt); |
|---|
| 33 | void moduleDraw(void) const; |
|---|
| 34 | |
|---|
| 35 | void moduleHelp(void) const; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | void init(void); |
|---|
| 39 | static void* mainLoop(void* tmp); |
|---|
| 40 | bool draw(float dt); |
|---|
| 41 | float tick(); |
|---|
| 42 | bool eventHandler(); |
|---|
| 43 | void quit(); |
|---|
| 44 | |
|---|
| 45 | static void* mainloopGui(void* tmp); |
|---|
| 46 | |
|---|
| 47 | void printHelp(void) const; |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | private: |
|---|
| 51 | Framework(); |
|---|
| 52 | |
|---|
| 53 | private: |
|---|
| 54 | static Framework* singletonRef; |
|---|
| 55 | |
|---|
| 56 | Camera* camera; |
|---|
| 57 | |
|---|
| 58 | bool isFinished; |
|---|
| 59 | |
|---|
| 60 | int movement [4]; |
|---|
| 61 | float backgroundColor[4]; |
|---|
| 62 | |
|---|
| 63 | /* world timing */ |
|---|
| 64 | Uint32 lastFrame; //!< last time of frame (in MiliSeconds) |
|---|
| 65 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
|---|
| 66 | float dtS; //!< The time needed for caluculations in seconds |
|---|
| 67 | float speed; //!< how fast the game flows |
|---|
| 68 | double gameTime; //!< this is where the game time is saved |
|---|
| 69 | Uint32 frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. |
|---|
| 70 | |
|---|
| 71 | Uint8* keys; // This variable will be used in the keyboard routine |
|---|
| 72 | bool mouseDown[MOUSE_BUTTON_COUNT]; |
|---|
| 73 | |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | #ifdef GUI_MODULE |
|---|
| 77 | int quitGui(GtkWidget* widget, void* data); |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | #endif /* _FRAMEWORK_H */ |
|---|