-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (26 loc) · 910 Bytes
/
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
import visualization as visu
import pygame as pg
import sys
# Initialize everything.
# pygame.init() is include in the __init__-function of Graphics.
my_game = visu.Graphics()
# button_change_flag =
# Game loop.
while 1:
# Check if the visuals correspond to the right state.
my_game.check_state()
# Check for events in the event que.
for event in pg.event.get():
# Check if the game was quit.
if event.type == pg.QUIT:
pg.quit()
sys.exit()
# Check for mouse clicks.
elif event.type == pg.MOUSEBUTTONDOWN:
# Save the position of the mouse at the moment the screen is clicked.
pos_x, pos_y = pg.mouse.get_pos()
my_game.on_click(pos_x, pos_y)
# Update the screen.
pg.display.flip()
# If the game did not end, add a delay so that the CPU is not occupied all the time.
pg.time.delay(5)