can someone help me solve "8.4 Eyes following dot" from CMU CS academy?



code:



app.background = 'salmon'



dot = Circle(200, 200, 5, fill=None, border='white')

eyes = Group()



def makeEyes():

Fix these nested for loops so that they draw another row and column of

eyes in the bottom right corner.

(HINT: You will only need to change one number in the 'range' of

each for loop. Why aren't eyes drawn there now?)

Fix Your Code Here ###

for centerX in range(0, 400, 100):

for centerY in range(0, 400, 100):

Oval(centerX, centerY, 70, 65, fill='white')

newEye = Group(

Oval(centerX, centerY, 30, 28, fill='cyan', border='black'),

Oval(centerX, centerY, 15, 15)

)


Saves centerX, and centerY value so you can use it for resetting

the eye in onMouseMove.

newEye.resetX = centerX

newEye.resetY = centerY

eyes.add(newEye)



eyes.toFront()

dot.toFront()



makeEyes()



def onMouseMove(mouseX, mouseY):

Moves the dot to the mouse location.

dot.centerX = mouseX

dot.centerY = mouseY


Loops over each eye in the group eyes.

for eye in eyes.children:

Change this code so that the angle it is creating is the angle between

the eye's reset custom properties and the current mouse location.

Fix Your Code Here ###

angle = angleTo(0, 0, 200, 200)


Increase the amount the eyes move based on how far from the mouse

they are.

distanceMoved = 20 - (distance(mouseX, mouseY, eye.resetX, eye.resetY) / 20)


Change this code so that the getPointInDir function uses the eye's

reset custom properties as its x1 and y1, and uses the calculated

angle above.

Fix Your Code Here ###

newCenterX, newCenterY = getPointInDir(200, 200, 50, distanceMoved)

eye.centerX = newCenterX

eye.centerY = newCenterY