PSE Game Physics - Summer 11 - FAQs

From Sccswiki
Jump to navigation Jump to search

Questions to Worksheet 1

  • Q: How can I get the number of seconds elapsed during the last frame?
  • A: This value is stored in 'frame_elapsed_time'
  • Q: The integration method is called by no method.
  • A: Calling this method at an appropriate point is one of your tasks to get familiar with the engine.
  • Q: How can i change the position of an iPhysicsObject
  • A: You can use the translate() method of the object.
  • Q: With activated desktop effects, the window content isn't updated as fast as the displayed FPS and by far less than 50 FPS. What's the problem?
  • A: There seems to be an window-title-update problem with the newest Ubuntu version when the window title is set to a new string frequently during one second.
    To solve this problem, avoid updating the window title. Replace the corresponding lines in file 'main.cpp' with this code to render the desired information just on-screen:


* update window title

title_text << " Scene: '" << cScenes->scene_description << "'";

title_text << " FPS: '" << engine.time.fps << "'";


engine.text.printfxy((float)20, (float)engine.window.height-20, title_text.str().c_str());

Questions to Worksheet 2

  • Q: How can I get the plane factory data?
  • A: You have to cast the generic objectFactory pointer to the primitive specific one.
    cObjectFactorySphere &sphereFactory = *((cObjectFactorySphere*)sphere_object.objectFactory->original_factory_ptr);
    Since objectFactory is of type iBase, you can also use the following static_cast:
    cObjectFactorySphere &sphere_factory = static_cast<cObjectFactorySphere &>(sphere_object.objectFactory.getClass());