mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
unlikely fix
This commit is contained in:
@@ -3,6 +3,7 @@ from typing import Any
|
|||||||
|
|
||||||
from libs.audio import audio
|
from libs.audio import audio
|
||||||
from libs.texture import tex
|
from libs.texture import tex
|
||||||
|
from libs.utils import input_state
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ class Screen:
|
|||||||
return next_screen
|
return next_screen
|
||||||
|
|
||||||
def update(self) -> Any:
|
def update(self) -> Any:
|
||||||
|
input_state.update()
|
||||||
ret_val = self._do_screen_start()
|
ret_val = self._do_screen_start()
|
||||||
if ret_val:
|
if ret_val:
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import string
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from libs.global_data import PlayerNum, global_data
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -16,6 +15,7 @@ from raylib import (
|
|||||||
SHADER_UNIFORM_VEC4,
|
SHADER_UNIFORM_VEC4,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from libs.global_data import PlayerNum, global_data
|
||||||
from libs.texture import TextureWrapper
|
from libs.texture import TextureWrapper
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -57,11 +57,25 @@ def strip_comments(code: str) -> str:
|
|||||||
index += 1
|
index += 1
|
||||||
return result
|
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]):
|
def is_input_key_pressed(keys: list[int], gamepad_buttons: list[int]):
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if rl.IsKeyPressed(key):
|
if key in input_state.pressed_keys_this_frame:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if rl.IsGamepadAvailable(0):
|
if rl.IsGamepadAvailable(0):
|
||||||
|
|||||||
Reference in New Issue
Block a user