Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7290 was 7283, checked in by bensch, 18 years ago

orxonox/trunk: thread for audio, and 'is' to 'b'

File size: 3.1 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
13#include <SDL_thread.h>
14
15class Shell;
16class WorldEntity;
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 */
29class GameWorld : public StoryEntity
30{
31
32  public:
33    GameWorld ();
34    virtual ~GameWorld ();
35
36    virtual void loadParams(const TiXmlElement* root);
37
38    /* functions from story-entity */
39    virtual ErrorMessage init();
40    virtual ErrorMessage loadData();
41    virtual ErrorMessage unloadData();
42
43    virtual bool start();
44    virtual bool stop();
45    virtual bool pause();
46    virtual bool resume();
47    virtual void run();
48
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 */
52    inline void setSpeed(float speed) { this->speed = speed; };
53    /**  returns the track path of this world @returns the track path */
54
55    static void togglePNodeVisibility();
56    static void toggleBVVisibility();
57
58    static int createAudioThread(void* GameWorld);
59
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(std::list<WorldEntity*> worldEntity, float dt);
69    virtual void tick();
70    virtual void update();
71    virtual void collide();
72    virtual void draw();
73    virtual void display();
74
75
76  private:
77    void displayLoadScreen();
78    void releaseLoadScreen();
79
80
81  protected:
82    SDL_Thread*         audioThread;
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
89    /* world timing */
90    Uint32              lastFrame;                    //!< last time of frame (in MiliSeconds)
91    Uint32              cycle;                        //!< The cycle we are in (starts with 0 and rises with every frame)
92    float               dtS;                          //!< The time needed for caluculations in seconds
93    float               speed;                        //!< how fast the game flows
94    double              gameTime;                     //!< this is where the game time is saved
95    Uint32              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
96
97
98    /* external modules interfaces */
99    Shell*              shell;
100};
101
102#endif /* _GAME_WORLD_H */
Note: See TracBrowser for help on using the repository browser.