-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation_gui.py
39 lines (30 loc) · 1.12 KB
/
simulation_gui.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
import pygame
#from src.Planet import Planet
#from src.Simulation import Simulation
# define some colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RICHBLUE = (2, 1, 34)
#define display size
display_width = 800
display_height = 600
ico = pygame.image.load('../imgs/favicon.ico')
pygame.init()
#open seprate window for simulation, init pygame
def create(simulation):
global sim
pygame.display.set_caption('Planetbox')
pygame.display.set_icon(ico)
DISPLAY = pygame.display.set_mode((display_width, display_height), pygame.RESIZABLE)
DISPLAY.fill(RICHBLUE)
simulation.animatePlanets(DISPLAY, display_width, display_height, 1)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.VIDEORESIZE:
DISPLAY = pygame.display.set_mode(event.dict['size'], pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.RESIZABLE)
DISPLAY.fill(RICHBLUE)
simulation.animatePlanets(DISPLAY, event.dict['w'], event.dict['h'], 1)
if __name__ == '__main__' : create()