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 - adding a new HUD section

For this example we'll mainly be editing the files for our HUD, Cycle, MachineGun, and Cannon classes.

  1. Open GunClasses_03.py. First, we have a few small edits to make here.
  2. We need labels for the guns to show which HUD elements relate to which gun. Add this line to the __init__ method of the MachineGun class, right under the line that says self.cycle = cycle:
    self.name = "JR Martin J59 Jabber"
    
  3. Add this line to the same place in the Cannon class:
    self.name = "Virtue X-A9 Equalizer"
    
  4. Each gun needs to have an energy cost associated with it, so add the following line to the MachineGun class, right beneath the line that says self.damage = 10:
    self.energyCost = 1.25
    
  5. Add the following line in the same place in the ...

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