Skip to content
Snippets Groups Projects
Commit 049e89c1 authored by SREERAM KEERTHAN PARUCHURU's avatar SREERAM KEERTHAN PARUCHURU
Browse files

partial one

parent 1c6342d3
No related branches found
No related tags found
No related merge requests found
from vpython import *
#GlowScript 2.7 VPython
ball = sphere(pos=vector(-5,0,0),radius=1,color=color.red,make_trail=True)
wall = box(pos=vector(6,0,0),size=vector(0.2,12,12),color=color.green)
wallL= box(pos=vector(-6,0,0),size=vector(0.2,12,12),color=color.green)
wall1 =box(pos=vector(0,6,0),size=vector(-12,0,12),color=color.green)
wall2 =box(pos=vector(0,-6,0),size=vector(-12,0,12),color=color.green)
vscale=0.1
ball.velocity=vector(25,3,0)
varr=arrow(pos=ball.pos,axis=vscale*ball.velocity,color=color.yellow)
delta=0.005
t=0
while(t>=0):
rate(100)
if(ball.pos.y>wall1.pos.y):
ball.color=color.white
ball.velocity.x=-ball.velocity.x
ball.velocity.y=-ball.velocity.y
varr.axis=ball.velocity*vscale
ball.pos=ball.pos+(ball.velocity*(delta))
varr.pos=varr.pos+(ball.velocity*(delta))
t=t+delta
if(ball.pos.x==wall.pos.x):
ball.velocity.x=-ball.velocity.x
varr.axis=ball.velocity*vscale
ball.pos=ball.pos+(ball.velocity*(delta))
varr.pos=varr.pos+(ball.velocity*(delta))
t=t+delta
else if(ball.pos.x==wallL.pos.x):
ball.velocity.x=-ball.velocity.x
varr.axis=ball.velocity*vscale
ball.pos=ball.pos+(ball.velocity*(delta))
varr.pos=varr.pos+(ball.velocity*(delta))
t=t+delta
else:
ball.pos=ball.pos+ball.velocity*delta
varr.pos=varr.pos+(ball.velocity*(delta))
t=t+delta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment