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