46 lines
991 B
Python
46 lines
991 B
Python
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"),
|
|
Control(arcade.key.ENTER, "Választ"),
|
|
Control(arcade.key.LSHIFT, "Vissza"),
|
|
]
|
|
|
|
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 depress(cid):
|
|
if controls[cid].pressed:
|
|
controls[cid].pressed = False
|
|
controls[cid].held = True
|
|
|
|
def is_control_pressed(cid):
|
|
return controls[cid].pressed
|
|
|
|
def is_control_held(cid):
|
|
return controls[cid].held
|