unlikely fix

This commit is contained in:
Yonokid
2026-01-01 10:56:55 -05:00
parent e0b7f0a863
commit d8a219243c
2 changed files with 20 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ from typing import Any
from libs.audio import audio
from libs.texture import tex
from libs.utils import input_state
logger = logging.getLogger(__name__)
@@ -34,6 +35,7 @@ class Screen:
return next_screen
def update(self) -> Any:
input_state.update()
ret_val = self._do_screen_start()
if ret_val:
return ret_val

View File

@@ -1,10 +1,9 @@
import string
import ctypes
import hashlib
import sys
import logging
import string
import sys
import time
from libs.global_data import PlayerNum, global_data
from pathlib import Path
from typing import Optional
@@ -16,6 +15,7 @@ from raylib import (
SHADER_UNIFORM_VEC4,
)
from libs.global_data import PlayerNum, global_data
from libs.texture import TextureWrapper
logger = logging.getLogger(__name__)
@@ -57,11 +57,25 @@ def strip_comments(code: str) -> str:
index += 1
return result
class InputState:
def __init__(self):
self.pressed_keys_this_frame = set()
def update(self):
"""Call this once per frame to drain the key queue"""
self.pressed_keys_this_frame.clear()
key = rl.GetKeyPressed()
while key > 0:
self.pressed_keys_this_frame.add(key)
key = rl.GetKeyPressed()
input_state = InputState()
def is_input_key_pressed(keys: list[int], gamepad_buttons: list[int]):
if global_data.input_locked:
return False
for key in keys:
if rl.IsKeyPressed(key):
if key in input_state.pressed_keys_this_frame:
return True
if rl.IsGamepadAvailable(0):