I want to be able to bounce the ball on the screen but when I run the code the ball moves of frame. I have attached a file of the code down below. Here's the code I have so far:
import time import random from graphics import * def main(): window_width=600 window_length=700 dx= int(1) dy= int(1) win= GraphWin("shapes", window_width, window_length) center= Point(dx,dy) circ= Circle(center, 30) circ.setFill('red') circ.draw(win) for i in range(100): dx1=random.randint(1,155) dy2=random.randint(1,155) dx+=dx1 dy+=dy2 if dx > window_width or dx <0: dx =1 if dy > window_length or dy<0: dy=1 circ.move(dx,dy) time.sleep(3) buran write Nov-15-2025, 07:23 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
