I'm creating a Snake game in Python. After pressing a direction key the snake will move in that direction at a slow pace until the user presses another key. I was able to make the snake move after pressing a key, but I could not stop it by pressing another key: (I'm using a pygame)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
while i==False:
time.sleep(0.2)
X_had1=X_had1 - 1
#Print operation
if event.type == pygame.KEYDOWN:
if event.key != pygame.K_LEFT:
i=True