def move(self): old_x, old_y = self.snake[-1] dir_x, dir_y = self.snake_direction new_x = old_x + dir_x new_y = old_y + dir_y
# Checking if the player has gone outside of the game area
if new_x < 0:
exit('GAME OVER')
if new_y < 0:
exit('GAME OVER')
if new_x >= self.width:
exit('GAME OVER')
if new_y >= self.height:
exit('GAME OVER')
new_head = new_x, new_y
self.snake.append(new_head)
del self.snake[0]