Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Added a third power-up level, which unlocks missile-firing.
Browse files Browse the repository at this point in the history
  • Loading branch information
triple-h3lix committed Jan 18, 2016
1 parent a6b86b2 commit f3f5822
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Binary file added assets/missile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sounds/rocket.ogg
Binary file not shown.
35 changes: 34 additions & 1 deletion spaceShooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def shoot(self):
all_sprites.add(bullet)
bullets.add(bullet)
shooting_sound.play()
if self.power >= 2:
if self.power == 2:
bullet1 = Bullet(self.rect.left, self.rect.centery)
bullet2 = Bullet(self.rect.right, self.rect.centery)
all_sprites.add(bullet1)
Expand All @@ -179,6 +179,20 @@ def shoot(self):
bullets.add(bullet2)
shooting_sound.play()

""" MOAR POWAH """
if self.power >= 3:
bullet1 = Bullet(self.rect.left, self.rect.centery)
bullet2 = Bullet(self.rect.right, self.rect.centery)
missile1 = Missile(self.rect.centerx, self.rect.top) # Missile shoots from center of ship
all_sprites.add(bullet1)
all_sprites.add(bullet2)
all_sprites.add(missile1)
bullets.add(bullet1)
bullets.add(bullet2)
bullets.add(missile1)
shooting_sound.play()
missile_sound.play()

def powerup(self):
self.power += 1
self.power_time = pygame.time.get_ticks()
Expand Down Expand Up @@ -276,6 +290,23 @@ def update(self):
## lets bind it to "spacebar".
## adding an event for it in Game loop

## FIRE ZE MISSILES
class Missile(pygame.sprite.Sprite):
def __init__(self, x, y):
pygame.sprite.Sprite.__init__(self)
self.image = missile_img
self.image.set_colorkey(BLACK)
self.rect = self.image.get_rect()
self.rect.bottom = y
self.rect.centerx = x
self.speedy = -10

def update(self):
"""should spawn right in front of the player"""
self.rect.y += self.speedy
if self.rect.bottom < 0:
self.kill()


###################################################
## Load all game images
Expand All @@ -288,6 +319,7 @@ def update(self):
player_mini_img = pygame.transform.scale(player_img, (25, 19))
player_mini_img.set_colorkey(BLACK)
bullet_img = pygame.image.load(path.join(img_dir, 'laserRed16.png')).convert()
missile_img = pygame.image.load(path.join(img_dir, 'missile.png')).convert_alpha()
# meteor_img = pygame.image.load(path.join(img_dir, 'meteorBrown_med1.png')).convert()
meteor_images = []
meteor_list = [
Expand Down Expand Up @@ -336,6 +368,7 @@ def update(self):
###################################################
### Load all game sounds
shooting_sound = pygame.mixer.Sound(path.join(sound_folder, 'pew.wav'))
missile_sound = pygame.mixer.Sound(path.join(sound_folder, 'rocket.ogg'))
expl_sounds = []
for sound in ['expl3.wav', 'expl6.wav']:
expl_sounds.append(pygame.mixer.Sound(path.join(sound_folder, sound)))
Expand Down

0 comments on commit f3f5822

Please sign in to comment.