Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99994
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-12-03 20:19 -0800 |
| Message-ID | <ee38a39b-5d03-4715-b9d8-23ca24e91866@googlegroups.com> (permalink) |
| Subject | How to bounce the ball forever around the screen |
| From | phamtony33@gmail.com |
from Tkinter import *
window = Tk()
canvas = Canvas(window, width=500, height=500, background="green")
canvas.pack()
def move_ball(speed_x, speed_y):
box = canvas.bbox("ball")
x1 = box[0]
y1 = box[1]
x2 = box[2]
y2 = box[3]
if x1 <= 0:
speed_x = 0
speed_y = 0
canvas.move("ball", speed_x, speed_y)
canvas.after(30, move_ball, speed_x, speed_y)
canvas.create_oval(225, 225, 275, 275, fill="blue", tags="ball")
move_ball(-10, 7)
mainloop()
where in the code should i change to make the ball bounce around forever. is it the x and y?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
How to bounce the ball forever around the screen phamtony33@gmail.com - 2015-12-03 20:19 -0800 Re: How to bounce the ball forever around the screen Peter Otten <__peter__@web.de> - 2015-12-04 09:09 +0100
csiph-web