Hey, I'm brand new to Python and I'm sorry if my code/question is sloppy and ridiculous. I had to make a snowman for homework, but now I have to make the entire snowman move 6 times wherever the user clicks. I used this at first, but it obviously only moves the snowman's head:
for i in range(6):
p = win.getMouse()
c = top.getCenter()
dx = p.getX() - c.getX()
dy = p.getY() - c.getY()
top.move(dx,dy)
So how would I get all the pieces of the snowman to move at once?
from graphics import *
def main():
win = GraphWin("Snowman",400,500)
top = Circle(Point(200,115), 45)
top.setFill("white")
top.setOutline("white")
top.draw(win)
middle = Circle(Point(200,210), 65)
middle.setFill("white")
middle.setOutline("white")
middle.draw(win)
bottom = Circle(Point(200,345), 85)
bottom.setFill("white")
bottom.setOutline("white")
bottom.draw(win)
hat = Rectangle(Point(290,150),Point(200,160))
hat.setFill("black")
hat.move(-43,-86)
hat.draw(win)
tophat = Rectangle(Point(30,30),Point(70,70))
tophat.setFill("black")
tophat.move(150,-7)
tophat.draw(win)
eye = Circle(Point(180,100), 3.5)
eye.setFill("black")
eye.draw(win)
eye2=eye.clone()
eye2.move(40,0)
eye2.draw(win)
nose = Polygon(Point(180,90),Point(130,100),Point(180,100))
nose.setFill("orange")
nose.move(20,18)
nose.draw(win)
mouth = eye2.clone()
mouth.move(-50,25)
mouth.draw(win)
mouth2 = mouth.clone()
mouth2.move(15,10)
mouth2.draw(win)
mouth3 = mouth.clone()
mouth3.move(30,15)
mouth3.draw(win)
mouth4 = mouth.clone()
mouth4.move(45,10)
mouth4.draw(win)
mouth5 = mouth.clone()
mouth5.move(60,0)
mouth5.draw(win)
button = mouth.clone()
button.move(30,50)
button.draw(win)
button2 = mouth.clone()
button2.move(30,80)
button2.draw(win)
button3 = mouth.clone()
button3.move(30,110)
button3.draw(win)
leftarm = Line(Point(50,100),Point(125,125))
leftarm.setFill("brown")
leftarm.setWidth(2)
leftarm.move(18,60)
leftarm.draw(win)
rightarm = Line(Point(50,-45),Point(125,-80))
rightarm.setFill("brown")
rightarm.setWidth(2)
rightarm.move(205,225)
rightarm.draw(win)
snow = Circle(Point(100,100), 2)
snow.setFill("white")
snow.setOutline("white")
snow.draw(win)
snow2 = snow.clone()
snow2.move(200,100)
snow2.draw(win)
snow3 = snow.clone()
snow3.move(250,150)
snow3.draw(win)
snow4 = snow.clone()
snow4.move(200,200)
snow4.draw(win)
snow5 = snow.clone()
snow5.move(150,50)
snow5.draw(win)
snow6 = snow.clone()
snow6.move(25,100)
snow6.draw(win)
snow7 = snow.clone()
snow7.move(-15,50)
snow7.draw(win)
snow8 = snow.clone()
snow8.move(-60,-20)
snow8.draw(win)
snow9 = snow.clone()
snow9.move(-40,-70)
snow9.draw(win)
snow10 = snow.clone()
snow10.move(275,30)
snow10.draw(win)
snow11 = snow.clone()
snow11.move(230,-5)
snow11.draw(win)
snow12 = snow.clone()
snow12.move(190,-50)
snow12.draw(win)
snow13 = snow.clone()
snow13.move(50,-70)
snow13.draw(win)
snow14 = snow.clone()
snow14.move(-40,250)
snow14.draw(win)
snow15 = snow.clone()
snow15.move(-70,150)
snow15.draw(win)
win.getMouse()
win.close()
main()
Thank you for any help!!