from visual import *


scene2 = display(title='Graph of position', width=600, height=200, center=(5,0,0), range=(10,10,10))

ball = sphere (pos=(8,0,0), radius=0.5, color=color.yellow)

border1 = box (pos=(5,2.5,0), length=9, height=0.2, width=0.5, color=color.green)
border2 = box (pos=(5,-2.5,0), length=9, height=0.2, width=0.5, color=color.green)
rac1 = box (pos=(10,0,0), length=0.5, height=2, width=0.5, color=color.blue)
rac2 = box (pos=(0,0,0), length=0.5, height=2, width=0.5, color=color.blue)

dt = 0.01
ball.velocity = vector(-4,-2,0)

while 1:
	rate(100)
	ball.pos = ball.pos + ball.velocity*dt
	if ball.x < 0.8:
		ball.velocity = rotate (ball.velocity, angle=math.pi/2, axis=(0,0,1))
	if ball.x > 9.2:
		ball.velocity = rotate (ball.velocity, angle=math.pi/2, axis=(0,0,1))
	if ball.y > 2:
		ball.velocity = rotate (ball.velocity, angle=math.pi/4, axis=(1,0,0))
	if ball.y < -2:
		ball.velocity = rotate (ball.velocity, angle=math.pi/4, axis=(1,0,0))
	rac1.y = ball.y
	rac2.y = ball.y

