Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/game_world.h @ 7142

Last change on this file since 7142 was 7131, checked in by bensch, 19 years ago

orxonox/trunk: framerate calculation is much more 'accurate' meaning, if it is falling from one value into another one, the rate will be averanged to the middle.

File size: 3.0 KB
Line 
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
13class Shell;
14class WorldEntity;
15
16/** How many frames time values to keep
17 * The higher the value the smoother the result is...
18 * Don't make it 0 or less :)
19 */
20#define TICK_SMOOTH_VALUE 10
21
22//! The game world
23/**
24 *  this class initializes everything that should be displayed inside of the current level.
25 *  it is the main driving factor during gameplay.
26 */
27class GameWorld : public StoryEntity
28{
29
30  public:
31    GameWorld ();
32    virtual ~GameWorld ();
33
34    virtual void loadParams(const TiXmlElement* root);
35
36    /* functions from story-entity */
37    virtual ErrorMessage init();
38    virtual ErrorMessage loadData();
39    virtual ErrorMessage unloadData();
40
41    virtual bool start();
42    virtual bool stop();
43    virtual bool pause();
44    virtual bool resume();
45    virtual void run();
46
47    /**  this returns the current game time @returns elapsed game time     */
48    inline double getGameTime() { return this->gameTime; }
49    /** sets the game speed @param speed speed of the Game */
50    inline void setSpeed(float speed) { this->speed = speed; };
51    /**  returns the track path of this world @returns the track path */
52
53    static void togglePNodeVisibility();
54    static void toggleBVVisibility();
55
56
57
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(std::list<WorldEntity*> worldEntity, float dt);
67    virtual void tick();
68    virtual void update();
69    virtual void collide();
70    virtual void draw();
71    virtual void display();
72
73
74  private:
75    void displayLoadScreen();
76    void releaseLoadScreen();
77
78
79  protected:
80    GameWorldData*      dataTank;                     //!< reference to the GameWorld Data Tank
81    TiXmlElement*       dataXML;                      //!< The XML-Element this World has been loaded with.
82
83    bool                showPNodes;                   //!< if the PNodes should be visible.
84    bool                showBV;                       //!< if the Bounding Volumes should be visible.
85
86    /* world timing */
87    Uint32              lastFrame;                    //!< last time of frame (in MiliSeconds)
88    Uint32              cycle;                        //!< The cycle we are in (starts with 0 and rises with every frame)
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
92    Uint32              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
93
94
95    /* external modules interfaces */
96    Shell*              shell;
97};
98
99#endif /* _GAME_WORLD_H */
Note: See TracBrowser for help on using the repository browser.