From 7cb1ba8a02672da570bc0b172ba4fa707fd2ceed Mon Sep 17 00:00:00 2001 From: Prannesh SathyaMoorthy <cb.en.u4cse16231@cb.students.amrita.edu> Date: Wed, 2 Jan 2019 12:58:28 +0530 Subject: [PATCH] Upload New File --- Prannesh16231_BallBounce.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Prannesh16231_BallBounce.py diff --git a/Prannesh16231_BallBounce.py b/Prannesh16231_BallBounce.py new file mode 100644 index 0000000..5124fbf --- /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 -- GitLab