For this example we'll mainly be editing the files for our HUD
, Cycle
, MachineGun
, and Cannon
classes.
Open
GunClasses_03.py
. First, we have a few small edits to make here.We need labels for the guns to show which HUD elements relate to which gun. Add this line to the
__init__
method of theMachineGun
class, right under the line that saysself.cycle = cycle
:self.name = "JR Martin J59 Jabber"
Add this line to the same place in the
Cannon
class:self.name = "Virtue X-A9 Equalizer"
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 saysself.damage = 10
:self.energyCost = 1.25
Add the following line in the same place in the
Cannon
class:self.energyCost = 5
To actually deduct the energy costs from the cycle's total when the gun is fired, we need to add this line to the
fire()
method in both the classes, right beneath the line that startsfireSeq
:self...