diff --git a/BlankProjectTemplate/src/Gameplay.py b/BlankProjectTemplate/src/Gameplay.py index 5197934210f998fc0acaac7350c68998bfb58a8b..92048beb2deffa0eef1de4103f5f51d1bf64b993 100644 --- a/BlankProjectTemplate/src/Gameplay.py +++ b/BlankProjectTemplate/src/Gameplay.py @@ -35,6 +35,7 @@ def game(speed, colour, backgroundColour): pygame.draw.rect(win, colour , [x,y, size, size]) food = Food(size) + still = True #Loop through the events as long as the game is running run = True @@ -52,21 +53,22 @@ def game(speed, colour, backgroundColour): if event.type == pygame.KEYDOWN: if (event.key == pygame.K_LEFT): # if snake is moving up or down, turn left, otherwise don't turn - if (snake.axis): snake.direct = -1 + if (snake.axis or still): snake.direct = -1; still = False snake.axis = 0 if (event.key == pygame.K_RIGHT): #if snake is moving up or down turn right, otherwise dont turn - if (snake.axis): snake.direct = 1 + if (snake.axis or still): snake.direct = 1; still = False snake.axis = 0 if (event.key == pygame.K_UP): #if snake is moving left or right turn up, otherwise dont turn - if (not snake.axis): snake.direct = -1 + if (not snake.axis or still): snake.direct = -1; still = False snake.axis = 1 if (event.key == pygame.K_DOWN): #if snake is moving left or right turn down, otherwise dont turn - if (not snake.axis): snake.direct = 1 + if (not snake.axis or still): snake.direct = 1; still = False snake.axis = 1 + #Snake moving depending on axis and direction if (snake.axis): y += (size)*snake.direct