# Lab 4: while_loop4.py
# sphere moving towards wall
# Written by: Your Name
from __future__ import division
from visual import *
ball = sphere(pos=vector(-5,0,0), radius=0.5, color=color.red)
wallR = box(pos= vector (6,0,0), size= (2,4,8), color=color.green)
vball = vector(1.5,0,0) # vector vball represents the velocity of ball
t = 0 # variable t represents time
deltat = 1 # variable deltat represents the time step, the amount
# of time elapsed for each iteration of the loop
while ball.pos.x < wallR.x:
rate(2)
print "position at time", t, "is:", ball.pos
# update the position of ball using vector operations
ball.pos = ball.pos + vball*deltat
vball.x = vball.x + 1 # increase velocity of ball
t = t + deltat # update time
print "finished at time", t, "with position", ball.pos