Changeset 7919 in orxonox.OLD for trunk/src/story_entities
- Timestamp:
- May 28, 2006, 3:48:13 PM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world.cc
r7871 r7919 25 25 26 26 #include "util/loading/game_loader.h" 27 #include "util/timer.h" 27 28 28 29 #include "player.h" … … 259 260 this->cycle = 0; 260 261 for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++) 261 this->frameTimes[i] = 100;262 this->frameTimes[i] = 0.01f; 262 263 this->dtS = 0.0f; 263 this->lastFrame = SDL_GetTicks();264 this->lastFrame = Timer::getNow(); 264 265 265 266 if (this->dataTank->music != NULL) … … 356 357 void GameWorld::tick () 357 358 { 358 Uint32 currentFrame = SDL_GetTicks();359 360 359 if( !this->bPaused) 361 360 { 362 361 // CALCULATE FRAMERATE 363 362 Uint32 frameTimesIndex; 364 Uint32 getTicks;365 363 Uint32 i; 364 double currentFrame = Timer::getNow(); 366 365 367 366 frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE; 368 getTicks = SDL_GetTicks(); 369 this->frameTimes[frameTimesIndex] = getTicks - this->lastFrame; 370 this->lastFrame = getTicks; 367 this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame; 368 this->lastFrame = currentFrame; 371 369 ++this->cycle; 372 this->dtS = 0 ;370 this->dtS = 0.0; 373 371 for (i = 0; i < TICK_SMOOTH_VALUE; i++) 374 372 this->dtS += this->frameTimes[i]; 375 this->dtS = this->dtS / TICK_SMOOTH_VALUE / 1000.0f* speed;373 this->dtS = this->dtS / TICK_SMOOTH_VALUE * speed; 376 374 377 375 // TICK everything … … 390 388 this->dataTank->gameRule->tick(this->dtS); 391 389 } 392 this->lastFrame = currentFrame;393 390 } 394 391 … … 526 523 GraphicsEngine* engine = GraphicsEngine::getInstance(); 527 524 525 528 526 AtmosphericEngine::getInstance()->draw(); 527 528 //glEnable(GL_DEPTH_TEST); 529 //glEnable(GL_LIGHTING); 529 530 530 531 // set camera -
trunk/src/story_entities/game_world.h
r7785 r7919 93 93 94 94 /* world timing */ 95 Uint32lastFrame; //!< last time of frame (in MiliSeconds)95 double lastFrame; //!< last time of frame (in MiliSeconds) 96 96 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 97 97 float dtS; //!< The time needed for caluculations in seconds 98 98 float speed; //!< how fast the game flows 99 99 double gameTime; //!< this is where the game time is saved 100 Uint32frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.100 double frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. 101 101 102 102 GameRules* gameRules; //!< Pointer to the data structure containig the game rules -
trunk/src/story_entities/movie_loader.cc
r7868 r7919 115 115 GraphicsEngine::enter2DMode(); 116 116 117 glPushAttrib(GL_ENABLE_BIT); 117 118 glEnable(GL_TEXTURE_2D); 118 119 glBindTexture(GL_TEXTURE_2D, movie_player->getTexture()); … … 127 128 glEnd(); 128 129 130 glPopAttrib(); 129 131 GraphicsEngine::leave2DMode(); 130 132 -
trunk/src/story_entities/simple_game_menu.cc
r7868 r7919 28 28 #include "util/loading/factory.h" 29 29 30 #include "p_node.h"31 30 #include "world_entity.h" 32 31 #include "elements/image_entity.h" … … 41 40 #include "cd_engine.h" 42 41 43 44 using namespace std; 45 42 #include "glgui.h" 46 43 47 44 //! This creates a Factory to fabricate a SimpleGameMenu … … 51 48 52 49 SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) 53 : GameWorld()50 : GameWorld() 54 51 { 55 52 this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); … … 66 63 this->selectorSource = NULL; 67 64 65 66 /// GUI 67 ///(this is as modular as it is possible). 68 OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME"); 69 pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui)); 70 pb->show(); 71 pb->setAbsCoor2D(50, 50); 72 73 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 74 OrxGui::GLGuiHandler::getInstance()->activate(); 75 ///// 76 68 77 if (root != NULL) 69 78 this->loadParams(root); … … 72 81 } 73 82 74 75 /** 76 * @brief remove the SimpleGameMenu from memory 77 * 78 * delete everything explicitly, that isn't contained in the parenting tree! 79 * things contained in the tree are deleted automaticaly 80 */ 83 /// HACK only for testing. 84 void SimpleGameMenu::enterGui() 85 { 86 /// 87 OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button"); 88 dnpb->show(); 89 dnpb->setAbsCoor2D(350, 50); 90 dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL)); 91 92 OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!"); 93 rdnpb->show(); 94 rdnpb->setAbsCoor2D(200, 180); 95 rdnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::quitMenu)); 96 97 OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine(); 98 input->setText("input some text here"); 99 input->show(); 100 input->setAbsCoor2D(200, 230); 101 102 103 ///// 104 } 105 106 107 #include "threading.h" 108 void SimpleGameMenu::execURL() const 109 { 110 std::string URL = "http://www.orxonox.net"; 111 SDL_CreateThread(startURL, (void*)&URL); 112 } 113 114 #ifdef __OSX__ 115 #include <ApplicationServices/ApplicationServices.h> 116 #elif defined __WIN32__ 117 #include <shellapi.h> 118 #endif 119 120 int SimpleGameMenu::startURL(void* url) 121 { 122 std::string URL = *(std::string*)url; 123 #ifdef __linux__ 124 system ((std::string("firefox ") + URL).c_str()); 125 #elif defined __OSX__ 126 CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(), 127 kCFStringEncodingASCII, NULL); 128 LSOpenCFURLRef (url_handle, NULL); 129 CFRelease (url_handle); 130 #elif defined __WIN32__ 131 ShellExecute(GetActiveWindow(), 132 "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL); 133 } 134 #endif 135 PRINTF(3)("loaded external webpage %s\n", URL.c_str()); 136 } 137 138 /** 139 * @brief remove the SimpleGameMenu from memory 140 * 141 * delete everything explicitly, that isn't contained in the parenting tree! 142 * things contained in the tree are deleted automaticaly 143 */ 81 144 SimpleGameMenu::~SimpleGameMenu () 82 145 { … … 85 148 if( this->dataTank) 86 149 delete this->dataTank; 87 } 88 89 90 /** 91 * @brief loads the parameters of a SimpleGameMenu from an XML-element 92 * @param root the XML-element to load from 93 */ 150 delete OrxGui::GLGuiHandler::getInstance( ); 151 } 152 153 154 /** 155 * @brief loads the parameters of a SimpleGameMenu from an XML-element 156 * @param root the XML-element to load from 157 */ 94 158 void SimpleGameMenu::loadParams(const TiXmlElement* root) 95 159 { … … 103 167 104 168 /** 105 106 107 108 109 169 * @brief this is executed just before load 170 * 171 * since the load function sometimes needs data, that has been initialized 172 * before the load and after the proceeding storyentity has finished 173 */ 110 174 ErrorMessage SimpleGameMenu::init() 111 175 { … … 129 193 130 194 /** 131 132 195 * @brief load the data 196 */ 133 197 ErrorMessage SimpleGameMenu::loadData() 134 198 { … … 149 213 { 150 214 element = element->FirstChildElement(); 151 // load Players/Objects/Whatever215 // load Players/Objects/Whatever 152 216 PRINTF(4)("Loading Elements\n"); 153 217 while( element != NULL) … … 196 260 this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL); 197 261 this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f, 198 262 State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f)); 199 263 this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity)); 200 264 } … … 244 308 245 309 /** 246 247 248 310 * @brief set the Sound to play when switching menu entry. 311 * @param selectorSound the sound to load. 312 */ 249 313 void SimpleGameMenu::setSelectorSound(const std::string& selectorSound) 250 314 { … … 280 344 281 345 /** 282 283 346 * @brief start the menu 347 */ 284 348 bool SimpleGameMenu::start() 285 349 { … … 293 357 294 358 /** 295 296 359 * stop the menu 360 */ 297 361 bool SimpleGameMenu::stop() 298 362 { … … 305 369 306 370 /** 307 308 371 * override the standard tick for more functionality 372 */ 309 373 void SimpleGameMenu::tick() 310 374 { 311 375 GameWorld::tick(); 312 376 377 // Make the GLGui tick. 378 OrxGui::GLGuiHandler::getInstance()->tick(this->dtS); 379 313 380 this->animateScene(this->dtS); 314 381 } … … 316 383 317 384 /** 318 319 385 * @brief no collision detection in the menu 386 */ 320 387 void SimpleGameMenu::collide() 321 388 { 322 // this->dataTank->localCamera->323 } 324 325 326 /** 327 328 389 // this->dataTank->localCamera-> 390 } 391 392 393 /** 394 * @brief animate the scene 395 */ 329 396 void SimpleGameMenu::animateScene(float dt) 330 397 { … … 335 402 } 336 403 337 338 /** 339 * @brief event dispatcher funciton 340 * @param event the incoming event 341 */ 404 void SimpleGameMenu::quitMenu() 405 { 406 this->setNextStoryID(WORLD_ID_GAMEEND); 407 this->stop(); 408 } 409 410 411 /** 412 * @brief event dispatcher funciton 413 * @param event the incoming event 414 */ 342 415 void SimpleGameMenu::process(const Event &event) 343 416 { … … 422 495 423 496 /** 424 425 426 427 497 * @brief switches to from one meny layer to an other 498 * @param layer1 from layer 499 * @param layer2 to layer 500 */ 428 501 void SimpleGameMenu::switchMenuLayer(int layer1, int layer2) 429 502 { … … 485 558 486 559 /********************************************************************************************** 487 488 489 490 491 /** 492 493 560 SimpleGameMenuData 561 **********************************************************************************************/ 562 563 564 /** 565 * SimpleGameMenuData constructor 566 */ 494 567 SimpleGameMenuData::SimpleGameMenuData() 495 568 {} 496 569 497 570 /** 498 499 571 * SimpleGameMenuData decontructor 572 */ 500 573 SimpleGameMenuData::~SimpleGameMenuData() 501 574 {} … … 503 576 504 577 /** 505 506 578 * initialize the GameWorldDataData 579 */ 507 580 ErrorMessage SimpleGameMenuData::init() 508 581 { … … 513 586 514 587 /** 515 516 517 588 * loads the GUI data 589 * @param root reference to the xml root element 590 */ 518 591 ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root) 519 592 { … … 524 597 525 598 /** 526 527 599 * unloads the GUI data 600 */ 528 601 ErrorMessage SimpleGameMenuData::unloadGUI() 529 602 { … … 534 607 535 608 /** 536 537 538 609 * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) 610 * @param root reference to the xml root parameter 611 */ 539 612 ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root) 540 613 { … … 545 618 if( element != NULL) 546 619 { 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 620 element = element->FirstChildElement(); 621 PRINTF(4)("Loading WorldEntities\n"); 622 while(element != NULL) 623 { 624 BaseObject* created = Factory::fabricate(element); 625 if( created != NULL ) 626 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 627 628 if( element->Value() == "SkyBox") 629 this->sky = dynamic_cast<WorldEntity*>(created); 630 if( element->Value() == "Terrain") 631 this->terrain = dynamic_cast<Terrain*>(created); 632 element = element->NextSiblingElement(); 633 } 634 635 PRINTF(4)("Done loading WorldEntities\n"); 563 636 } 564 637 … … 570 643 571 644 /** 572 573 645 * unloads the world entities from the xml file 646 */ 574 647 ErrorMessage SimpleGameMenuData::unloadWorldEntities() 575 648 { … … 580 653 581 654 /** 582 583 584 655 * loads the scene data 656 * @param root reference to the xml root element 657 */ 585 658 ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root) 586 659 { … … 591 664 592 665 /** 593 594 666 * unloads the scene data 667 */ 595 668 ErrorMessage SimpleGameMenuData::unloadScene() 596 669 { -
trunk/src/story_entities/simple_game_menu.h
r7460 r7919 49 49 virtual ~SimpleGameMenu(); 50 50 51 /// TODO TAKE THIS OUT 52 void enterGui(); 53 void execURL() const; 54 static int startURL(void* data); 55 /// 51 56 virtual void loadParams(const TiXmlElement* root); 52 57 … … 60 65 virtual void process(const Event &event); 61 66 67 68 void startLevel(int level); 69 void quitMenu(); 70 71 void TEST() { printf("TEST\n"); } 62 72 63 73 protected:
Note: See TracChangeset
for help on using the changeset viewer.