how to control snake with only two keys i.e left and right
问题 currently, i'm using all four keys to steer the snake left, right, up and down. I'm wondering how can i only use left and right key to move the snake around. if event.key == pygame.K_LEFT: snake.direction = 2 elif event.key == pygame.K_RIGHT: snake.direction = 3 elif event.key == pygame.K_UP: snake.direction = 0 elif event.key == pygame.K_DOWN: snake.direction = 1 def move(self): if self.direction is 0: self.dy = -self.block self.dx = 0 if self.direction is 1: self.dy = self.block self.dx = 0