forked from caphax/dino_run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (45 loc) · 1.49 KB
/
main.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
54
55
56
57
58
59
60
61
from random import randint
import pygame
from class_plaer import dinozavrik
from class_kaktus import long_kaktus, short_kaktus
def close_game():
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
kaktuses = pygame.sprite.Group()
RES = 800
fps = 60
pygame.init()
screen = pygame.display.set_mode((RES, RES))
clock = pygame.time.Clock()
dino = dinozavrik()
t = pygame.time.get_ticks()
shrift = pygame.font.Font(None, 120)
while True:
collide = pygame.Rect.collidelist(dino.rect, kaktuses.sprites())
screen.fill('black')
if len(kaktuses) < 3 and pygame.time.get_ticks() - t >= randint(400, 9000):
t = pygame.time.get_ticks()
if randint(1,3) == 1:
kaktuses.add(long_kaktus())
else:
kaktuses.add(short_kaktus())
dino.test()
kaktuses.update()
kaktuses.draw(screen)
# long_kaktus().kill()
pygame.draw.rect(screen, pygame.Color('white'), (0, 500, 900, 5))
dino.draw(screen)
# if collide == 0:
# while True:
# screen.fill('black')
# screen.blit(shrift.render('GAME OVER', True, (200,0,0)), (140, 100))
# screen.blit(shrift.render('click in spase', True, (50,0,0)), (140, 170))
# pygame.display.update()
# close_game()
# if pygame.key.get_pressed()[pygame.K_SPACE]:
# kaktuses = pygame.sprite.Group()
# break
clock.tick(fps)
pygame.display.update()
close_game()