-
Notifications
You must be signed in to change notification settings - Fork 0
/
barrier.py
36 lines (30 loc) · 1.15 KB
/
barrier.py
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
import pygame
from pygame.colordict import THECOLORS
class Barrier(pygame.sprite.Sprite):
def __init__(self, x, speed, score, group) -> None:
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('images/barrier_150.png').convert_alpha()
self.image.set_colorkey(THECOLORS['white'])
self.rect = self.image.get_rect(center = (x, 0))
self.speed = speed
self.score = score
self.add(group)
def update(self, *args) -> None:
if self.rect.y < args[0] - 20:
self.rect.y += self.speed
else:
self.kill()
class Haystack(pygame.sprite.Sprite):
def __init__(self, x, speed, score, group) -> None:
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('images/haystack_120.png').convert_alpha()
self.image.set_colorkey(THECOLORS['white'])
self.rect = self.image.get_rect(center = (x, 0))
self.speed = speed
self.score = score
self.add(group)
def update(self, *args) -> None:
if self.rect.y < args[0] - 20:
self.rect.y += self.speed
else:
self.kill()