Irányítás
This commit is contained in:
38
src/controls.py
Normal file
38
src/controls.py
Normal 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
|
||||
Reference in New Issue
Block a user