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 - creating the main cannon

Fortunately, we'll be able to do a good bit of copying and pasting code we've already written to make the main cannon. Let's get started.

  1. Open ExplosionClasses_01.py. The first thing we'll do is to make a new kind of explosion for the main cannon.
  2. Add a new import to the top of the file:
    from pandac.PandaModules import *
    
  3. Copy the entire Pop class and paste it into the bottom of the file. Change the class name to Boom, and use the find and replace feature of Notepad++ to change self.pop into self.boom everywhere it appears in the Boom class.
  4. Change the definition of the __init__ method for the Boom class to look like this:
    def __init__(self, pos, scale, damage):
    
  5. Add the following line to the __init__ method ...

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