-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·48 lines (39 loc) · 1.21 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
from utils import *
from enemy import *
from tower import *
from menu import *
def pause_game():
global play
play = not play
pygame.init()
screen = pygame.display.set_mode((1000, 588 + int(192 * 0.50556))) # TODO: увеличить высоту для панели
play = True
screens = [
load_img('f/screens/screen0.png', size=(1000, 588))
]
world = [
Enemy(open_path('f/levels/paths/level_1.1.txt', 'wave.v.1'), 'run', enemy_imgs['scorpion']),
StoneTower(200, 200, stone_imgs['stone'], tower_imgs['stone'])
]
t = 0
buttons = [
Button(881, 560, menu_imgs['buttons']['action']['pause'], pause_game)
]
p = Panel(0, 588, menu_imgs['panel'], buttons)
while True:
if play:
screen.blit(screens[0], (0, 0))
pygame.time.delay(10)
t += 1
if t % 150 == 0:
world.append(Enemy(open_path('f/levels/paths/level_1.2.txt'), 'run', enemy_imgs['scorpion']))
for elem in world:
elem.update()
elem.draw(screen)
p.draw(screen)
for e in pygame.event.get():
if e.type == pygame.QUIT:
exit()
elif e.type == pygame.MOUSEBUTTONUP:
p.try_push(*pygame.mouse.get_pos())
pygame.display.flip()