16 lines
385 B
Python
16 lines
385 B
Python
|
# engine/input_handler.py
|
||
|
import pygame
|
||
|
|
||
|
class InputHandler:
|
||
|
def __init__(self):
|
||
|
self.keys = {}
|
||
|
|
||
|
def process_event(self, event):
|
||
|
if event.type == pygame.KEYDOWN:
|
||
|
self.keys[event.key] = True
|
||
|
elif event.type == pygame.KEYUP:
|
||
|
self.keys[event.key] = False
|
||
|
|
||
|
def is_key_pressed(self, key):
|
||
|
return self.keys.get(key, False)
|