-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra_alien.py
More file actions
22 lines (18 loc) · 808 Bytes
/
extra_alien.py
File metadata and controls
22 lines (18 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pygame
from constants import screen_size, alien_constants
# Represents a bonus alien that moves across the screen from either side.
class Extra(pygame.sprite.Sprite):
def __init__(self, starting_side):
super().__init__()
self.image = pygame.image.load("./assets/graphics/extra.png").convert_alpha()
self.rect = self.image.get_rect()
# Positioning the alien
self.x_start = -self.rect.width
self.speed = alien_constants.EXTRA_ALIEN_SPEED
if starting_side == "right":
self.x_start = screen_size.SCREEN_WIDTH
self.speed = -alien_constants.EXTRA_ALIEN_SPEED
self.rect.x = self.x_start
self.rect.y = alien_constants.EXTRA_ALIEN_Y_POSITION
def update(self):
self.rect.x += self.speed