def moveAll(shapeList, dx, dy): for shape in shapeList: shape.move(dx, dy) def moveAllOnLine(shapeList, dx, dy, repetitions, delay): for i in range(repetitions): moveAll(shapeList, dx, dy) time.sleep(delay) def makeFace(center, win): head = Circle(center, 25) head.setFill("yellow") head.draw(win) eye1Center = center.clone() eye1Center.move(-10, 5) eye1 = Circle(eye1Center, 5) eye1.setFill('blue') eye1.draw(win) eye2End1 = eye1Center.clone() eye2End1.move(15, 0) eye2End2 = eye2End1.clone() eye2End2.move(10, 0) eye2 = Line(eye2End1, eye2End2) eye2.setWidth(3) eye2.draw(win) mouthCorner1 = center.clone() mouthCorner1.move(-10, -10) mouthCorner2 = mouthCorner1.clone() mouthCorner2.move(20, -5) mouth = Oval(mouthCorner1, mouthCorner2) mouth.setFill("red") mouth.draw(win) return [head, eye1, eye2, mouth] def main(): winWidth = 300 winHeight = 300 win = GraphWin('Back and Forth', winWidth, winHeight) win.setCoords(0, 0, winWidth, winHeight) # make right side up coordinates! rect = Rectangle(Point(200, 90), Point(220, 100)) rect.setFill("blue") rect.draw(win) faceList = makeFace(Point(40, 100), win) #NEW faceList2 = makeFace(Point(150,125), win) #NEW stepsAcross = 46 #NEW section dx = 5 dy = 3 wait = .05 offScreenJump = winWidth*2 for i in range(3): moveAllOnLine(faceList, dx, 0, stepsAcross, wait) moveAll(faceList2, offScreenJump, 0) # face 2 jumps off the screen moveAllOnLine(faceList, -dx, dy, stepsAcross/2, wait) moveAll(faceList2, -offScreenJump, 0) # face 2 jumps back on screen moveAllOnLine(faceList, -dx, -dy, stepsAcross/2, wait) Text(Point(winWidth/2, 20), 'Click anywhere to quit.').draw(win)
Edited by Nick Evan: Added code-tags
Well, with the code you gave us, the star could look a lot like a face.