Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/orxonox.cc @ 3613

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

orxonox/trunk: taken camera out of orxonox.cc/h because, it just does not belong there

File size: 5.6 KB
RevLine 
[1850]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software Foundation,
18   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
19
[1855]20
21   ### File Specific:
22   main-programmer: Patrick Boenzli
[2190]23   co-programmer: Christian Meyer
[1850]24*/
25
[2190]26#include "orxonox.h"
[3610]27
[2036]28#include "world.h"
29#include "data_tank.h"
[2190]30#include "command_node.h"
[2636]31#include "game_loader.h"
[3610]32#include "graphics_engine.h"
33
[2190]34#include <string.h>
[3592]35int verbose = 4;
[2036]36
[1803]37using namespace std;
38
[2190]39/**
[2636]40   \brief create a new Orxonox
[2190]41*/
42Orxonox::Orxonox ()
[1872]43{
44  pause = false;
45}
[1803]46
[2190]47/**
[2636]48   \brief remove Orxonox from memory
[2190]49*/
[1875]50Orxonox::~Orxonox () 
[2190]51{
[3226]52  Orxonox::singletonRef = NULL;
[2636]53  if( world != NULL) delete world;
54  if( localinput != NULL) delete world;
55  if( resources != NULL) delete resources;
[3611]56  delete GraphicsEngine::getInstance(); // deleting the Graphics
[2190]57}
[1850]58
[3449]59/** \brief this is a singleton class to prevent duplicates */
[3226]60Orxonox* Orxonox::singletonRef = 0;
[1872]61
[3449]62/**
63   \returns reference or new Object of Orxonox if not existent.
64*/
[1850]65Orxonox* Orxonox::getInstance (void)
[1803]66{
[3226]67  if (singletonRef == NULL)
68    singletonRef = new Orxonox();
69  return singletonRef;
[1850]70}
71
[2190]72/**
[2636]73   \brief this finds the config file
74   
75   Since the config file varies from user to user and since one may want to specify different config files
76   for certain occasions or platforms this function finds the right config file for every occasion and stores
77   it's path and name into configfilename
[2190]78*/
[3226]79void Orxonox::getConfigFile (int argc, char** argv)
[1850]80{
[2636]81  strcpy (configfilename, "orxonox.conf");
[1803]82}
83
[2190]84/**
[2636]85   \brief initialize Orxonox with command line
[2190]86*/
87int Orxonox::init (int argc, char** argv)
[1803]88{
[2636]89  // parse command line
90  // config file
91 
[3226]92  getConfigFile (argc, argv);
[3174]93  SDL_Init (SDL_INIT_TIMER);
[2636]94  // initialize everything
[3226]95  if( initVideo() == -1) return -1;
96  if( initSound() == -1) return -1;
[2190]97  printf("> Initializing input\n");
[3226]98  if( initInput() == -1) return -1;
[2190]99  printf("> Initializing networking\n");
[3226]100  if( initNetworking () == -1) return -1;
[2190]101  printf("> Initializing resources\n");
[3226]102  if( initResources () == -1) return -1;
[2636]103  //printf("> Initializing world\n");
104  //if( init_world () == -1) return -1; PB: world will be initialized when started
105 
106  return 0;
[1850]107}
[1849]108
[2190]109/**
[2636]110   \brief initializes SDL and OpenGL
[2190]111*/
[3226]112int Orxonox::initVideo() 
[2190]113{
[3611]114  PRINTF(3)("> Initializing video\n");
[2190]115 
[3610]116  GraphicsEngine::getInstance();
[2190]117 
118  return 0;
119}
[1850]120
[3214]121
[2190]122/**
[2636]123   \brief initializes the sound engine
[2190]124*/
[3226]125int Orxonox::initSound() 
[2190]126{
[3174]127  printf("> Initializing sound\n");
[3226]128  // SDL_Init(SDL_INIT_AUDIO);
[2636]129  printf("Not yet implemented\n");
130  return 0;
[2190]131}
[1900]132
[3214]133
[2190]134/**
[2636]135   \brief initializes input functions
[2190]136*/
[3226]137int Orxonox::initInput() 
[2190]138{
[2636]139  // create localinput
140  localinput = new CommandNode( configfilename);
141 
142  return 0;
[1803]143}
144
[3214]145
[2190]146/**
[2636]147   \brief initializes network system
[2190]148*/
[3226]149int Orxonox::initNetworking() 
[1897]150{
[2636]151  printf("Not yet implemented\n");
152  return 0;
[1897]153}
154
[3214]155
[2190]156/**
[2636]157   \brief initializes and loads resource files
[2190]158*/
[3226]159int Orxonox::initResources() 
[1858]160{
[2636]161  printf("Not yet implemented\n");
162  return 0;
[1858]163}
[1849]164
[3214]165
[2190]166/**
[2636]167   \brief initializes the world
[2190]168*/
[3226]169int Orxonox::initWorld() 
[1896]170{
[2636]171  //world = new World();
172 
173  // TO DO: replace this with a menu/intro
174  //world->load_debug_level();
175 
176  return 0;
[1896]177}
178
[2636]179
[2190]180/**
[2636]181   \brief starts the orxonox game or menu
182
183   here is the central orxonox state manager. There are currently two states
184   - menu
185   - game-play
186   both states manage their states themselfs again.
[2190]187*/
[2636]188void Orxonox::start()
189{
190 
191  this->gameLoader = GameLoader::getInstance();
192  this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0);
193  this->gameLoader->init();
194  this->gameLoader->start();
195}
196
[3214]197
[2636]198/**
199   \brief exits Orxonox
200*/
[1875]201void Orxonox::quitGame() 
202{
[2636]203  bQuitOrxonox = true;
[1875]204}
205
206
[3214]207
[2190]208/**
[2636]209   \brief handles sprecial events from localinput
210   \param event: an event not handled by the CommandNode
[2190]211*/
[3226]212void Orxonox::eventHandler(SDL_Event* event)
[2190]213{
[2636]214  // Handle special events such as reshape, quit, focus changes
[2190]215}
[3214]216 
[1875]217
[2190]218/**
[2636]219   \brief handle keyboard commands that are not meant for WorldEntities
220   \param cmd: the command to handle
221   \return true if the command was handled by the system or false if it may be passed to the WorldEntities
[2190]222*/
[3226]223bool Orxonox::systemCommand(Command* cmd)
[2190]224{
[3220]225  /*
[2636]226  if( !strcmp( cmd->cmd, "quit"))
227    {
228      if( !cmd->bUp) this->gameLoader->stop();
229      return true;
230    }
231  return false;
[3220]232  */
233  return false;
[2190]234}
[1803]235
[2190]236/**
[2636]237   \brief retrieve a pointer to the local CommandNode
238   \return a pointer to localinput
[2190]239*/
[3226]240CommandNode* Orxonox::getLocalInput()
[1850]241{
[2636]242  return localinput;
[1803]243}
244
[3214]245
[2190]246/**
[2636]247   \brief retrieve a pointer to the local World
248   \return a pointer to world
[2190]249*/
[3226]250World* Orxonox::getWorld()
[1872]251{
[2636]252  return world;
[1872]253}
[1850]254
[3449]255/**
256   \return The reference of the SDL-screen of orxonox
257*/
[3365]258SDL_Surface* Orxonox::getScreen ()
259{
260  return this->screen;
261}
[3214]262
[3449]263/**
264   \brief main function
[3214]265
[3449]266   here the journey begins
267*/
[3226]268int main(int argc, char** argv) 
[1803]269{ 
[2636]270  printf(">>> Starting Orxonox <<<\n");
[1850]271  Orxonox *orx = Orxonox::getInstance();
[2190]272 
[3226]273  if((*orx).init(argc, argv) == -1)
[2636]274    {
275      printf("! Orxonox initialization failed\n");
276      return -1;
277    }
278 
279  orx->start();
280 
[2190]281  //delete orx;
282 
[1803]283  return 0;
284}
Note: See TracBrowser for help on using the repository browser.