from vpython import *
#GlowScript 2.7 VPython
ball = sphere(pos=vector(-5,0,0), radius=2.5,color=color.green)  
wallR = box(pos=vector(6,0,0), size=vector(0.2,12,12), color=color.blue) 
ball.velocity = vector(25,0,0)  
deltat = 0.005  
t = 0  
ball.pos = ball.pos + ball.velocity*deltat 
wallL = box(pos=ball.pos, size=vector(0.2,12,12), color=color.red) 
ball.velocity = vector(25,5,0)
vscale = 0.1
varr = arrow(pos=ball.pos, axis=vscale*ball.velocity, color=color.yellow)
while t < 3: 
    rate(100) 
    if ball.pos.x > wallR.pos.x: 
        ball.velocity.x = -ball.velocity.x  
    ball.pos = ball.pos + ball.velocity*deltat
    t = t + deltat 
wallL = box(pos=ball.pos, size=vector(0.2,12,12), color=color.red)