-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (26 loc) · 857 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
32
33
import pygame
from classes.canvas import Canvas
from constants import FPS
def main():
canvas = Canvas()
clock = pygame.time.Clock()
canvas.load_file()
while True:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
canvas.dump_to_file()
return
if event.type == pygame.MOUSEBUTTONDOWN:
if canvas.pressed_button:
canvas.mouse_positions.append(event.pos)
else:
canvas.check_button_pressed(event.pos)
if event.type == pygame.KEYDOWN:
keys = pygame.key.get_pressed()
if keys[pygame.K_ESCAPE]:
canvas.reset_all_buttons()
canvas.update()
canvas.draw()
if __name__ == "__main__":
main()