[6352] | 1 | /*! |
---|
| 2 | * @file game_world.h |
---|
| 3 | * container for all game worlds (singleplayers, multiplayers..) |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _GAME_WORLD_H |
---|
| 7 | #define _GAME_WORLD_H |
---|
| 8 | |
---|
[6402] | 9 | |
---|
[6352] | 10 | #include "story_entity.h" |
---|
[6498] | 11 | #include "game_world_data.h" |
---|
[6352] | 12 | |
---|
| 13 | class TiXmlElement; |
---|
| 14 | class Shell; |
---|
[6402] | 15 | class WorldEntity; |
---|
[6387] | 16 | class GameWorldData; |
---|
[6352] | 17 | |
---|
[6402] | 18 | |
---|
[6352] | 19 | //! The game world |
---|
| 20 | /** |
---|
| 21 | * this class initializes everything that should be displayed inside of the current level. |
---|
| 22 | * it is the main driving factor during gameplay. |
---|
| 23 | */ |
---|
| 24 | class GameWorld : public StoryEntity |
---|
| 25 | { |
---|
| 26 | |
---|
| 27 | public: |
---|
| 28 | GameWorld (const TiXmlElement* root = NULL); |
---|
| 29 | virtual ~GameWorld (); |
---|
| 30 | |
---|
[6512] | 31 | virtual void loadParams(const TiXmlElement* root); |
---|
[6352] | 32 | |
---|
[6370] | 33 | /* functions from story-entity */ |
---|
| 34 | virtual ErrorMessage init(); |
---|
[6372] | 35 | virtual ErrorMessage loadData(); |
---|
[6387] | 36 | virtual ErrorMessage unloadData(); |
---|
[6352] | 37 | |
---|
[6387] | 38 | virtual bool start(); |
---|
| 39 | virtual bool stop(); |
---|
| 40 | virtual bool pause(); |
---|
| 41 | virtual bool resume(); |
---|
| 42 | virtual void run(); |
---|
[6352] | 43 | |
---|
[6366] | 44 | /** this returns the current game time @returns elapsed game time */ |
---|
| 45 | inline double getGameTime() { return this->gameTime; } |
---|
| 46 | /** sets the game speed @param speed speed of the Game */ |
---|
[6352] | 47 | inline void setSpeed(float speed) { this->speed = speed; }; |
---|
[6366] | 48 | /** returns the track path of this world @returns the track path */ |
---|
[6386] | 49 | const char* getPath() { return this->path; } |
---|
[6352] | 50 | void setPath( const char* name); |
---|
| 51 | |
---|
[6366] | 52 | /** toggles the PNode visibility in the world (drawn as boxes) */ |
---|
[6352] | 53 | void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; }; |
---|
[6366] | 54 | /** toggles the bounding volume (BV) visibility */ |
---|
[6352] | 55 | void toggleBVVisibility() { this->showBV = !this->showBV; }; |
---|
| 56 | |
---|
| 57 | |
---|
[6498] | 58 | inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; } |
---|
| 59 | |
---|
| 60 | |
---|
[6352] | 61 | protected: |
---|
| 62 | /* world - running functions */ |
---|
[6386] | 63 | virtual void synchronize(); |
---|
| 64 | virtual void handleInput(); |
---|
| 65 | virtual void tick(std::list<WorldEntity*> worldEntity, float dt); |
---|
| 66 | virtual void tick(); |
---|
| 67 | virtual void update(); |
---|
| 68 | virtual void collide(); |
---|
| 69 | virtual void draw(); |
---|
| 70 | virtual void display(); |
---|
[6352] | 71 | |
---|
| 72 | |
---|
[6386] | 73 | private: |
---|
| 74 | void displayLoadScreen(); |
---|
| 75 | void releaseLoadScreen(); |
---|
| 76 | |
---|
| 77 | |
---|
[6352] | 78 | protected: |
---|
[6407] | 79 | GameWorldData* dataTank; //!< reference to the GameWorld Data Tank |
---|
[6387] | 80 | char* path; //!< The file from which this world is loaded |
---|
[6352] | 81 | |
---|
[6387] | 82 | bool showPNodes; //!< if the PNodes should be visible. |
---|
| 83 | bool showBV; //!< if the Bounding Volumes should be visible. |
---|
[6352] | 84 | |
---|
| 85 | /* world timing */ |
---|
[6402] | 86 | Uint32 lastFrame; //!< last time of frame |
---|
| 87 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
| 88 | Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) |
---|
| 89 | float dtS; //!< The time needed for caluculations in seconds |
---|
| 90 | float speed; //!< how fast the game flows |
---|
| 91 | double gameTime; //!< this is where the game time is saved |
---|
[6352] | 92 | |
---|
| 93 | /* external modules interfaces */ |
---|
[6387] | 94 | Shell* shell; |
---|
| 95 | }; |
---|
[6352] | 96 | |
---|
| 97 | #endif /* _GAME_WORLD_H */ |
---|