Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from visual import *
- ball = sphere(pos=(-5,0,0), radius=r, color=color.red)
- wallR = box(pos=(6,0,0), size=(0.2,12,12), color=color.green)
- wallL = box(pos=(-6,0,0), size=(0.2,12,12), color=color.green)
- wallT = box(pos=(0,6,0), size=(12,0.2,12), color=color.blue)
- wallB = box(pos=(0,-6,0), size=(12,0.2,12), color=color.blue)
- dt = 0.05
- ball.velocity = vector(2,1.5,0)
- while 1:
- rate(100)
- ball.pos = ball.pos + ball.velocity*dt
- rate(100)
- ball.pos = ball.pos + ball.velocity*dt
- if not (wallL.x+0.5 < ball.x < wallR.x-0.5):
- ball.velocity.x = -ball.velocity.x
- if not (wallB.y+0.5 < ball.y < wallT.y-0.5):
- ball.velocity.y = -ball.velocity.y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement