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