1

I'm very new to using python and trying to start on my final project for an intro to computing class. I'm using the Zelle graphics module to try to create a python game. I have created a face using the graphics module, and I want to clone this face and have the cloned version moved 50 spaces to the right. I have imported time in order to move the objects.

Here is the code in question:

from graphics import *

import time

def main(): win = GraphWin("Guess the Faces", 1000, 500) win.yUp() win.setBackground(color_rgb(20, 20, 20))

def robotFaces():
    robot1 = Rectangle(Point(25, 350), Point(100, 425))
    robot1.setOutline(color_rgb(0, 0, 0))
    robot1.setFill(color_rgb(180, 180, 180))
    robot1.draw(win)
    r1eye1 = Rectangle(Point(35, 390), Point(55, 415))
    r1eye1.setOutline(color_rgb(0, 0, 0))
    r1eye1.setFill(color_rgb(255, 255, 255))
    r1eye1.draw(win)
    r1eye2 = Rectangle(Point(70, 390), Point(90, 415))
    r1eye2.setOutline(color_rgb(0, 0, 0))
    r1eye2.setFill(color_rgb(255, 255, 255))
    r1eye2.draw(win)
    r1pupil1 = Rectangle(Point(42, 390), Point(48, 408))
    r1pupil1.setFill(color_rgb(0, 0, 0))
    r1pupil1.draw(win)
    r1pupil2 = Rectangle(Point(77, 390), Point(83, 408))
    r1pupil2.setFill(color_rgb(0, 0, 0))
    r1pupil2.draw(win)
    r1mouth = Polygon(Point(35, 360), 
        Point(90, 360), 
        Point(90, 370), 
        Point(85, 370), 
        Point(85, 365), 
        Point(40, 365), 
        Point(40, 370), 
        Point(35, 370))
    r1mouth.setFill(color_rgb(255, 255, 255))
    r1mouth.setOutline(color_rgb(0, 0, 0))
    r1mouth.draw(win)

    robot2 = robot1.clone
    robot2.move(50, 0)
    robot2.draw(win)
    r2eye1 = r1eye1.clone
    r2eye1.move(50, 0)
    r2eye1.draw(win)
    r2eye2 = r1eye2.clone
    r2eye2.move(50, 0)
    r2eye2.draw(win)
    r2pupil1 = r1pupil1.clone
    r2pupil1.move(50, 0)
    r2pupil1.draw(win)
    r2pupil2 = r1pupil2.clone
    r2pupil2.move(50, 0)
    r2pupil2.draw(win)
    r2mouth = r1mouth.clone 
    r2mouth.move(50, 0)
    r2mouth.draw(win)

robotFaces()

win.getMouse()
win.promptClose(win.getWidth()/2, 10)

main()

I expect there to be a second robot face, 50 spaces to the right of the original one. What actually happens is I get this attribute error:

AttributeError: 'function' object has no attribute 'move'

Is there something else I need to do to make the object movable?

2
  • use button {} to correctly format code instead of using ` or ``` Commented Dec 7, 2017 at 16:07
  • always put full error message (Traceback) in question (as text, not screenshot). There are other useful informations. Commented Dec 7, 2017 at 16:09

1 Answer 1

1

You didn't call the clone method.

robot2 = robot1.clone()

In future, please cut down your code to the minimum necessary to demonstrate the problem, and post the full traceback.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.