Changeset 6358 in orxonox.OLD for branches/network/src/story_entities/game_world.cc
- Timestamp:
- Dec 30, 2005, 10:49:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/game_world.cc
r6352 r6358 17 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD 18 18 19 #include " world.h"19 #include "game_world.h" 20 20 21 21 #include "shell_command.h" … … 70 70 71 71 72 SHELL_COMMAND(speed, World, setSpeed);73 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);74 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);72 SHELL_COMMAND(speed, GameWorld, setSpeed); 73 SHELL_COMMAND(togglePNodeVisibility, GameWorld, togglePNodeVisibility); 74 SHELL_COMMAND(toggleBVVisibility, GameWorld, toggleBVVisibility); 75 75 76 76 using namespace std; 77 77 78 //! This creates a Factory to fabricate a World 79 CREATE_FACTORY(World, CL_WORLD); 80 81 World::World(const TiXmlElement* root) 78 //! This creates a Factory to fabricate a GameWorld 79 CREATE_FACTORY(GameWorld, CL_GAME_WORLD); 80 81 82 83 GameWorld::GameWorld(const TiXmlElement* root) 82 84 { 83 85 this->constuctorInit("", -1); … … 88 90 89 91 /** 90 * remove the World from memory92 * remove the GameWorld from memory 91 93 * 92 94 * delete everything explicitly, that isn't contained in the parenting tree! 93 95 * things contained in the tree are deleted automaticaly 94 96 */ 95 World::~World ()97 GameWorld::~GameWorld () 96 98 { 97 99 delete this->shell; 98 PRINTF(3)(" World::~World() - deleting current world\n");100 PRINTF(3)("GameWorld::~GameWorld() - deleting current world\n"); 99 101 100 102 delete this->localPlayer; … … 129 131 130 132 /** 131 * initializes the world.133 * initializes the world. 132 134 * @param name the name of the world 133 135 * @param worldID the ID of this world … … 139 141 * NO LEVEL LOADING HERE - NEVER! 140 142 */ 141 void World::constuctorInit(const char* name, int worldID)142 { 143 this->setClassID(CL_ WORLD, "World");143 void GameWorld::constuctorInit(const char* name, int worldID) 144 { 145 this->setClassID(CL_GAME_WORLD, "GameWorld"); 144 146 145 147 this->setName(name); … … 156 158 157 159 /** 158 * loads the parameters of a World from an XML-element160 * loads the parameters of a GameWorld from an XML-element 159 161 * @param root the XML-element to load from 160 162 */ 161 void World::loadParams(const TiXmlElement* root)162 { 163 PRINTF(4)("Creating a World\n");164 165 LoadParam(root, "identifier", this, World, setStoryID)163 void GameWorld::loadParams(const TiXmlElement* root) 164 { 165 PRINTF(4)("Creating a GameWorld\n"); 166 167 LoadParam(root, "identifier", this, GameWorld, setStoryID) 166 168 .describe("Sets the StoryID of this world"); 167 169 168 LoadParam(root, "nextid", this, World, setNextStoryID)170 LoadParam(root, "nextid", this, GameWorld, setNextStoryID) 169 171 .describe("Sets the ID of the next world"); 170 172 171 LoadParam(root, "path", this, World, setPath)172 .describe("The Filename of this World (relative from the data-dir)");173 LoadParam(root, "path", this, GameWorld, setPath) 174 .describe("The Filename of this GameWorld (relative from the data-dir)"); 173 175 } 174 176 … … 179 181 * before the load and after the proceeding storyentity has finished 180 182 */ 181 ErrorMessage World::preLoad()183 ErrorMessage GameWorld::preLoad() 182 184 { 183 185 State::setObjectManager(&this->objectManager); … … 195 197 196 198 this->localCamera = new Camera(); 197 this->localCamera->setName (" World-Camera");199 this->localCamera->setName ("GameWorld-Camera"); 198 200 199 201 State::setCamera(this->localCamera, this->localCamera->getTarget()); … … 205 207 206 208 /** 207 * loads the World by initializing all resources, and set their default values.209 * loads the GameWorld by initializing all resources, and set their default values. 208 210 */ 209 ErrorMessage World::load()211 ErrorMessage GameWorld::load() 210 212 { 211 213 PRINTF(3)("> Loading world: '%s'\n", getPath()); … … 215 217 if( getPath() == NULL) 216 218 { 217 PRINTF(1)(" World has no path specified for loading");218 return (ErrorMessage){213,"Path not specified"," World::load()"};219 PRINTF(1)("GameWorld has no path specified for loading"); 220 return (ErrorMessage){213,"Path not specified","GameWorld::load()"}; 219 221 } 220 222 … … 226 228 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 227 229 delete XMLDoc; 228 return (ErrorMessage){213,"XML File parsing error"," World::load()"};230 return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"}; 229 231 } 230 232 … … 238 240 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 239 241 delete XMLDoc; 240 return (ErrorMessage){213,"Path not a WorldDataFile"," World::load()"};242 return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"}; 241 243 } 242 244 … … 246 248 if( string == NULL) 247 249 { 248 PRINTF(2)(" World is missing a proper 'name'\n");250 PRINTF(2)("GameWorld is missing a proper 'name'\n"); 249 251 this->setName("Unknown"); 250 252 } … … 281 283 if( element == NULL) 282 284 { 283 PRINTF(1)(" World is missing 'WorldEntities'\n");285 PRINTF(1)("GameWorld is missing 'WorldEntities'\n"); 284 286 } 285 287 else … … 353 355 SoundEngine::getInstance()->setListener(this->localCamera); 354 356 355 356 357 //////////// 358 // STATIC // 359 //////////// 360 361 362 // TestEntity* testEntity = new TestEntity(); 363 // testEntity->setRelCoor(Vector(570, 10, -15)); 364 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 365 // this->spawn(testEntity); 366 367 for(int i = 0; i < 100; i++) 368 { 369 WorldEntity* tmp = new NPCTest1(); 370 char npcChar[10]; 371 sprintf (npcChar, "NPC_%d", i); 372 tmp->setName(npcChar); 373 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 374 this->spawn(tmp); 375 } 357 /* some static stuff*/ 376 358 377 359 this->music = NULL; … … 380 362 } 381 363 382 ErrorMessage World::postLoad()364 ErrorMessage GameWorld::postLoad() 383 365 { 384 366 this->releaseLoadScreen(); … … 387 369 388 370 /** 389 * initializes a new World shortly before start371 * initializes a new GameWorld shortly before start 390 372 * 391 373 * this is the function, that will be loaded shortly before the world is 392 374 * started 393 375 */ 394 ErrorMessage World::preStart()376 ErrorMessage GameWorld::preStart() 395 377 { 396 378 this->bPause = false; … … 403 385 404 386 /** 405 * starts the World387 * starts the GameWorld 406 388 */ 407 ErrorMessage World::start()389 ErrorMessage GameWorld::start() 408 390 { 409 391 this->bQuitWorld = false; … … 416 398 This happens, when the player decides to end the Level. 417 399 */ 418 ErrorMessage World::stop()419 { 420 PRINTF(3)(" World::stop() - got stop signal\n");400 ErrorMessage GameWorld::stop() 401 { 402 PRINTF(3)("GameWorld::stop() - got stop signal\n"); 421 403 this->bQuitWorld= true; 422 404 } … … 425 407 * pauses the Game 426 408 */ 427 ErrorMessage World::pause()409 ErrorMessage GameWorld::pause() 428 410 { 429 411 this->isPaused = true; … … 433 415 * ends the pause Phase 434 416 */ 435 ErrorMessage World::resume()417 ErrorMessage GameWorld::resume() 436 418 { 437 419 this->isPaused = false; … … 439 421 440 422 /** 441 * destroys the World442 */ 443 ErrorMessage World::destroy()423 * destroys the GameWorld 424 */ 425 ErrorMessage GameWorld::destroy() 444 426 { 445 427 … … 449 431 * shows the loading screen 450 432 */ 451 void World::displayLoadScreen ()452 { 453 PRINTF(3)(" World::displayLoadScreen - start\n");433 void GameWorld::displayLoadScreen () 434 { 435 PRINTF(3)("GameWorld::displayLoadScreen - start\n"); 454 436 455 437 //GLMenuImageScreen* … … 457 439 this->glmis->setMaximum(8); 458 440 459 PRINTF(3)(" World::displayLoadScreen - end\n");441 PRINTF(3)("GameWorld::displayLoadScreen - end\n"); 460 442 } 461 443 … … 465 447 * @todo take out the delay 466 448 */ 467 void World::releaseLoadScreen ()468 { 469 PRINTF(3)(" World::releaseLoadScreen - start\n");449 void GameWorld::releaseLoadScreen () 450 { 451 PRINTF(3)("GameWorld::releaseLoadScreen - start\n"); 470 452 this->glmis->setValue(this->glmis->getMaximum()); 471 PRINTF(3)(" World::releaseLoadScreen - end\n");453 PRINTF(3)("GameWorld::releaseLoadScreen - end\n"); 472 454 delete this->glmis; 473 455 } … … 478 460 * @returns elapsed game time 479 461 */ 480 double World::getGameTime()462 double GameWorld::getGameTime() 481 463 { 482 464 return this->gameTime; … … 488 470 * synchronize local data with remote data 489 471 */ 490 void World::synchronize ()472 void GameWorld::synchronize () 491 473 { 492 474 // Get remote input … … 502 484 sdl and has its own event-passing-queue. 503 485 */ 504 void World::handleInput ()486 void GameWorld::handleInput () 505 487 { 506 488 EventHandler::getInstance()->process(); … … 509 491 } 510 492 511 void World::tick(std::list<WorldEntity*> entityList, float dt)493 void GameWorld::tick(std::list<WorldEntity*> entityList, float dt) 512 494 { 513 495 std::list<WorldEntity*>::iterator entity; … … 524 506 a heart-beat. 525 507 */ 526 void World::tick ()508 void GameWorld::tick () 527 509 { 528 510 Uint32 currentFrame = SDL_GetTicks(); … … 588 570 state to the whole system. 589 571 */ 590 void World::update()572 void GameWorld::update() 591 573 { 592 574 GraphicsEngine::getInstance()->update(this->dtS); … … 597 579 598 580 599 void World::collide()581 void GameWorld::collide() 600 582 { 601 583 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), … … 610 592 clear all buffers and draw the world 611 593 */ 612 void World::display ()594 void GameWorld::display () 613 595 { 614 596 // clear buffer … … 630 612 * runs through all entities calling their draw() methods 631 613 */ 632 void World::draw ()614 void GameWorld::draw () 633 615 { 634 616 GraphicsEngine* engine = GraphicsEngine::getInstance(); … … 674 656 * collisions drawing everything to the screen. 675 657 */ 676 void World::mainLoop()658 void GameWorld::mainLoop() 677 659 { 678 660 this->lastFrame = SDL_GetTicks (); 679 PRINTF(3)(" World::mainLoop() - Entering main loop\n");661 PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n"); 680 662 681 663 while(!this->bQuitWorld) /* @todo implement pause */ … … 698 680 } 699 681 700 PRINTF(3)(" World::mainLoop() - Exiting the main loop\n");682 PRINTF(3)("GameWorld::mainLoop() - Exiting the main loop\n"); 701 683 } 702 684 … … 707 689 * @param entity to be added 708 690 */ 709 void World::spawn(WorldEntity* entity)691 void GameWorld::spawn(WorldEntity* entity) 710 692 { 711 693 // this->entities->add (entity); … … 713 695 } 714 696 715 void World::setPath( const char* name)697 void GameWorld::setPath( const char* name) 716 698 { 717 699 if (this->path) … … 729 711 } 730 712 731 const char* World::getPath( void)713 const char* GameWorld::getPath( void) 732 714 { 733 715 return path;
Note: See TracChangeset
for help on using the changeset viewer.