-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbomb.py
More file actions
24 lines (19 loc) · 758 Bytes
/
bomb.py
File metadata and controls
24 lines (19 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pygame
from pygame.sprite import Sprite
class Bomb(Sprite):
def __init__(self, ai_game):
super().__init__()
self.screen = ai_game.screen
self.settings = ai_game.settings
# Create a bomb rect at the top of the ship
self.image = pygame.image.load("/Users/eugeneheynike/Desktop/Alien_Invasion/Bomb.png")
self.rect = self.image.get_rect()
self.rect.midtop = ai_game.ship.rect.midtop
# self.exists = True
# Store the bullet's position as a decimal value.
self.y = float(self.rect.y)
def update(self):
"""Move the bomb to the top of the screen"""
self.y -= self.settings.bullet_speed
# Update the rect position
self.rect.y = self.y