Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/world.cc @ 6210

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

typo

File size: 18.3 KB
RevLine 
[4555]1/*
[1853]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.
[1855]10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
[2190]13   co-programmer: Christian Meyer
[5390]14   co-programmer: Benjamin Grauer
[1853]15*/
16
[3590]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
18
[2190]19#include "world.h"
[3608]20
[5205]21#include "shell_command.h"
[6150]22#include "resource_manager.h"
[4347]23#include "state.h"
24
[3608]25#include "p_node.h"
[2190]26#include "world_entity.h"
[2036]27#include "player.h"
[2190]28#include "camera.h"
[2816]29#include "environment.h"
[6151]30#include "terrain.h"
[6150]31
[4245]32#include "test_entity.h"
[3608]33#include "terrain.h"
[3436]34#include "light.h"
[4726]35#include "load_param.h"
[5174]36#include "shell.h"
[3620]37
[4940]38#include "fast_factory.h"
[3812]39#include "animation_player.h"
[4176]40#include "particle_engine.h"
[4245]41#include "graphics_engine.h"
[4338]42#include "physics_engine.h"
[4396]43#include "fields.h"
[3646]44
[4488]45#include "md2Model.h"
46
[3608]47#include "glmenu_imagescreen.h"
48#include "list.h"
[4010]49#include "game_loader.h"
[2036]50
[3964]51#include "animation3d.h"
[3608]52
[4010]53#include "substring.h"
[3608]54
[4261]55#include "factory.h"
[4245]56
[5556]57#include "weapons/projectile.h"
[4405]58#include "event_handler.h"
[4504]59#include "sound_engine.h"
[4961]60#include "ogg_player.h"
[4504]61
[4747]62#include "class_list.h"
63
[4917]64#include "cd_engine.h"
[5750]65#include "npcs/npc_test1.h"
[5318]66#include "shader.h"
[4820]67
[5915]68#include "playable.h"
[5996]69#include "network_manager.h"
70#include "playable.h"
[5915]71
[5996]72
[5205]73SHELL_COMMAND(speed, World, setSpeed);
[5389]74SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);
[5429]75SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);
[5205]76
[1856]77using namespace std;
[1853]78
[4978]79//! This creates a Factory to fabricate a World
[5750]80CREATE_FACTORY(World, CL_WORLD);
[3620]81
[4261]82World::World(const TiXmlElement* root)
[4010]83{
84  this->constuctorInit("", -1);
[4094]85  this->path = NULL;
[4555]86
[4261]87  this->loadParams(root);
[4010]88}
89
[4555]90/**
[4838]91 *  remove the World from memory
[6150]92 *
93 *  delete everything explicitly, that isn't contained in the parenting tree!
94 *  things contained in the tree are deleted automaticaly
[4838]95 */
[2190]96World::~World ()
[1872]97{
[5206]98  delete this->shell;
[3546]99  PRINTF(3)("World::~World() - deleting current world\n");
[3677]100
[5915]101  delete this->localPlayer;
[5115]102
[5296]103  // delete all the initialized Engines.
[5447]104  FastFactory::flushAll(true);
[4735]105  delete LightManager::getInstance();
[4822]106  delete ParticleEngine::getInstance();
[5296]107  delete AnimationPlayer::getInstance();
[4978]108  delete PhysicsEngine::getInstance();
[4822]109
[4978]110  // external engines initialized by the orxonox-class get deleted
[4504]111  SoundEngine::getInstance()->flushAllBuffers();
[4830]112  SoundEngine::getInstance()->flushAllSources();
[4504]113
[6142]114  if (State::getObjectManager() == &this->objectManager)
115    State::setObjectManager(NULL);
[4978]116  // erease everything that is left.
[6074]117  delete PNode::getNullParent();
[5915]118
[6054]119  //secondary cleanup of PNodes;
120  const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE);
121  if (nodeList != NULL)
122    while (!nodeList->empty())
123      delete nodeList->front();
124
[5318]125  Shader::suspendShader();
[4872]126
[4978]127  // unload the resources !!
[4136]128  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
[1872]129}
[1858]130
[3526]131/**
[4978]132 * initializes the world.
133 * @param name the name of the world
134 * @param worldID the ID of this world
135 *
136 * set all stuff here that is world generic and does not use to much memory
137 * because the real init() function StoryEntity::init() will be called
138 * shortly before start of the game.
139 * since all worlds are initiated/referenced before they will be started.
140 * NO LEVEL LOADING HERE - NEVER!
[3526]141*/
[4978]142void World::constuctorInit(const char* name, int worldID)
[3526]143{
[4320]144  this->setClassID(CL_WORLD, "World");
[2636]145
[4978]146  this->setName(name);
[5211]147  this->gameTime = 0.0f;
[5205]148  this->setSpeed(1.0);
[4961]149  this->music = NULL;
[5211]150  this->shell = NULL;
[5915]151  this->localPlayer = NULL;
152  this->localCamera = NULL;
[5389]153
154  this->showPNodes = false;
[5429]155  this->showBV = false;
[3629]156}
[3526]157
[4978]158/**
159 * loads the parameters of a World from an XML-element
160 * @param root the XML-element to load from
161 */
[4261]162void World::loadParams(const TiXmlElement* root)
163{
[4600]164  PRINTF(4)("Creating a World\n");
[4261]165
[5671]166  LoadParam(root, "identifier", this, World, setStoryID)
[4261]167    .describe("Sets the StoryID of this world");
[4834]168
[5671]169  LoadParam(root, "nextid", this, World, setNextStoryID)
[4261]170    .describe("Sets the ID of the next world");
[4834]171
[5671]172  LoadParam(root, "path", this, World, setPath)
[4261]173    .describe("The Filename of this World (relative from the data-dir)");
174}
175
[3629]176/**
[4978]177 * this is executed just before load
178 *
179 * since the load function sometimes needs data, that has been initialized
180 * before the load and after the proceeding storyentity has finished
[3629]181*/
182ErrorMessage World::preLoad()
183{
[6142]184  State::setObjectManager(&this->objectManager);
[4829]185  this->cycle = 0;
186
[3620]187  /* init the world interface */
[5206]188  this->shell = new Shell();
[4010]189
[4735]190  LightManager::getInstance();
[6074]191  PNode::getNullParent();
[3993]192
[4010]193  AnimationPlayer::getInstance(); // initializes the animationPlayer
[5915]194  ParticleEngine::getInstance();
[4338]195  PhysicsEngine::getInstance();
[4010]196
[4015]197  this->localCamera = new Camera();
[4978]198  this->localCamera->setName ("World-Camera");
[4555]199
[4827]200  State::setCamera(this->localCamera, this->localCamera->getTarget());
[4347]201
[4245]202  GraphicsEngine::getInstance()->displayFPS(true);
[6152]203  this->displayLoadScreen();
[3526]204}
205
206
[3449]207/**
[4836]208 *  loads the World by initializing all resources, and set their default values.
[6150]209 */
[3459]210ErrorMessage World::load()
[4555]211{
[4104]212  PRINTF(3)("> Loading world: '%s'\n", getPath());
213  TiXmlElement* element;
[4010]214  GameLoader* loader = GameLoader::getInstance();
[4555]215
[4010]216  if( getPath() == NULL)
[2636]217    {
[4104]218      PRINTF(1)("World has no path specified for loading");
[4010]219      return (ErrorMessage){213,"Path not specified","World::load()"};
220    }
[4555]221
[5915]222  TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());
[4010]223  // load the campaign document
[4555]224  if( !XMLDoc->LoadFile())
[4010]225  {
226    // report an error
[5915]227    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
[4010]228    delete XMLDoc;
229    return (ErrorMessage){213,"XML File parsing error","World::load()"};
230  }
[4555]231
[4010]232  // check basic validity
233  TiXmlElement* root = XMLDoc->RootElement();
234  assert( root != NULL);
[4555]235
[4010]236  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
237    {
238      // report an error
[4104]239      PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
[4010]240      delete XMLDoc;
241      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
242    }
[4555]243
[4010]244  // load the parameters
245  // name
246  const char* string = grabParameter( root, "name");
247  if( string == NULL)
248    {
[4104]249      PRINTF(2)("World is missing a proper 'name'\n");
[5211]250      this->setName("Unknown");
[4010]251    }
252  else
253    {
[5211]254      this->setName(string);
[4010]255    }
[4978]256
[4104]257  ////////////////
258  // LOADSCREEN //
259  ////////////////
260  element = root->FirstChildElement("LoadScreen");
261  if (element == NULL)
262    {
263      PRINTF(2)("no LoadScreen specified, loading default\n");
264
265      glmis->setBackgroundImage("pictures/load_screen.jpg");
266      this->glmis->setMaximum(8);
267      this->glmis->draw();
268    }
269  else
270    {
[4261]271      this->glmis->loadParams(element);
[4104]272      this->glmis->draw();
273    }
274  this->glmis->draw();
[4726]275
276  ////////////////////////
277  // find WorldEntities //
278  ////////////////////////
279
[4104]280  element = root->FirstChildElement("WorldEntities");
[4555]281
[4010]282  if( element == NULL)
283    {
[4104]284      PRINTF(1)("World is missing 'WorldEntities'\n");
[4010]285    }
286  else
287    {
288      element = element->FirstChildElement();
289      // load Players/Objects/Whatever
[4104]290      PRINTF(4)("Loading WorldEntities\n");
[4010]291      while( element != NULL)
[4555]292        {
[5996]293          BaseObject* created = Factory::fabricate(element);
[5915]294          if( created != NULL )
295          {
296            if(created->isA(CL_WORLD_ENTITY))
297              this->spawn(dynamic_cast<WorldEntity*>(created));
[5996]298            printf("Created a %s: %s\n", created->getClassName(), created->getName());
[5915]299          }
300
[4555]301          // if we load a 'Player' we use it as localPlayer
[5915]302
303
[4555]304          //todo do this more elegant
[5915]305          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
[6150]306            this->sky = dynamic_cast<WorldEntity*>(created);
[4918]307          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
308          {
[5915]309            terrain = dynamic_cast<Terrain*>(created);
[4918]310            CDEngine::getInstance()->setTerrain(terrain);
311          }
[4555]312          element = element->NextSiblingElement();
[4836]313          glmis->step(); //! @todo temporary
[4555]314        }
[4104]315      PRINTF(4)("Done loading WorldEntities\n");
[4010]316    }
[4555]317
[4726]318    //////////////////////////////
319    // LOADING ADDITIONAL STUFF //
320    //////////////////////////////
321
[5652]322    LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
[4735]323
[5915]324   LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);
325//   LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);
[4726]326
[4010]327  // free the XML data
[4015]328
[4010]329  delete XMLDoc;
[4015]330  /* GENERIC LOADING PROCESS FINISHED */
[4555]331
332
[5915]333  // Create a Player
334  this->localPlayer = new Player();
[4245]335
[5915]336  Playable* playable;
337  const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);
338  if (playableList != NULL)
339  {
340    playable = dynamic_cast<Playable*>(playableList->front());
341    this->localPlayer->setControllable(playable);
342  }
[4555]343
[5915]344  // bind camera
345  playable->addChild (this->localCamera);
[4555]346
[5915]347//   //localCamera->setParent(TrackNode::getInstance());
348//  tn->addChild(this->localCamera);
[4620]349  localCamera->setClipRegion(1, 10000.0);
[5915]350  localCamera->lookAt(playable);
351//  this->localPlayer->setParentMode(PNODE_ALL);
[5355]352  if (sky != NULL)
353  {
354    this->sky->setParent(this->localCamera);
355    this->sky->setParentMode(PNODE_MOVEMENT);
356  }
[3368]357
[4504]358  SoundEngine::getInstance()->setListener(this->localCamera);
[4176]359
[4347]360
[4709]361
[4715]362  ////////////
363  // STATIC //
364  ////////////
365
366
[4721]367//   TestEntity* testEntity = new TestEntity();
368//   testEntity->setRelCoor(Vector(570, 10, -15));
369//   testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
370//   this->spawn(testEntity);
[4397]371
[4976]372  for(int i = 0; i < 100; i++)
373  {
[5750]374    WorldEntity* tmp = new NPCTest1();
[5049]375    char npcChar[10];
376    sprintf (npcChar, "NPC_%d", i);
[5256]377        tmp->setName(npcChar);
[5336]378    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
[4976]379    this->spawn(tmp);
380  }
381
[6034]382  this->music = NULL;
383  //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
[5211]384  //music->playback();
[4010]385}
[3365]386
[6152]387ErrorMessage World::postLoad()
388{
389  this->releaseLoadScreen();
390}
[4245]391
[6152]392
[4326]393/**
[4836]394 *  initializes a new World shortly before start
[4978]395 *
396 * this is the function, that will be loaded shortly before the world is
397 * started
[3459]398*/
[6152]399ErrorMessage World::preStart()
[3459]400{
401  this->bPause = false;
[5051]402
403  /* update the object position before game start - so there are no wrong coordinates used in the first processing */
[6074]404  PNode::getNullParent()->updateNode (0.001f);
405  PNode::getNullParent()->updateNode (0.001f);
[3459]406}
407
408
409/**
[4836]410 *  starts the World
[6150]411 */
[3459]412ErrorMessage World::start()
413{
[6151]414  this->bQuitWorld = false;
[3459]415  this->mainLoop();
416}
417
418/**
[4836]419 *  stops the world.
[3459]420
421   This happens, when the player decides to end the Level.
422*/
423ErrorMessage World::stop()
424{
[3546]425  PRINTF(3)("World::stop() - got stop signal\n");
[6151]426  this->bQuitWorld= true;
[3459]427}
428
429/**
[4836]430 *  pauses the Game
[3459]431*/
432ErrorMessage World::pause()
433{
434  this->isPaused = true;
435}
436
437/**
[4836]438 *  ends the pause Phase
[3459]439*/
440ErrorMessage World::resume()
441{
442  this->isPaused = false;
443}
444
445/**
[4836]446 *  destroys the World
[3459]447*/
448ErrorMessage World::destroy()
449{
[3566]450
[3459]451}
452
453/**
[4836]454 *  shows the loading screen
[3459]455*/
456void World::displayLoadScreen ()
457{
[4555]458  PRINTF(3)("World::displayLoadScreen - start\n");
459
460  //GLMenuImageScreen*
[4099]461  this->glmis = new GLMenuImageScreen();
[3675]462  this->glmis->setMaximum(8);
[4555]463
464  PRINTF(3)("World::displayLoadScreen - end\n");
[3459]465}
466
467/**
[6150]468 * @brief removes the loadscreen, and changes over to the game
469 *
470 * @todo take out the delay
[3459]471*/
472void World::releaseLoadScreen ()
473{
[4555]474  PRINTF(3)("World::releaseLoadScreen - start\n");
[3459]475  this->glmis->setValue(this->glmis->getMaximum());
[4555]476  PRINTF(3)("World::releaseLoadScreen - end\n");
[4099]477  delete this->glmis;
[3459]478}
479
480
[3620]481/**
[4836]482 *  this returns the current game time
483 * @returns elapsed game time
[3646]484*/
485double World::getGameTime()
486{
487  return this->gameTime;
488}
489
[3225]490
[5045]491
[2190]492/**
[4836]493 *  synchronize local data with remote data
[1855]494*/
[2636]495void World::synchronize ()
[1855]496{
[2636]497  // Get remote input
498  // Update synchronizables
[5996]499/*  NetworkManager::getInstance()->synchronize();*/
[1855]500}
[2636]501
[3459]502
[2636]503/**
[4836]504 *  run all input processing
[3225]505
506   the command node is the central input event dispatcher. the node uses the even-queue from
507   sdl and has its own event-passing-queue.
[2636]508*/
[3225]509void World::handleInput ()
[2636]510{
[4407]511  EventHandler::getInstance()->process();
512
[2636]513  // remoteinput
514}
515
[6142]516void World::tick(std::list<WorldEntity*> entityList, float dt)
517{
518  std::list<WorldEntity*>::iterator entity;
519  for (entity = entityList.begin(); entity != entityList.end(); entity++)
520    (*entity)->tick(dt);
[3459]521
[6142]522}
523
[2636]524/**
[4836]525 *  advance the timeline
[3225]526
527   this calculates the time used to process one frame (with all input handling, drawing, etc)
528   the time is mesured in ms and passed to all world-entities and other classes that need
529   a heart-beat.
[2636]530*/
[3551]531void World::tick ()
[2636]532{
533  Uint32 currentFrame = SDL_GetTicks();
534  if(!this->bPause)
535    {
[3644]536      this->dt = currentFrame - this->lastFrame;
[4555]537
[4610]538      if( this->dt > 10)
[4555]539        {
540          float fps = 1000/dt;
[3790]541
[4555]542          // temporary, only for showing how fast the text-engine is
543          char tmpChar[20];
544          sprintf(tmpChar, "fps: %4.0f", fps);
545        }
[2636]546      else
[4555]547        {
548          /* the frame-rate is limited to 100 frames per second, all other things are for
549             nothing.
550          */
[5048]551          PRINTF(3)("fps = 1000 - frame rate is adjusted\n");
[4610]552          SDL_Delay(10-dt);
[4555]553          this->dt = 10;
554        }
555
[5205]556      this->dtS = (float)this->dt / 1000.0 * this->speed;
[4145]557      this->gameTime += this->dtS;
[4833]558
[6155]559      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
[6142]560      this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
[6155]561      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);
[6142]562      this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
563      this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
[4010]564
[3459]565      /* update tick the rest */
[4832]566      this->localCamera->tick(this->dtS);
[4558]567      // tick the engines
[4245]568      AnimationPlayer::getInstance()->tick(this->dtS);
[4979]569//      if (this->cycle > 5)
[4558]570        PhysicsEngine::getInstance()->tick(this->dtS);
[4396]571
[4558]572      ParticleEngine::getInstance()->tick(this->dtS);
[4396]573
[4831]574
[4558]575      /** actualy the Graphics Engine should tick the world not the other way around...
[4555]576         but since we like the things not too complicated we got it this way around
577         until there is need or time to do it the other way around.
[4836]578         @todo: GraphicsEngine ticks world: separation of processes and data...
[4681]579
580        bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,
581         beceause graphics have nothing(or at least not much) to do with Motion.
[4245]582      */
583      GraphicsEngine::getInstance()->tick(this->dtS);
[2636]584    }
585  this->lastFrame = currentFrame;
586}
587
[3216]588
[2636]589/**
[4836]590 *  this function gives the world a consistant state
[3551]591
592   after ticking (updating the world state) this will give a constistant
593   state to the whole system.
594*/
595void World::update()
596{
[5406]597  GraphicsEngine::getInstance()->update(this->dtS);
[6074]598  PNode::getNullParent()->updateNode (this->dtS);
[4504]599  SoundEngine::getInstance()->update();
[4978]600  //music->update();
[3551]601}
602
603
[4917]604void World::collide()
605{
[6142]606  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),
607                                            this->objectManager.getObjectList(OM_GROUP_01_PROJ));
608  CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),
609                                            this->objectManager.getObjectList(OM_COMMON));
[4917]610}
611
[3551]612/**
[4836]613 *  render the current frame
[4555]614
[3225]615   clear all buffers and draw the world
[2636]616*/
617void World::display ()
618{
619  // clear buffer
620  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
621  // set camera
622  this->localCamera->apply ();
623  // draw world
624  this->draw();
625  // draw HUD
[4837]626  /** @todo draw HUD */
[2636]627  // flip buffers
[4681]628  GraphicsEngine::swapBuffers();
[3365]629  //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();
630  //SDL_Flip (screen);
[2636]631}
632
[2644]633
[3225]634/**
[4917]635 *  runs through all entities calling their draw() methods
636 */
637void World::draw ()
638{
[6142]639  GraphicsEngine* engine = GraphicsEngine::getInstance();
640  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
641  engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));
642  engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));
643  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));
644  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));
645  engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
[4917]646
[6142]647//   {
648//     if( entity->isVisible() ) entity->draw();
649  //FIXME
650//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
651//     entity = iterator->nextElement();
652//   }
653
[4917]654  ParticleEngine::getInstance()->draw();
655
[5389]656  if (unlikely(this->showPNodes))
[6074]657    PNode::getNullParent()->debugDraw(0);
[5389]658
[6142]659  engine->draw();
[4917]660  //TextEngine::getInstance()->draw();
661}
662
[2816]663
[3225]664/**
[6150]665 * \brief main loop of the world: executing all world relevant function
666 *
667 * in this loop we synchronize (if networked), handle input events, give the heart-beat to
668 * all other member-entities of the world (tick to player, enemies etc.), checking for
669 * collisions drawing everything to the screen.
670 */
671void World::mainLoop()
[2816]672{
[6150]673  this->lastFrame = SDL_GetTicks ();
674  PRINTF(3)("World::mainLoop() - Entering main loop\n");
[3529]675
[6151]676  while(!this->bQuitWorld) /* @todo implement pause */
[6150]677  {
678    ++this->cycle;
679      // Network
680    this->synchronize ();
681      // Process input
682    this->handleInput ();
[6151]683    if( this->bQuitWorld)
[6150]684      break;
685      // Process time
686    this->tick ();
687      // Process collision
688    this->collide ();
689      // Update the state
690    this->update ();
691      // Draw
692    this->display ();
693  }
[3365]694
[6150]695  PRINTF(3)("World::mainLoop() - Exiting the main loop\n");
[2644]696}
[2816]697
698
[6150]699
[3521]700/**
[4836]701 *  add and spawn a new entity to this world
702 * @param entity to be added
[3521]703*/
[6150]704void World::spawn(WorldEntity* entity)
[3521]705{
[6150]706//   this->entities->add (entity);
707  entity->postSpawn ();
[3521]708}
709
[4010]710void World::setPath( const char* name)
711{
[4094]712  if (this->path)
713    delete this->path;
714  if (ResourceManager::isFile(name))
715  {
716    this->path = new char[strlen(name)+1];
717    strcpy(this->path, name);
718  }
719  else
720    {
721      this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];
722      sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
723    }
[4010]724}
725
726const char* World::getPath( void)
727{
728  return path;
729}
Note: See TracBrowser for help on using the repository browser.