-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.py
47 lines (32 loc) · 826 Bytes
/
frontend.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
46
if not __name__ == "__main__":
raise ImportError("Do not import the Decrolution front-end as a library!")
from pygame import display, event, draw, locals
from sys import exit
from decrolution import initialize, update, GRID
from numpy import ndindex
scale: int = 8
display.init()
display.set_mode((800, 600))
display.set_caption("Decrolution")
#display.set_icon("")
initialize()
counter = 0
while True:
for e in event.get():
if e.type == locals.QUIT:
exit()
if counter == 100:
counter = 0
update()
counter += 1
display.get_surface().fill((0x00, 0x00, 0x00))
for x, y in ndindex(GRID.shape):
cell = GRID[x, y]
if cell is None:
continue
draw.rect(
display.get_surface(),
cell.colour.as_tuple(),
(x * scale, y * scale, scale, scale)
)
display.flip()