-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipe.py
More file actions
20 lines (17 loc) · 781 Bytes
/
Copy pathpipe.py
File metadata and controls
20 lines (17 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pygame
from game_object import GameObject
from shape_renderer import ShapeRenderer
class Pipe(GameObject):
def __init__(self, x, y, width, height, speed, is_top=True):
super().__init__()
self.speed = speed
self.scored = False # Flag to check if the bird has passed this pipe
self.trained = False # Flag to check if the pipe has been trained on
self.is_top = is_top # Indicates whether this is the top or bottom pipe
# Create the rectangle surface for the pipe
self.image = ShapeRenderer.create_rectangle_surface(width, height, (34, 139, 34))
self.rect = self.image.get_rect(topleft=(x, y))
def update(self):
self.rect.x -= self.speed
if self.rect.right < 0:
self.kill()