Skip to content

Commit 0787509

Browse files
committed
fix of previous commit, added code comments
1 parent dc2b611 commit 0787509

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

killthealiens.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
changeover = 0 #for scroll change over
6565
ychng = 0
6666

67+
#for more precise keyboard input
6768
goright = False
6869
goleft = False
6970

@@ -130,7 +131,7 @@
130131

131132
ship.updatepos()
132133

133-
if(BEASTMODE == 3):
134+
if(BEASTMODE == 3): #if boss is out
134135
if(boss.infirerange(ship) > 0):
135136
if(random.randrange(0,10) == 1):
136137
bullets.append(boss.fire(bulletimg, obj.LEFT))
@@ -196,7 +197,7 @@
196197
deadindex = saucers.index(saucer)
197198
dietest = 1
198199
bullet.explode(time)
199-
#saucers.remove(saucer) #this removes te actual object from the list
200+
#saucers.remove(saucer) #this removes the actual object from the list
200201
score += 5
201202

202203
#this is so that we don't mess up the previous for iteration
@@ -254,9 +255,13 @@
254255
healthlbl = myfont.render("Health: " + str(ship.health), 1, (255,255,0))
255256
scorelbl = myfont.render("Score: " + str(score), 1, (255,255,0))
256257
bosslbl = myfont.render("Boss Health: " + str(boss.health), 1, (255,255,0))
258+
259+
257260
#render images
261+
258262
screen.fill(BLACK)
259263

264+
#for seamless vertical scrolling
260265
if(changeover == 0):
261266
screen.blit(bg, (0,0), (0, 2000-obj.SCREENH-bgoffset, obj.SCREENW, 2000-bgoffset))
262267
elif(changeover == 1):

obj.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#saucerimg = pygame.image.load("saucera.png")
1515
#bulletimg = pygame.image.load("bullet.png")
1616

17+
#divide an image into frames
1718
def 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

2728
explosion = toframes(pygame.image.load("explode.png"), 5, 120)
2829

30+
#all sprites inherit from this class
2931
class 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

Comments
 (0)