Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import simplegui
- import random
- xForce = random.randint(-10, 10)
- yForce = random.randint(-10, 10)
- print(xForce, yForce)
- py1 = 300
- py2 = 300
- size = 40
- bounce = True
- colors = ["Red", "Yellow", "Blue", "Green", "Orange", "Purple", "Black"]
- color = random.choice(colors)
- cx = 300
- cy = 300
- xSpeed = xForce
- ySpeed = yForce
- def draw_handler(canvas):
- global bounce
- global color
- global cx
- global cy
- global xSpeed
- global ySpeed
- cx += xSpeed
- cy += ySpeed
- canvas.draw_circle((cx, cy), 20, 5, color)
- canvas.draw_line((50, py1 + size), (50, py1 - size), 10, "Black")
- canvas.draw_line((550, py2 + size), (550, py2 - size), 10, "Black")
- frame = simplegui.create_frame('Testing', 600, 600)
- frame.set_canvas_background("White")
- frame.set_draw_handler(draw_handler)
- frame.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement