I have a strange behavior with when using pygame.
[...]
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
[...]
while running:
[...]
dt = (new_time - start_time).total_seconds()
keys = pygame.key.get_pressed()
if keys[pygame.K_DOWN]:
bot.brake(dt)
elif keys[pygame.K_UP]:
bot.accelerate(dt)
Sometimes, even if I am not pushing any key, it instantaneously starts to accelerate the bot. When I debug, I found that the key is pressed for pygames, even if I don't touch the keyboard. That happens even on a fresh start of the game.
Can you help me find the cause of this problem?