-
Notifications
You must be signed in to change notification settings - Fork 1
/
statusmodifiers.py
68 lines (50 loc) · 1.83 KB
/
statusmodifiers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from trajectorymovingobject import TrajectoryMovingObject
from constants import SCREENW, SCREENH, STATMOD_DURATION, PLAYERSPEED, PLAYERMAXSPEED, STATMOD_SPEED
from timer import Timer
import random
# todo: handling of timers with acquisition of multiple power ups in player and gamemap
# is a bit out of whack
# If you receive multiple power ups, the status will be reset at the end of the timer of
# the first power up received
# power ups and downs, to be inherited from
class StatusModifier(TrajectoryMovingObject):
def __init__(self, img):
TrajectoryMovingObject.__init__(self, random.randrange(0, SCREENW), -1 * img.get_height(), STATMOD_SPEED, img)
def payload(self, target):
self.notify("remove")
def update(self):
super().update()
if self.y > SCREENH:
self.notify("remove")
class TimeableStatmod(StatusModifier):
def __init__(self, img):
super().__init__(img)
self.timer = Timer(self)
def payload(self, target):
self.timer.startwatch(STATMOD_DURATION)
super().payload(target)
# +1 life
class OneUp(StatusModifier):
def payload(self, target):
# add some sort of happy animation
target.oneup()
super().payload(target)
# bomb booby trap, -1 life
class Bomb(StatusModifier):
def payload(self, target):
target.die() # initiate explosion
super().payload(target)
# double background and ship speed
class SpeedUp(TimeableStatmod):
def payload(self, target):
target.speed = PLAYERMAXSPEED
super().payload(target)
def reverse(self, target):
target.speed = PLAYERSPEED
# shoot from 3 locations
class MoreGuns(TimeableStatmod):
def payload(self, target):
target.bamfmode = True
super().payload(target)
def reverse(self, target):
target.bamfmode = False