From 98a2e240e386d6252129f97fe18f61ee4f4e1333 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 1 Apr 2024 00:09:37 +0300 Subject: [PATCH] phc: key repeat + 30 fps event_loop --- mod_pygame/phantom_castle.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mod_pygame/phantom_castle.py b/mod_pygame/phantom_castle.py index 73ffdb0..c1bb526 100644 --- a/mod_pygame/phantom_castle.py +++ b/mod_pygame/phantom_castle.py @@ -339,7 +339,7 @@ class Hero(GameObject): if not self.active: return - wide, short = 30, 5 + wide, short = 10, 2 if event.type == pygame.KEYDOWN: match event.key: case pygame.K_UP: @@ -646,11 +646,14 @@ class Scene(GameObject): self.end.handle_event(event) def event_loop(self): + clock = pygame.time.Clock() + pygame.key.set_repeat(50, 30) while not self.done: - event = pygame.event.wait() - self.handle_event(event) + for event in pygame.event.get(): + self.handle_event(event) self.draw() pygame.display.flip() + clock.tick(30) def game(assets):