-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (38 loc) · 1.14 KB
/
main.py
File metadata and controls
48 lines (38 loc) · 1.14 KB
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
import pygame
from pygame.constants import HWSURFACE, DOUBLEBUF, RESIZABLE
from texture_manager import TextureManager
from player import Player, Bullet
from wave_manager import WaveManager
TextureManager.load_directory('res')
pygame.init()
window = pygame.display.set_mode((64 * 15, 64 * 15), HWSURFACE | DOUBLEBUF)
pygame.display.set_caption("SSSPACE INVADERS!")
pygame.display.set_icon(TextureManager.get("player"))
pygame.mixer.init()
pygame.mixer.set_num_channels(32)
clock = pygame.time.Clock()
game_timer = 0.0
dt = 0.0
player = Player()
wave_manager = WaveManager()
running = True
while running:
# Handle input
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
break
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
break
player.proccess_event(dt, wave_manager.aliens)
wave_manager.update(dt)
window.fill((0, 0, 0))
wave_manager.draw(window)
player.draw(window)
pygame.display.update()
dt = clock.tick(60) / 1000.0
# Update
game_timer += dt
pygame.quit()