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.
Open
ExplosionClasses_01.py
. The first thing we'll do is to make a new kind of explosion for the main cannon.Add a new import to the top of the file:
from pandac.PandaModules import *
Copy the entire
Pop
class and paste it into the bottom of the file. Change the class name toBoom
, and use the find and replace feature of Notepad++ to changeself.pop
intoself.boom
everywhere it appears in theBoom
class.Change the definition of the
__init__
method for theBoom
class to look like this:def __init__(self, pos, scale, damage):
Add the following line to the
__init__
method of theBoom
class, immediately afterself.boom.setPos(pos)
:self.boom.setScale(scale)
At the bottom of the
Boom
class's__init__
method, add the following block of code:self.boomCN = CollisionNode("BoomCN") self.boomCS = CollisionSphere(0...