import turtle import math wn = turtle.Screen() wn.bgcolor("blue") wn.tracer(3) player = turtle.Turtle() player.color("red") player.shape("circle") player.penup() player.speed(0) player.setposition(-225, 50) square = turtle.Turtle() square.color("white") square.shape("square") square.penup() square.speed(0) square.setposition(-200, 100) square_2 = turtle.Turtle() square_2.color("white") square_2.shape("square") square_2.penup() square_2.speed(0) square_2.setposition(-250, 50) speed = 0.4 def turnleft(): player.left(90) def turnright(): player.right(90) turtle.listen() turtle.onkey(turnleft, "Left") turtle.onkey(turnright, "Right") while True: player.forward(speed) d = math.sqrt(math.pow(player.xcor()-square.xcor(),2) + math.pow(player.ycor()-square.ycor(),2)) if d < 20: square.q() d = math.sqrt(math.pow(player.xcor()-square_2.xcor(),2) + math.pow(player.ycor()-square_2.ycor(),2)) if d < 20: square_2.q()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)