23 lines
594 B
Python

import pygame
class InputHandler:
# returns pressed key
def getPressed():
return pygame.key.get_pressed()
def getInputAxis() -> tuple:
xvel:int = 0
yvel:int = 0
# construct x and y velocity input axis
if InputHandler.getPressed()[pygame.K_a]:
xvel = -1
if InputHandler.getPressed()[pygame.K_d]:
xvel = 1
if InputHandler.getPressed()[pygame.K_w]:
yvel = -1
if InputHandler.getPressed()[pygame.K_s]:
yvel = 1
return tuple((xvel, yvel))