-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (29 loc) · 819 Bytes
/
Copy pathmain.py
File metadata and controls
38 lines (29 loc) · 819 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
38
import pygame
from Bird import Bird
from Drawer import Drawer
from Controller import Controller
pygame.init()
# Screen config
WIDTH = 480
HEIGHT = 640
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("PyBird")
# Classes instances
bird = Bird([200, 320])
controller = Controller(screen, bird)
drawer = Drawer(screen, WIDTH, HEIGHT, bird, controller)
# Game loop
running = True
clock = pygame.time.Clock()
frametime = 60
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
bird.jump()
controller.update()
drawer.draw()
pygame.display.update()
clock.tick(frametime)