more flexible functions, allow passing arguments to functions
This commit is contained in:
@@ -14,7 +14,7 @@ pygame.init()
|
||||
pygame.mouse.set_visible(False)
|
||||
|
||||
SIZE = (1280, 1024)
|
||||
mode = pygame.display.set_mode(SIZE, 1)
|
||||
screen = pygame.display.set_mode(SIZE, pygame.HWSURFACE | pygame.DOUBLEBUF)
|
||||
pygame.display.set_caption("weather clock")
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
@@ -24,6 +24,8 @@ def game_loop():
|
||||
parent = None
|
||||
|
||||
while True:
|
||||
clock.tick(1)
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_q:
|
||||
@@ -35,13 +37,13 @@ def game_loop():
|
||||
|
||||
panel_time = os.stat(CONFIG_PATH).st_mtime_ns
|
||||
if panel_time != panel_load:
|
||||
parent = panel.Panel(SIZE, children=panel.load(CONFIG_PATH))
|
||||
parent = panel.Panel(lambda: pygame.Surface(SIZE), children=panel.load(CONFIG_PATH))
|
||||
panel_load = panel_time
|
||||
|
||||
mode.blit(parent.surf, (0, 0))
|
||||
screen.fill((0, 0, 0))
|
||||
screen.blit(parent.surf, (0, 0))
|
||||
|
||||
pygame.display.update()
|
||||
clock.tick(8)
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
game_loop()
|
||||
|
||||
Reference in New Issue
Block a user