zoria/src/controller.py

20 lines
417 B
Python
Raw Normal View History

2020-02-19 10:42:00 -08:00
import pygame
keybinds = {
"up": ["w", "UP"],
"down": ["s", "DOWN"],
"left": ["a", "LEFT"],
"right": ["d", "RIGHT"],
"shift": ["RSHIFT", "LSHIFT"],
2020-05-02 02:28:38 -07:00
"attack": ["SPACE"],
2020-02-19 10:42:00 -08:00
}
def is_down(control):
try:
keys = pygame.key.get_pressed()
for key in keybinds[control]:
if keys[getattr(pygame, "K_" + key)]:
return True
except:
return False