[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" |
---|
[7338] | 12 | #include "playable.h" |
---|
[6352] | 13 | |
---|
| 14 | class Shell; |
---|
[6402] | 15 | class WorldEntity; |
---|
[6352] | 16 | |
---|
[7131] | 17 | /** How many frames time values to keep |
---|
| 18 | * The higher the value the smoother the result is... |
---|
| 19 | * Don't make it 0 or less :) |
---|
| 20 | */ |
---|
| 21 | #define TICK_SMOOTH_VALUE 10 |
---|
[6402] | 22 | |
---|
[6352] | 23 | //! The game world |
---|
| 24 | /** |
---|
| 25 | * this class initializes everything that should be displayed inside of the current level. |
---|
| 26 | * it is the main driving factor during gameplay. |
---|
| 27 | */ |
---|
| 28 | class GameWorld : public StoryEntity |
---|
| 29 | { |
---|
| 30 | public: |
---|
[6989] | 31 | GameWorld (); |
---|
[6352] | 32 | virtual ~GameWorld (); |
---|
| 33 | |
---|
[6512] | 34 | virtual void loadParams(const TiXmlElement* root); |
---|
[6352] | 35 | |
---|
[6370] | 36 | /* functions from story-entity */ |
---|
| 37 | virtual ErrorMessage init(); |
---|
[6372] | 38 | virtual ErrorMessage loadData(); |
---|
[6387] | 39 | virtual ErrorMessage unloadData(); |
---|
[6352] | 40 | |
---|
[6387] | 41 | virtual bool start(); |
---|
| 42 | virtual bool stop(); |
---|
| 43 | virtual bool pause(); |
---|
| 44 | virtual bool resume(); |
---|
| 45 | virtual void run(); |
---|
[6352] | 46 | |
---|
[7338] | 47 | void setPlaymode(Playable::Playmode playmode); |
---|
[7339] | 48 | void setPlaymode(const std::string& playmode); |
---|
[6366] | 49 | /** this returns the current game time @returns elapsed game time */ |
---|
| 50 | inline double getGameTime() { return this->gameTime; } |
---|
| 51 | /** sets the game speed @param speed speed of the Game */ |
---|
[6352] | 52 | inline void setSpeed(float speed) { this->speed = speed; }; |
---|
[6366] | 53 | /** returns the track path of this world @returns the track path */ |
---|
[6352] | 54 | |
---|
[7004] | 55 | static void togglePNodeVisibility(); |
---|
| 56 | static void toggleBVVisibility(); |
---|
[6352] | 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(); |
---|
[7370] | 65 | virtual void tick(ObjectManager::EntityList worldEntity, float dt); |
---|
[6386] | 66 | virtual void tick(); |
---|
| 67 | virtual void update(); |
---|
| 68 | virtual void collide(); |
---|
[7370] | 69 | |
---|
| 70 | void drawEntityList(const ObjectManager::EntityList& drawList ) const; |
---|
[6386] | 71 | virtual void draw(); |
---|
| 72 | virtual void display(); |
---|
[6352] | 73 | |
---|
| 74 | |
---|
[6386] | 75 | private: |
---|
| 76 | void displayLoadScreen(); |
---|
| 77 | void releaseLoadScreen(); |
---|
| 78 | |
---|
| 79 | |
---|
[6352] | 80 | protected: |
---|
[6407] | 81 | GameWorldData* dataTank; //!< reference to the GameWorld Data Tank |
---|
[6845] | 82 | TiXmlElement* dataXML; //!< The XML-Element this World has been loaded with. |
---|
[6352] | 83 | |
---|
[6387] | 84 | bool showPNodes; //!< if the PNodes should be visible. |
---|
| 85 | bool showBV; //!< if the Bounding Volumes should be visible. |
---|
[6352] | 86 | |
---|
| 87 | /* world timing */ |
---|
[7131] | 88 | Uint32 lastFrame; //!< last time of frame (in MiliSeconds) |
---|
[6402] | 89 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
| 90 | float dtS; //!< The time needed for caluculations in seconds |
---|
| 91 | float speed; //!< how fast the game flows |
---|
| 92 | double gameTime; //!< this is where the game time is saved |
---|
[7131] | 93 | Uint32 frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. |
---|
[6352] | 94 | |
---|
[7131] | 95 | |
---|
[6352] | 96 | /* external modules interfaces */ |
---|
[6387] | 97 | Shell* shell; |
---|
| 98 | }; |
---|
[6352] | 99 | |
---|
| 100 | #endif /* _GAME_WORLD_H */ |
---|