diff --git a/Prannesh16231_BallBounce.py b/Prannesh16231_BallBounce.py new file mode 100644 index 0000000000000000000000000000000000000000..5124fbff2d3fbf8c0a14c1e8c0ddd650d3eb51bf --- /dev/null +++ b/Prannesh16231_BallBounce.py @@ -0,0 +1,19 @@ +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) \ No newline at end of file