1414#saucerimg = pygame.image.load("saucera.png")
1515#bulletimg = pygame.image.load("bullet.png")
1616
17+ #divide an image into frames
1718def toframes (img , numframes , xstep ):
1819 #img to divide up, number of frames to generate, step size on x axis to split on
1920 frames = [] #list of images
@@ -26,6 +27,7 @@ def toframes(img, numframes, xstep):
2627
2728explosion = toframes (pygame .image .load ("explode.png" ), 5 , 120 )
2829
30+ #all sprites inherit from this class
2931class MoveableObject (pygame .sprite .Sprite ):
3032 def __init__ (self , x , y , img ):
3133 pygame .sprite .Sprite .__init__ (self )
@@ -43,7 +45,7 @@ def updatepos(self): #this lets us play nice with pygame
4345 self .pos = (self .x , self .y )
4446 self .rect .x = self .x
4547 self .rect .y = self .y
46- def explode (self , time ):
48+ def explode (self , time ): #yes, everything can explode
4749 self .timestack .append (time )
4850 self .speed = 0
4951 if (len (self .timestack ) < 2 ):
@@ -115,10 +117,12 @@ def __init__(self, x, y, img, time):
115117 MoveableObject .__init__ (self , x , y , img )
116118 self .health = 2000
117119 self .inittime = time
120+
118121 #state indicator for boss
119122 #0 is still, 1 is aimless moving
120123 #2 is chase ship, 3 is fire at ship
121124 self .mode = 0
125+
122126 #counts number of steps in a given direction
123127 self .step = 0
124128 self .maxstep = 4
@@ -164,6 +168,9 @@ def move(self, foe, time):
164168 elif (test > 0 ):
165169 self .mode = 0
166170 self .alreadygoing = 0
171+
172+ #MODE 3 HAS NOT BEEN IMPLEMENTED
173+
167174
168175 #check for screen boundaries
169176 if (self .y + self .height > foe .y - 60 ):
0 commit comments