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 - defining the Cycle class

This example will mostly involve taking code we've already written and moving it to a new file. Be sure to follow along carefully so we don't move any code we don't want to move.

  1. First, create a blank file in Notepad++ and save it as CycleClass_01.py.
  2. Add the following two lines to the new file:
    class Cycle(DirectObject):
    def __init__(self):
    
  3. Next, cut the following lines that declare the speed, acceleration, turning, and other cycle variables from WorldClass_01.py, and paste them into the __init__ method of the Cycle class.
    self.speed = 0
    self.throttle = 0
    self.maxSpeed = 200
    self.accel = 25
    self.handling = 20
    
  4. Do the same to these lines, which load the cycle model, and reparent and reposition it. They also ...

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