Sep-02-2024, 02:13 PM
Hello, I'm having a problem. I'm trying to make the "A" key do the basic movement of moving my player to the side. This error occurs that says that 'K_a' is not defined. I'm basing this entirely on my understanding, on the pygame DOC, and on examples from the internet, so I'm not really understanding what happened because in the pygame doc, the A key is written 'K_a'. Could someone explain it to me?
this function is in the player
this function is in the player
def _inputs(self, events): if events.type == pygame.key.get_pressed()[K_a]: self.posX -= speedthis function is in the game
def _events(self): for event in pygame.event.get(): self.player._inputs(event) # player Input (Player is in a player variable) if event.type == pygame.QUIT: self.running = False
Error:NameError: name 'K_a' is not defined