from visual import * ball = sphere(pos=(-5,0,0), radius = 0.5, color=color.cyan) 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) wallU = box(pos=(0,6,0),size=(12, 0.2, 12), color=color.red) wallD = box(pos=(0,-6,0),size=(12,0.2, 12), color=color.red) wallF = box(pos=(0,0,-6),size=(12,12,0.2), color=color.white) ball.velocity=vector(20,5,-7) vscale=0.1 varr = arrow(pos=ball.pos, axis=ball.velocity*vscale, color = color.yellow) ball.trail = curve(color = ball.color) deltat=0.005 t=0 scene.autoscale = False while True: rate(100) if ball.pos.x > wallR.pos.x or ball.pos.x < wallL.pos.x: ball.velocity.x = -ball.velocity.x if ball.pos.y > wallU.pos.y or ball.pos.y < wallD.pos.y: ball.velocity.y = -ball.velocity.y if ball.pos.z > 6 or ball.pos.z < wallF.pos.z: ball.velocity.z = -ball.velocity.z ball.pos = ball.pos + ball.velocity*deltat ball.trail.append(pos=ball.pos) t = t + deltat