-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (31 loc) · 1.09 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
import pygame as pg
from components.world import World
from constants import *
def main():
pg.init()
screen = pg.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), pg.DOUBLEBUF, 8) #, pg.RESIZABLE)
clock = pg.time.Clock()
running = True
w = World(screen, imgs(), width=screen.get_width(), height=screen.get_height())
pg.event.set_allowed([pg.QUIT, pg.KEYDOWN])
while running:
for event in pg.event.get():
if event.type == pg.KEYDOWN:
if event.key == pg.K_DOWN:
w.update()
if event.type == pg.MOUSEBUTTONDOWN:
for i, cell in enumerate(w.flatCells):
if cell.rect.collidepoint(event.pos):
cell.onClick(event)
if event.type == pg.QUIT:
running = False
pg.display.flip()
clock.tick(FPS)
if REFRESH_DELAY > 0:
pg.event.pump()
pg.time.delay(REFRESH_DELAY)
w.update()
#print(clock.get_fps())
if __name__ == '__main__':
main()
pg.quit()