Do Now

  1. Go to repl.it ➝ my repls
  2. Create new Python Turtle repl  (click red + at bottom right)
  3. Copy & paste your code from Keyboard Control 1
import turtle

player1 = turtle.Turtle()

world = turtle.Screen()
world.bgcolor("black")
world.listen()
player1.penup()
player1.color("red")
player1.shape("turtle")

def moveUp():
  player1.seth(90)
  player1.sety(player1.ycor() +20)
def moveDown():
  player1.seth(270)
  player1.sety(player1.ycor() -20)
def moveLeft():
  player1.seth(180)
  player1.setx(player1.xcor() -20)
def moveRight():
  player1.seth(0)
  player1.setx(player1.xcor() +20)
 
world.onkey(moveUp, "Up")
world.onkey(moveDown, "Down")
world.onkey(moveLeft, "Left")
world.onkey(moveRight, "Right")

you'll need this for classwork today, so copy this if you don't have it

Do Now

By Michelle Lim

Do Now

  • 1,250