I am trying to draw a shape and then move that shape around the screen with the arrow keys. My goal is to make a 2D game in the end, but I can't figure out how to draw more than a circle and get it all to move.
I pasted my code so far. After the circle is drawn I tried going for a line and it doesn't seem to like that. If I take out that forward
statement then I can move the circle around again.
import turtle
def Left():
move.left(1)
move.forward(1)
def Right():
move.right(1)
move.forward(1)
def Forwards():
move.forward(1)
def Backwards():
move.backward(1)
def moving_object(move):
move.fillcolor('orange')
move.begin_fill()
move.circle(20)
move.forward(10)
move.end_fill()
screen = turtle.Screen()
screen.setup(600,600)
screen.bgcolor('green')
screen.tracer(0)
move = turtle.Turtle()
move.color('orange')
move.speed(0)
move.width(2)
move.hideturtle()
move.penup()
move.goto(-250, 0)
move.pendown()
screen.listen()
screen.onkeypress(Left, "Left")
screen.onkeypress(Right, "Right")
screen.onkeypress(Forwards, "Up")
screen.onkeypress(Backwards, "Down")
while True :
move.clear()
moving_object(move)
screen.update()