Irányítás

This commit is contained in:
markojozsef
2026-09-16 12:30:05 +02:00
parent 4eaf0dbd98
commit bbdead0b2e
5 changed files with 59 additions and 20 deletions

38
src/controls.py Normal file
View File

@@ -0,0 +1,38 @@
import arcade
class Control:
def __init__(self, key, label):
self.key = key
self.label = label
self.pressed = False
self.held = False
controls = [
Control(arcade.key.W, "Fel"),
Control(arcade.key.S, "Le"),
Control(arcade.key.A, "Bal"),
Control(arcade.key.D, "Jobb"),
]
def key_press(key):
for c in controls:
if c.key == key:
c.pressed = True
def key_release(key):
for c in controls:
if c.key == key:
c.pressed = False
c.held = False
def update():
for c in controls:
if c.pressed:
c.pressed = False
c.held = True
def is_control_pressed(cid):
return controls[cid].pressed
def is_control_held(cid):
return controls[cid].held