Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from visual import *
  2. ball = sphere(pos=(-5,0,0), radius=r, color=color.red)
  3. wallR = box(pos=(6,0,0), size=(0.2,12,12), color=color.green)
  4. wallL = box(pos=(-6,0,0), size=(0.2,12,12), color=color.green)
  5. wallT = box(pos=(0,6,0), size=(12,0.2,12), color=color.blue)
  6. wallB = box(pos=(0,-6,0), size=(12,0.2,12), color=color.blue)
  7. dt = 0.05
  8. ball.velocity = vector(2,1.5,0)
  9. while 1:
  10. rate(100)
  11. ball.pos = ball.pos + ball.velocity*dt
  12. rate(100)
  13. ball.pos = ball.pos + ball.velocity*dt
  14. if not (wallL.x+0.5 < ball.x < wallR.x-0.5):
  15. ball.velocity.x = -ball.velocity.x
  16. if not (wallB.y+0.5 < ball.y < wallT.y-0.5):
  17. ball.velocity.y = -ball.velocity.y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement