Question: whats wrong with my code? Draw a boundary for the game as a circle with a 3 0 0 unit radius centered on ( 0

whats wrong with my code? Draw a boundary for the game as a circle with a 300 unit radius centered on (0,0). You will use an
invisible turtle to do this.
Add a hunter turtle (with a different color and shape than the other turtles). The user should be
able to move the turtle left and right and should be able to speed up and slow down the turtle
with its speed never dropping below 1(like from lab 5). If the hunter turtle hits the wall, it should
move jump to the center of the screen.
Add two shark "turtles" to hunt the hunter. These sharks should begin the game at location (200,
0) and (-200,0). They should move toward the hunter turtle in some non-random fashion.
None of the turtles should leave lines behind as they move.
import turtle
import random
win = turtle.Screen()
boundary = turtle.Turtle()
boundary.hideturtle()
boundary.penup()
boundary.goto(0,-300)
boundary.pendown()
boundary.circle(300)
hunt = turtle.Turtle()
hunt.color('pink')
hunt.shape('square')
hunt.width(5)
sharkTurtles =[]
shark1= turtle.Turtle()
shark1.color('blue')
shark1.width(6)
shark1.shape('arrow')
shark2= turtle.Turtle()
shark2.color('blue')
shark2.width(6)
shark2.shape('arrow')
speed =1
sharkSpeed =1
running = True
def go_left():
hunt.left(15)
def go_right():
hunt.right(15)
def go_home():
hunt.setposition(0,0)
def stop():
global running
running = False
def speed_up():
global speed
speed = speed +1
def speed_down():
global speed
if speed >0:
speed = speed -1
win.listen()
win.onkey(go_left, "Left")
win.onkey(go_right, "Right")
win.onkey(go_home, "space")
win.onkey(stop,"q")
win.onkey(speed_up,"Up")
win.onkey(speed_down, "Down")
shark1.penup()
shark1.setposition(200,0)
shark2.penup()
shark2.setposition(-200,0)
sharks = shark1, shark2
while running:
hunt.forward(speed)
angleToHunt = sharks.towards(int(hunt.xcor()), int(hunt.ycor()))
sharks.setheading(angleToHunt)
sharks.forward(sharkSpeed)
whats wrong with my code? Draw a boundary for the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!