-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (36 loc) · 1.34 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
import pygame
import simulator
from simulator import main
from utils import Button
WIDTH, HEIGHT = 1200, 700
win = pygame.display.set_mode((WIDTH, HEIGHT))
buttons = pygame.Surface((WIDTH, HEIGHT))
simulator.win = win
start_img = pygame.transform.scale(pygame.image.load("start.png"), (200, 100))
quit_img = pygame.transform.scale(pygame.image.load("quit.png"), (200, 100))
planet = pygame.transform.scale(pygame.image.load("jupiter.png"), (simulator.PLANET_SIZE * 2, simulator.PLANET_SIZE*2))
start_button = Button(WIDTH/2, 150, start_img)
quit_button = Button(WIDTH/2, HEIGHT/3 * 2, quit_img)
plan = simulator.Planet(WIDTH/2, HEIGHT/2, simulator.PLANET_MASS, buttons)
running = True
while running:
win.fill((0, 0, 0))
start_button.draw(buttons)
quit_button.draw(buttons)
plan.draw()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
if event.type == pygame.MOUSEBUTTONUP:
if start_button.rect.collidepoint(pygame.mouse.get_pos()):
main()
if quit_button.rect.collidepoint(pygame.mouse.get_pos()):
running = False
pygame.quit()
if start_button.collision():
main()
if quit_button.collision():
running = False
win.blit(buttons, (0, 0))
pygame.display.update()