import pygame class InputHandler: # returns pressed key def getPressed(): return pygame.key.get_pressed() # takes in movement inputs and maps them to x and y axis def getInputAxis() -> tuple: xvel:int = 0 yvel:int = 0 # construct x and y velocity input axis if InputHandler.getPressed()[pygame.K_a] or InputHandler.getPressed()[pygame.K_LEFT]: xvel = -1 if InputHandler.getPressed()[pygame.K_d] or InputHandler.getPressed()[pygame.K_RIGHT]: xvel = 1 if InputHandler.getPressed()[pygame.K_w] or InputHandler.getPressed()[pygame.K_UP]: yvel = -1 if InputHandler.getPressed()[pygame.K_s] or InputHandler.getPressed()[pygame.K_DOWN]: yvel = 1 return tuple((xvel, yvel))