O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - using delta time

We're going to employ delta time to make our cycle move at a constant speed instead of a speed based on frame rate. Once we have that done, we'll learn how to use delta time to protect against hiccups in the game— moments when the time between frames is abnormally large, and could cause the action to skip forward.

  1. We need to make two changes to use delta time for our cycle's movement. This first is to add this line at the beginning of our cycleMove method:
    dt = globalClock.getDt()
    
  2. This will create a temporary variable and fill it with the delta time from globalClock in one go. The delta time we get will be in full seconds, so if we want our cycle to move at 10 units per second, we need to change our call to setY ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required