-
Notifications
You must be signed in to change notification settings - Fork 0
/
obstacle.py
26 lines (20 loc) · 843 Bytes
/
obstacle.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
import pygame
class Obstacle(pygame.sprite.Sprite):
def __init__(self, groups, image: pygame.Surface, pos) -> None:
super().__init__(*groups)
self.image = image
self.rect = self.image.get_rect(topleft=pos)
def update(self, *args, **kwargs) -> None:
self.rect.topleft -= pygame.Vector2(kwargs.get("game_speed"), 0)
if self.rect.topright[0] < 0:
self.kill()
class PointObstacle(pygame.sprite.Sprite):
def __init__(self, groups, pos) -> None:
super().__init__(*groups)
surface = pygame.Surface((140, 140))
self.rect = surface.get_rect(topleft=pos)
def update(self, *args, **kwargs) -> None:
self.rect.topleft -= pygame.math.Vector2(
kwargs.get("game_speed") * 2, 0)
if self.rect.topright[0] < 0:
self.kill()