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 - implementing acceleration

Our cycle needs to accelerate at a constant rate until it reaches the throttle setting, or decelerate to the throttle, if necessary. This will take two things to make happen, some new variables and two new methods.

  1. To start with, we're going to add some variable declarations at the beginning of our __init__ method. Place this code right below the line where we define the __init__ method.
    self.speed = 0
    self.throttle = 0
    self.maxSpeed = 200
    self.accel = 25
    
  2. We also want to add a new method to our World class. Add this code to the end of the World class, right above the line that sets w = World()
    def speedCheck(self, dt): tSetting = (self.maxSpeed * self.throttle) if(self.speed < tSetting): if((self.speed ...

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