Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/main_reto_vs05/src/orxonox.cc @ 159

Last change on this file since 159 was 159, checked in by rgrieder, 16 years ago
File size: 2.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29* Basic part of the game.
30* It sets up Ogre and most important of all: Orxonox is the master of the
31* main loop and therefore time itself.
32*/
33
34
35#include "orxonox.h"
36
37
38/**
39* Empty Constructor.
40*/
41Orxonox::Orxonox()
42{
43}
44
45
46/**
47* Empty Destructor.
48*/
49Orxonox::~Orxonox()
50{
51}
52
53
54/**
55* Starts and runs the game
56*/
57void Orxonox::go(void)
58{
59        if (!setup())
60                return;
61
62        timer_ = new Timer();
63
64        unsigned long lastTime = timer_->getMilliseconds();
65
66        while (true)
67        {
68                //Pump messages in all registered RenderWindow windows
69                WindowEventUtilities::messagePump();
70
71                ogre_->getRoot()->renderOneFrame();
72
73                if (!runMgr_->tick(timer_->getMilliseconds(),
74            (timer_->getMilliseconds() - lastTime) / 1000.0))
75                        break;
76                lastTime = timer_->getMilliseconds();
77        }
78
79        // clean up
80        destroy();
81}
82
83
84/**
85* Create render engine, render window and the Run manager.
86* @return False if failed.
87*/
88bool Orxonox::setup(void)
89{
90        // create new 3D ogre render engine
91        ogre_ = new OgreControl();
92        ogre_->initialise();
93
94        runMgr_ = new RunManager(ogre_);
95
96        return true;
97}
98
99
100/**
101* Clean everything up.
102*/
103void Orxonox::destroy()
104{
105        if (timer_)
106                delete timer_;
107        if (runMgr_)
108                delete runMgr_;
109        if (ogre_)
110                delete ogre_;
111}
Note: See TracBrowser for help on using the repository browser.