0

Need to have balls moved when touched using getmouse() also need an if then statement when ball is clicked to have it moved

3
Contributors
5
Replies
33
Views
1 Year
Discussion Span
Last Post by Schol-R-LEA
Featured Replies
  • 1

    What happens when you try to run it? (BTW, there seems to have been some kind of problem when you pasted the code, but don't worry, it isn't hard to see to tell what the code actually is. These things happen.) Read More

  • 1

    That was the one I was thinking it might be, but I was hoping the OP could confirm this. Read More

0

heres the code
from graphics import *
import time

def main():

    win = GraphWin('Dribbling', 400, 450)
    from graphics import *

import time

def main():
    win = GraphWin('Dribbling', 400, 450)
    win.setBackground ("white")

    cir1 =Point( win.getmouse(), 40).draw(win)


    cir1 = Circle(Point(40,100), 25)
    cir1.setFill("blue")
    cir1.draw(win)

    cir2 = Circle(Point(150,125), 25)
    cir2.setFill("yellow")
    cir2.draw(win)

    for i in range(50):
        cir1.move(0, 5)
        time.sleep(.05)

    for i in range(50):
        cir1.move(0, -5)
        time.sleep(.05)

    for i in range(50):
        cir2.move(0,5)
        time.sleep(.05)

    for i in range(50):
        cir2.move(0,-5)
        time.sleep(.05)

main()



win.setBackground ("white")

cir1 =Point( win.getmouse(), 40).draw(win)


cir1 = Circle(Point(40,100), 25)
cir1.setFill("blue")
cir1.draw(win)

cir2 = Circle(Point(150,125), 25)
cir2.setFill("yellow")
cir2.draw(win)

for i in range(50):
    cir1.move(0, 5)
    time.sleep(.05)

for i in range(50):
    cir1.move(0, -5)
    time.sleep(.05)

for i in range(50):
    cir2.move(0,5)
    time.sleep(.05)

for i in range(50):
    cir2.move(0,-5)
    time.sleep(.05)

main()

1

What happens when you try to run it?

(BTW, there seems to have been some kind of problem when you pasted the code, but don't worry, it isn't hard to see to tell what the code actually is. These things happen.)

0

Oh, I forgot to add that the graphics module you are using is not part of the Python standard library; I have a pretty good guess as to which one you are using, but I'm not certain. Do you know which it is?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.