-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (28 loc) · 1.05 KB
/
main.py
File metadata and controls
36 lines (28 loc) · 1.05 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
import pygame
from controls import handle_interrupts
from drawing import draw, write_text
from objects import GameState
from physics import apply_gravitational_forces, move_planets, check_collisions_absorb
if __name__ == '__main__':
game_state = GameState()
pygame.init()
pygame.font.init()
display = pygame.display.set_mode(game_state.universe_bottom_right)
while not game_state.quit:
game_state = handle_interrupts(game_state)
if game_state.paused:
write_text(
GameState.universe_bottom_right[0] / 2,
GameState.universe_bottom_right[1] / 2,
'PAUSED',
display
)
pygame.display.flip()
continue
if game_state.pending_planet is None:
game_state = apply_gravitational_forces(game_state)
game_state = move_planets(game_state)
if len(game_state.planets) > 1:
game_state = check_collisions_absorb(game_state)
draw(game_state, display)
pygame.quit()