-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalien.py
More file actions
37 lines (28 loc) · 959 Bytes
/
Copy pathalien.py
File metadata and controls
37 lines (28 loc) · 959 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
25
26
27
28
29
30
31
32
33
34
35
36
37
import pygame
class Alien(pygame.sprite.Sprite):
def __init__(self, color, x, y):
super().__init__()
file_path = 'graph/' + color + '.png'
self.image = pygame.image.load(file_path).convert_alpha()
self.rect = self.image.get_rect(topleft=(x, y))
if color == 'red':
self.value = 100
elif color == 'green':
self.value = 200
else:
self.value = 300
def update(self, direction):
self.rect.x += direction
class Extra(pygame.sprite.Sprite):
def __init__(self, side, screen_width):
super().__init__()
self.image = pygame.image.load('graph/extra.png').convert_alpha()
if side == 'right':
x = screen_width + 50
self.speed = -3
else:
x = -50
self.speed = 3
self.rect = self.image.get_rect(topleft=(x, 80))
def update(self):
self.rect.x += self.speed