title: Turn left, right, accelerate or decelerate with Python turtle
body: <p>I am using turtle trying to move my Sprite and let it turn left or right or accelerate or decelerate. But my coding does not work. It only moves towards one direction and then disappears on the screen. Not sure where I did wrong.</p>
  
  <pre><code>import turtle
  turtle.fd(0)
  turtle.speed(0)
  turtle.bgcolor("black")
  turtle.hideturtle()
  turtle.setundobuffer(1)
  turtle.tracer(1)
  
  
  class Sprite(turtle.Turtle):
      def __init__(self, spriteshape, color, startx, starty):
          turtle.Turtle.__init__(self, shape=spriteshape)
          self.speed(0)
          self.penup()
          self.color(color)
          self.fd(0)
          self.goto(startx, starty)
          self.speed = 1
  
      def move(self):
          self.fd(self.speed)
  
  
  class Player(Sprite):
      def __init__(self, spriteshape, color, startx, starty):
          Sprite.__init__(self, spriteshape, color, startx, starty)
          self.speed = 4
          self.lives = 3
  
      def turn_left(self):
          self.lt(45)
  
      def turn_right(self):
          self.rt(45)
  
      def accelerate(self):
          self.speed += 1
  
      def decelerate(self):
          self.speed -= 1
  
  
  # Create my sprite
  player = Player("triangle", "white", 0, 0)
  turtle.onkey(player.turn_left, "Left")
  turtle.onkey(player.turn_right, "Right")
  turtle.onkey(player.accelerate, "Up")
  turtle.onkey(player.decelerate, "Down")
  turtle.listen()
  
  # Main game loop
  while True:
      player.move()
  </code></pre>