spaceblaster: Configurable beam damage

Beams need to set the amount of damage they do on collision when the
beams are constructed.
This commit is contained in:
Bryan Schumaker 2011-01-01 16:13:08 -05:00
parent ee9c56b434
commit 9a71af230f
2 changed files with 4 additions and 3 deletions

View File

@ -6,14 +6,15 @@ load = image.load
GO = object.GameObject
class Beam(GO):
def __init__(self, GAME, type, pos, speed):
def __init__(self, GAME, type, pos, speed, damage):
GO.__init__(self, load(GAME, "beam-%s.png" % type), pos, speed)
self.allow_offscreen = True
self.min_y -= self.h
self.damage = damage
def move(self):
self.move_y(1)
class CSEBeam(Beam):
def __init__(self, GAME):
Beam.__init__(self, GAME, "blue", (0,0), (0, -1.4))
Beam.__init__(self, GAME, "blue", (0,0), (0, -1.4), 20)

View File

@ -16,7 +16,7 @@ class ArcadeShip(GO):
def collide(self, beam):
ret = GO.collide(self, beam)
if ret == True:
self.health -= 20
self.health -= beam.damage
return ret
def is_alive(self):