-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPipe.py
36 lines (25 loc) · 929 Bytes
/
Pipe.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
import pygame
import random
class Pipe:
def __init__(self):
self.colour = (211, 253, 117)
self.width = 52
self.height = random.randint(50,300)
self.gap = 100
self.x = 288
self.dx = -1
self.score_sound = pygame.mixer.Sound('Sounds/sfx_point.wav')
def display(self, screen):
# Upper pipe
pygame.draw.rect(screen, self.colour, (self.x, 0, self.width, self.height))
# Lower pipe
lower_pipe_height = 300 - self.height
pygame.draw.rect(screen, self.colour, (self.x, self.height + self.gap, self.width, lower_pipe_height))
def update(self, dt):
self.x += self.dx * dt
if self.x <= -10:
self.x = 288
self.height = random.randint(50,300)
# pygame.mixer.Sound.play(self.score_sound)
return 1
return 0