From 7ed23a5d5f3b69ae7d4f6d34574b5a60b2d354be Mon Sep 17 00:00:00 2001 From: Roz K Date: Fri, 23 Dec 2022 10:25:37 +0100 Subject: [PATCH] Terminate on key release. --- game/game.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/game/game.py b/game/game.py index 3744743..73f62a0 100644 --- a/game/game.py +++ b/game/game.py @@ -154,6 +154,7 @@ def main(): clouds_orientation = tests_batch.params[clouds_id].orientation print("Running...") + events = buffer(Event, 16) start_time = time.monotonic() current_time = 0.0 frame_min = 10000.0 @@ -236,6 +237,19 @@ def main(): frame_max = max(frame_max, frame_ms) frame_avg += frame_ms perf_count += 1 + + stop = False + while True: + nevents = consume_events(events, len(events)) + if not nevents: + break + for event in events[:nevents]: + if event.type == EVENT_KEY_RELEASE: + print("EVENT_KEY_RELEASE:", event.data.key.keycode) + stop = True + if stop: + break + except KeyboardInterrupt: pass