Changeset 6402 in orxonox.OLD for branches/network/src/story_entities
- Timestamp:
- Jan 3, 2006, 11:04:50 PM (19 years ago)
- Location:
- branches/network/src/story_entities
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/campaign.cc
r6389 r6402 21 21 #include "load_param.h" 22 22 23 #include "campaign_data.h" 23 24 24 25 using namespace std; … … 63 64 64 65 PRINTF(4)("Loaded Campaign specific stuff\n"); 65 66 66 } 67 67 … … 147 147 148 148 149 150 /* ==========================================================================================================151 CampaignData152 ==========================================================================================================153 */154 155 /**156 * constructor for CampaignData157 */158 CampaignData::CampaignData(const TiXmlElement* root)159 {160 this->setClassID(CL_CAMPAIGN_DATA, "CampaignData");161 this->currentEntity = NULL;162 163 this->loadParams(root);164 }165 166 167 /**168 * destructor for CampaignData169 */170 CampaignData::~CampaignData()171 {172 PRINTF(0)("Deleting CampaignData\n");173 while( !this->storyEntities.empty())174 {175 StoryEntity* bo = this->storyEntities.back();176 this->storyEntities.pop_back();177 PRINTF(0)("CampaignData is been deleted: nr %i\n", bo->getStoryID());178 delete bo;179 }180 }181 182 183 184 /**185 * loads the Parameters of a Campaign186 * @param root: The XML-element to load from187 */188 void CampaignData::loadParams(const TiXmlElement* root)189 {190 LoadParamXML(root, "WorldList", this, CampaignData, loadParamsWorldList)191 .describe("A List of Worlds to be loaded in this Campaign");192 193 }194 195 196 /**197 * loads a WorldList198 * @param root: the XML-element to load from199 */200 void CampaignData::loadParamsWorldList(const TiXmlElement* root)201 {202 if( root == NULL)203 return;204 205 LOAD_PARAM_START_CYCLE(root, element);206 {207 StoryEntity* created = (StoryEntity*) Factory::fabricate(element);208 if( created != NULL)209 this->addStoryEntity(created);210 }211 LOAD_PARAM_END_CYCLE(element);212 }213 214 215 /**216 * add the StoryEntity to the campaign data tank217 * @param se the StoryEntity to add218 */219 void CampaignData::addStoryEntity(StoryEntity* se)220 {221 this->storyEntities.push_back(se);222 }223 224 225 /**226 * switch to the next level in the list and return it227 */228 StoryEntity* CampaignData::getFirstLevel()229 {230 int nextStoryID;231 int storyID;232 list<StoryEntity*>::iterator it;233 234 nextStoryID = 0;235 this->currentEntity = NULL;236 for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)237 {238 storyID = (*it)->getStoryID();239 if( storyID == nextStoryID)240 this->currentEntity = (*it);241 }242 return this->currentEntity;243 }244 245 246 /**247 * switch to the next level in the list and return it248 */249 StoryEntity* CampaignData::getNextLevel()250 {251 int nextStoryID;252 int storyID;253 list<StoryEntity*>::iterator it;254 255 nextStoryID = this->currentEntity->getNextStoryID();256 this->currentEntity = NULL;257 for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)258 {259 storyID = (*it)->getStoryID();260 if( storyID == nextStoryID)261 this->currentEntity = (*it);262 }263 return this->currentEntity;264 }265 266 267 268 269 -
branches/network/src/story_entities/campaign.h
r6387 r6402 9 9 10 10 #include "story_entity.h" 11 #include <list>12 11 13 12 … … 40 39 }; 41 40 42 43 44 //! A class that contains the data of the Campaign object45 class CampaignData : public BaseObject46 {47 48 public:49 CampaignData(const TiXmlElement* root);50 virtual ~CampaignData();51 52 void loadParams(const TiXmlElement* root);53 54 void addStoryEntity(StoryEntity* se);55 56 StoryEntity* getFirstLevel();57 StoryEntity* getNextLevel();58 59 60 private:61 void loadParamsWorldList(const TiXmlElement* root);62 63 64 private:65 StoryEntity* currentEntity; //!< reference to the currently used StoryEntity66 std::list<StoryEntity*> storyEntities; //!< list of story entities67 };68 69 41 #endif /* _CAMPAIGN_H */ -
branches/network/src/story_entities/game_world.cc
r6387 r6402 18 18 19 19 #include "game_world.h" 20 #include "game_world_data.h" 20 21 21 22 #include "shell_command.h" … … 82 83 83 84 GameWorld::GameWorld(const TiXmlElement* root) 84 : StoryEntity()85 : StoryEntity() 85 86 { 86 87 this->setClassID(CL_GAME_WORLD, "GameWorld"); … … 89 90 this->gameTime = 0.0f; 90 91 this->setSpeed(1.0f); 91 this->music = NULL;92 92 this->shell = NULL; 93 93 … … 110 110 if( this->gameWorldData) 111 111 delete this->gameWorldData; 112 113 PRINTF(0)("Deleted GameWorld\n"); 112 114 } 113 115 … … 123 125 124 126 LoadParam(root, "path", this, GameWorld, setPath) 125 127 .describe("The Filename of this GameWorld (relative from the data-dir)"); 126 128 127 129 PRINTF(4)("Loaded GameWorld specific stuff\n"); … … 137 139 ErrorMessage GameWorld::init() 138 140 { 139 State::setObjectManager(&this->objectManager);140 141 this->cycle = 0; 141 142 142 /* init the world interface */ 143 143 this->shell = new Shell(); 144 144 145 LightManager::getInstance(); 146 PNode::getNullParent(); 147 148 AnimationPlayer::getInstance(); // initializes the animationPlayer 149 ParticleEngine::getInstance(); 150 PhysicsEngine::getInstance(); 151 152 this->gameWorldData->localCamera = new Camera(); 153 this->gameWorldData->localCamera->setName ("GameWorld-Camera"); 154 155 State::setCamera(this->gameWorldData->localCamera, this->gameWorldData->localCamera->getTarget()); 156 157 GraphicsEngine::getInstance()->displayFPS(true); 145 this->gameWorldData->init(); 158 146 } 159 147 … … 171 159 172 160 if( getPath() == NULL) 173 174 175 176 161 { 162 PRINTF(1)("GameWorld has no path specified for loading"); 163 return (ErrorMessage){213,"Path not specified","GameWorld::load()"}; 164 } 177 165 178 166 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 179 // load the campaign document167 // load the xml world file for further loading 180 168 if( !XMLDoc->LoadFile()) 181 169 { 182 // report an error183 170 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 184 171 delete XMLDoc; 185 172 return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"}; 186 173 } 187 188 174 // check basic validity 189 175 TiXmlElement* root = XMLDoc->RootElement(); 190 176 assert( root != NULL); 191 192 177 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 193 { 194 // report an error 195 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 196 delete XMLDoc; 197 return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"}; 198 } 199 200 // load the parameters 201 // name 202 const char* string = grabParameter( root, "name"); 203 if( string == NULL) 204 { 205 PRINTF(2)("GameWorld is missing a proper 'name'\n"); 206 this->setName("Unknown"); 207 } 208 else 209 { 210 this->setName(string); 211 } 212 213 214 215 this->gameWorldData->loadGUI(root); 216 217 218 this->gameWorldData->loadWorldEntities(root); 219 220 ////////////////////////////// 221 // LOADING ADDITIONAL STUFF // 222 ////////////////////////////// 223 224 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); 225 226 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 227 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 228 229 // free the XML data 178 { 179 // report an error 180 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 181 delete XMLDoc; 182 return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"}; 183 } 184 /* the whole loading process for the GameWorld */ 185 this->gameWorldData->loadData(root); 230 186 231 187 delete XMLDoc; 232 /* GENERIC LOADING PROCESS FINISHED */233 234 235 236 237 238 // //localCamera->setParent(TrackNode::getInstance());239 // tn->addChild(this->localCamera);240 this->gameWorldData->localCamera->setClipRegion(1, 10000.0);241 // localCamera->lookAt(playable);242 // this->localPlayer->setParentMode(PNODE_ALL);243 if (this->gameWorldData->sky != NULL)244 {245 this->gameWorldData->localCamera->addChild(this->gameWorldData->sky);246 }247 SoundEngine::getInstance()->setListener(this->gameWorldData->localCamera);248 249 /* some static stuff*/250 251 this->music = NULL;252 //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);253 //music->playback();254 255 /* update the object position before game start - so there are no wrong coordinates used in the first processing */256 PNode::getNullParent()->updateNode (0.001f);257 PNode::getNullParent()->updateNode (0.001f);258 259 188 this->releaseLoadScreen(); 260 189 } … … 269 198 PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n"); 270 199 271 // delete all the initialized Engines. 272 FastFactory::flushAll(true); 273 delete LightManager::getInstance(); 274 delete ParticleEngine::getInstance(); 275 delete AnimationPlayer::getInstance(); 276 delete PhysicsEngine::getInstance(); 277 278 // external engines initialized by the orxonox-class get deleted 279 SoundEngine::getInstance()->flushAllBuffers(); 280 SoundEngine::getInstance()->flushAllSources(); 281 282 if (State::getObjectManager() == &this->objectManager) 283 State::setObjectManager(NULL); 284 // erease everything that is left. 285 delete PNode::getNullParent(); 286 287 //secondary cleanup of PNodes; 288 const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE); 289 if (nodeList != NULL) 290 while (!nodeList->empty()) 291 delete nodeList->front(); 292 293 Shader::suspendShader(); 294 295 // unload the resources !! 296 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 200 this->gameWorldData->unloadData(); 297 201 } 298 202 … … 309 213 } 310 214 215 311 216 /** 312 217 * stops the world. 313 314 This happens, when the player decides to end the Level. 315 */ 218 */ 316 219 bool GameWorld::stop() 317 220 { … … 320 223 } 321 224 322 /** 323 * pauses the Game 324 */ 225 226 /** 227 * pauses the game 228 */ 325 229 bool GameWorld::pause() 326 230 { 327 231 this->isPaused = true; 328 232 } 233 329 234 330 235 /** … … 338 243 339 244 /** 340 * shows the loading screen 341 */ 342 void GameWorld::displayLoadScreen () 343 { 344 PRINTF(3)("GameWorld::displayLoadScreen - start\n"); 345 this->gameWorldData->glmis = new GLMenuImageScreen(); 346 this->gameWorldData->glmis->setMaximum(8); 347 PRINTF(3)("GameWorld::displayLoadScreen - end\n"); 348 } 349 350 351 /** 352 * @brief removes the loadscreen, and changes over to the game 353 * 354 * @todo take out the delay 355 */ 356 void GameWorld::releaseLoadScreen () 357 { 358 PRINTF(3)("GameWorld::releaseLoadScreen - start\n"); 359 this->gameWorldData->glmis->setValue(this->gameWorldData->glmis->getMaximum()); 360 PRINTF(3)("GameWorld::releaseLoadScreen - end\n"); 361 delete this->gameWorldData->glmis; 245 * main loop of the world: executing all world relevant function 246 * 247 * in this loop we synchronize (if networked), handle input events, give the heart-beat to 248 * all other member-entities of the world (tick to player, enemies etc.), checking for 249 * collisions drawing everything to the screen. 250 */ 251 void GameWorld::run() 252 { 253 this->lastFrame = SDL_GetTicks (); 254 PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n"); 255 256 while( this->isRunning) /* @todo implement pause */ 257 { 258 ++this->cycle; 259 /* process intput */ 260 this->handleInput (); 261 if( !this->isRunning) 262 break; 263 264 /* network synchronisation */ 265 this->synchronize (); 266 /* process time */ 267 this->tick (); 268 /* process collision */ 269 this->collide (); 270 /* update the state */ 271 this->update (); 272 /* draw everything */ 273 this->display (); 274 } 275 276 PRINTF(3)("GameWorld::mainLoop() - Exiting the main loop\n"); 362 277 } 363 278 … … 367 282 */ 368 283 void GameWorld::synchronize () 369 { 370 // Get remote input 371 // Update synchronizables 372 /* NetworkManager::getInstance()->synchronize();*/ 373 } 284 {} 374 285 375 286 … … 383 294 { 384 295 EventHandler::getInstance()->process(); 385 386 // remoteinput 387 } 388 296 } 297 298 299 /** 300 * ticks a WorldEntity list 301 * @param entityList list of the WorldEntities 302 * @param dt time passed since last frame 303 */ 389 304 void GameWorld::tick(std::list<WorldEntity*> entityList, float dt) 390 305 { … … 397 312 /** 398 313 * advance the timeline 399 400 401 402 403 */314 * 315 * this calculates the time used to process one frame (with all input handling, drawing, etc) 316 * the time is mesured in ms and passed to all world-entities and other classes that need 317 * a heart-beat. 318 */ 404 319 void GameWorld::tick () 405 320 { 406 321 Uint32 currentFrame = SDL_GetTicks(); 322 407 323 if( !this->isPaused) 324 { 325 this->dt = currentFrame - this->lastFrame; 326 327 /* limit the the frame rate to 100 frames per second (fps) */ 328 if( this->dt < 10) 408 329 { 409 this->dt = currentFrame - this->lastFrame; 410 411 if( this->dt > 10) 412 { 413 float fps = 1000/dt; 414 415 // temporary, only for showing how fast the text-engine is 416 char tmpChar[20]; 417 sprintf(tmpChar, "fps: %4.0f", fps); 418 } 419 else 420 { 421 /* the frame-rate is limited to 100 frames per second, all other things are for 422 nothing. 423 */ 424 PRINTF(3)("fps = 1000 - frame rate is adjusted\n"); 425 SDL_Delay(10-dt); 426 this->dt = 10; 427 } 428 429 this->dtS = (float)this->dt / 1000.0 * this->speed; 430 this->gameTime += this->dtS; 431 432 this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 433 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 434 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS); 435 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 436 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 437 438 /* update tick the rest */ 439 this->gameWorldData->localCamera->tick(this->dtS); 440 // tick the engines 441 AnimationPlayer::getInstance()->tick(this->dtS); 442 // if (this->cycle > 5) 443 PhysicsEngine::getInstance()->tick(this->dtS); 444 445 ParticleEngine::getInstance()->tick(this->dtS); 446 447 448 /** actualy the Graphics Engine should tick the world not the other way around... 449 but since we like the things not too complicated we got it this way around 450 until there is need or time to do it the other way around. 451 @todo: GraphicsEngine ticks world: separation of processes and data... 452 453 bensch: in my opinion the GraphicsEngine could draw the world, but not tick it, 454 beceause graphics have nothing(or at least not much) to do with Motion. 455 */ 456 GraphicsEngine::getInstance()->tick(this->dtS); 330 /* the frame-rate is limited to 100 frames per second, all other things are for nothing. */ 331 PRINTF(0)("fps = 1000 - frame rate is adjusted\n"); 332 SDL_Delay(10 - dt); 333 this->dt = 10; 457 334 } 335 336 this->dtS = (float)this->dt / 1000.0f * this->speed; 337 this->gameTime += this->dtS; 338 339 this->tick(this->gameWorldData->objectManager->getObjectList(OM_DEAD_TICK), this->dtS); 340 this->tick(this->gameWorldData->objectManager->getObjectList(OM_COMMON), this->dtS); 341 this->tick(this->gameWorldData->objectManager->getObjectList(OM_GROUP_00), this->dtS); 342 this->tick(this->gameWorldData->objectManager->getObjectList(OM_GROUP_01), this->dtS); 343 this->tick(this->gameWorldData->objectManager->getObjectList(OM_GROUP_01_PROJ), this->dtS); 344 345 /* update tick the rest */ 346 this->gameWorldData->localCamera->tick(this->dtS); 347 AnimationPlayer::getInstance()->tick(this->dtS); 348 ParticleEngine::getInstance()->tick(this->dtS); 349 PhysicsEngine::getInstance()->tick(this->dtS); 350 351 GraphicsEngine::getInstance()->tick(this->dtS); 352 } 458 353 this->lastFrame = currentFrame; 459 354 } … … 462 357 /** 463 358 * this function gives the world a consistant state 464 465 466 467 */359 * 360 * after ticking (updating the world state) this will give a constistant 361 * state to the whole system. 362 */ 468 363 void GameWorld::update() 469 364 { … … 475 370 476 371 372 /** 373 * kicks the CDEngine to detect the collisions between the object groups in the world 374 */ 477 375 void GameWorld::collide() 478 376 { 479 CDEngine::getInstance()->checkCollisions(this-> objectManager.getObjectList(OM_GROUP_00),480 this->objectManager.getObjectList(OM_GROUP_01_PROJ));481 CDEngine::getInstance()->checkCollisions(this-> objectManager.getObjectList(OM_GROUP_01),482 this->objectManager.getObjectList(OM_COMMON));377 CDEngine::getInstance()->checkCollisions(this->gameWorldData->objectManager->getObjectList(OM_GROUP_00), 378 this->gameWorldData->objectManager->getObjectList(OM_GROUP_01_PROJ)); 379 CDEngine::getInstance()->checkCollisions(this->gameWorldData->objectManager->getObjectList(OM_GROUP_01), 380 this->gameWorldData->objectManager->getObjectList(OM_COMMON)); 483 381 } 484 382 485 383 /** 486 384 * render the current frame 487 488 489 */385 * 386 * clear all buffers and draw the world 387 */ 490 388 void GameWorld::display () 491 389 { … … 496 394 // draw world 497 395 this->draw(); 498 // draw HUD499 /** @todo draw HUD */500 396 // flip buffers 501 397 GraphicsEngine::swapBuffers(); 502 //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();503 //SDL_Flip (screen);504 398 } 505 399 … … 511 405 { 512 406 GraphicsEngine* engine = GraphicsEngine::getInstance(); 407 408 /* to draw the bounding boxes of the objects at level 2 for debug purp */ 409 if( unlikely( this->showBV)) 410 { 411 CDEngine* engine = CDEngine::getInstance(); 412 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 413 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON)); 414 engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON)); 415 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00)); 416 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01)); 417 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 418 } 419 /* debug draw the PNodes */ 420 if( unlikely(this->showPNodes)) 421 PNode::getNullParent()->debugDraw(0); 422 423 /* draw all WorldEntiy groups */ 513 424 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 514 425 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); … … 517 428 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 518 429 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 519 520 if( unlikely( this->showBV)) // to draw the bounding boxes of the objects at level 2 for debug purp 521 { 522 CDEngine* engine = CDEngine::getInstance(); 523 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 524 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON)); 525 engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON)); 526 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00)); 527 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01)); 528 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 529 } 530 531 // { 532 // if( entity->isVisible() ) entity->draw(); 533 //FIXME 534 // entity = iterator->nextElement(); 535 // } 536 430 /* draws the particles */ 537 431 ParticleEngine::getInstance()->draw(); 538 432 539 if (unlikely(this->showPNodes)) 540 PNode::getNullParent()->debugDraw(0); 541 433 /* final draw command */ 542 434 engine->draw(); 543 //TextEngine::getInstance()->draw(); 544 } 545 546 547 /** 548 * \brief main loop of the world: executing all world relevant function 549 * 550 * in this loop we synchronize (if networked), handle input events, give the heart-beat to 551 * all other member-entities of the world (tick to player, enemies etc.), checking for 552 * collisions drawing everything to the screen. 553 */ 554 void GameWorld::run() 555 { 556 this->lastFrame = SDL_GetTicks (); 557 PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n"); 558 559 while( this->isRunning) /* @todo implement pause */ 560 { 561 ++this->cycle; 562 // Network 563 this->synchronize (); 564 // Process input 565 this->handleInput (); 566 if( !this->isRunning) 567 break; 568 // Process time 569 this->tick (); 570 // Process collision 571 this->collide (); 572 // Update the state 573 this->update (); 574 // Draw 575 this->display (); 576 } 577 578 PRINTF(3)("GameWorld::mainLoop() - Exiting the main loop\n"); 579 } 580 581 582 583 /** 584 * add and spawn a new entity to this world 585 * @param entity to be added 586 */ 587 // void GameWorld::spawn(WorldEntity* entity) 588 // { 589 // // this->entities->add (entity); 590 // entity->postSpawn (); 591 // } 435 } 436 592 437 593 438 /** … … 605 450 } 606 451 else 607 { 608 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1]; 609 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name); 610 } 611 } 612 613 614 615 616 617 618 619 GameWorldData::GameWorldData() 620 { 621 this->localPlayer = NULL; 622 this->localCamera = NULL; 623 624 this->glmis = NULL; 625 626 this->localCamera = NULL; 627 this->localPlayer = NULL; 628 this->sky = NULL; 629 this->terrain = NULL; 630 631 } 632 633 634 GameWorldData::~GameWorldData() 635 { 636 if( this->localPlayer) 637 delete this->localPlayer; 638 } 639 640 641 642 ErrorMessage GameWorldData::loadData(TiXmlElement* root) 643 {} 644 645 646 647 648 ErrorMessage GameWorldData::loadGUI(TiXmlElement* root) 649 { 650 //////////////// 651 // LOADSCREEN // 652 //////////////// 653 TiXmlElement* element = root->FirstChildElement("LoadScreen"); 654 if( element == NULL) 655 { 656 PRINTF(2)("no LoadScreen specified, loading default\n"); 657 658 glmis->setBackgroundImage("pictures/load_screen.jpg"); 659 this->glmis->setMaximum(8); 660 this->glmis->draw(); 661 } 662 else 663 { 664 this->glmis->loadParams(element); 665 this->glmis->draw(); 666 } 667 this->glmis->draw(); 668 669 } 670 671 672 ErrorMessage GameWorldData::loadWorldEntities(TiXmlElement* root) 673 { 674 //////////////////////// 675 // find WorldEntities // 676 //////////////////////// 677 678 TiXmlElement* element = root->FirstChildElement("WorldEntities"); 679 680 if( element == NULL) 681 { 682 PRINTF(1)("GameWorld is missing 'WorldEntities'\n"); 683 } 684 else 685 { 686 element = element->FirstChildElement(); 687 // load Players/Objects/Whatever 688 PRINTF(4)("Loading WorldEntities\n"); 689 while( element != NULL) 690 { 691 BaseObject* created = Factory::fabricate(element); 692 if( created != NULL ) 693 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 694 695 696 //todo do this more elegant 697 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 698 this->sky = dynamic_cast<WorldEntity*>(created); 699 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 700 { 701 this->terrain = dynamic_cast<Terrain*>(created); 702 CDEngine::getInstance()->setTerrain(terrain); 703 } 704 element = element->NextSiblingElement(); 705 this->glmis->step(); //! @todo temporary 706 } 707 PRINTF(4)("Done loading WorldEntities\n"); 708 } 709 710 // Create a Player 711 this->localPlayer = new Player(); 712 713 Playable* playable; 714 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 715 if (playableList != NULL) 716 { 717 playable = dynamic_cast<Playable*>(playableList->front()); 718 this->localPlayer->setControllable(playable); 719 } 720 } 721 722 723 ErrorMessage GameWorldData::loadScene(TiXmlElement* root) 724 {} 725 452 { 453 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1]; 454 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name); 455 } 456 } 457 458 459 /** 460 * shows the loading screen 461 */ 462 void GameWorld::displayLoadScreen () 463 { 464 PRINTF(3)("GameWorld::displayLoadScreen - start\n"); 465 this->gameWorldData->glmis = new GLMenuImageScreen(); 466 this->gameWorldData->glmis->setMaximum(8); 467 PRINTF(3)("GameWorld::displayLoadScreen - end\n"); 468 } 469 470 471 /** 472 * removes the loadscreen, and changes over to the game 473 */ 474 void GameWorld::releaseLoadScreen () 475 { 476 PRINTF(3)("GameWorld::releaseLoadScreen - start\n"); 477 this->gameWorldData->glmis->setValue(this->gameWorldData->glmis->getMaximum()); 478 PRINTF(3)("GameWorld::releaseLoadScreen - end\n"); 479 } 480 -
branches/network/src/story_entities/game_world.h
r6387 r6402 7 7 #define _GAME_WORLD_H 8 8 9 #include "sdlincl.h" 9 10 10 #include "story_entity.h" 11 #include "object_manager.h"12 11 12 13 class TiXmlElement; 14 class Shell; 13 15 class WorldEntity; 14 class Camera; 15 class Player; 16 class GLMenuImageScreen; 17 class Terrain; 18 class TiXmlElement; 16 class GameWorldData; 19 17 20 class Shell;21 class OggPlayer;22 class GameWorldData;23 18 24 19 //! The game world … … 86 81 87 82 /* world timing */ 88 Uint32 lastFrame; //!< last time of frame 89 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 90 Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) 91 float dtS; //!< The time needed for caluculations in seconds 92 float speed; //!< how fast the game flows 93 double gameTime; //!< this is where the game time is saved 94 95 /* external modules interfaces */ 96 ObjectManager objectManager; //!< The ObjectManager of this GameWorld. 83 Uint32 lastFrame; //!< last time of frame 84 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 85 Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) 86 float dtS; //!< The time needed for caluculations in seconds 87 float speed; //!< how fast the game flows 88 double gameTime; //!< this is where the game time is saved 97 89 98 90 /* external modules interfaces */ 99 91 Shell* shell; 100 OggPlayer* music;101 102 /* important entities */103 };104 105 106 class GameWorldData : public BaseObject107 {108 109 public:110 GameWorldData();111 ~GameWorldData();112 /* world loading functions */113 virtual ErrorMessage loadData(TiXmlElement* root);114 115 virtual ErrorMessage loadGUI(TiXmlElement* root);116 virtual ErrorMessage loadWorldEntities(TiXmlElement* root);117 virtual ErrorMessage loadScene(TiXmlElement* root);118 119 public:120 GLMenuImageScreen* glmis; //!< The Level-Loader Display121 122 Camera* localCamera; //!< The current Camera123 Player* localPlayer; //!< The Player, you fly through the level.124 WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted125 Terrain* terrain; //!< The Terrain of the GameWorld.126 127 92 }; 128 93 -
branches/network/src/story_entities/multi_player_world.cc
r6387 r6402 51 51 : GameWorld(root) 52 52 { 53 this->constuctorInit("", -1); 53 this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld"); 54 54 55 this->path = NULL; 55 56 … … 83 84 void MultiPlayerWorld::constuctorInit(const char* name, int worldID) 84 85 { 85 this->setClassID(CL_MULTI_PLAYER_WORLD, "MultiPlayerWorld");86 this->setName(name);87 88 86 this->gameTime = 0.0f; 89 87 this->setSpeed(1.0); 90 this->music = NULL;91 88 this->shell = NULL; 92 89 -
branches/network/src/story_entities/single_player_world.cc
r6376 r6402 38 38 : GameWorld(root) 39 39 { 40 this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayer SinglePlayerWorld");40 this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerWorld"); 41 41 this->setName("SinglePlayerWorld uninitialized"); 42 42
Note: See TracChangeset
for help on using the changeset viewer.