-
Notifications
You must be signed in to change notification settings - Fork 1
/
gametest.py
53 lines (37 loc) · 986 Bytes
/
gametest.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
import os
import pygame
pygame.init()
display_width = 800
display_height = 600
black = (0, 0, 0)
white = (255, 255, 255)
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('Testing')
clock = pygame.time.Clock()
crashed = False
class Car(pygame.Rect):
def __init__(self, x, y):
super().__init__(x, y, carImg.get_size()[0], carImg.get_size()[1])
self.image = carImg
carImg = pygame.transform.scale2x(pygame.image.load('open.png'))
def draw_car(x, y):
gameDisplay.blit(carImg, (x, y))
x = display_width * 0.45
y = display_height * 0.8
gameDisplay.fill(white)
draw_car(x, y)
pygame.display.flip()
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
y -= 1
gameDisplay.fill(white)
draw_car(x, y)
if y < 10:
crashed = True
pygame.display.flip()
clock.tick(10)
pygame.quit()
quit()