Skip to content
Snippets Groups Projects
Commit 653e8899 authored by Velaga Abijith's avatar Velaga Abijith
Browse files

creation of the maze

parent dac2a9d8
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=0.5,
color=color.cyan, make_trail=True)
wallR = 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)
wallU = box(pos=vector(0,6,0), size=vector(12,0.2,12), color=color.green)
wallD = box(pos=vector(0,-6,0), size=vector(12,0.2,12), color=color.green)
wallB = box(pos=vector(0,0,-6), size=vector(12,12,0.2), color=color.green)
#wallF = box(pos=vector(0,0,6), size=vector(12,12,0.2), color=color.green)
ball.velocity = vector(25,5,10)
deltat = 0.005
t = 0
ev=scene.waitfor('keydown')
ball.pos = ball.pos + ball.velocity*deltat
vscale = 0.1
varr = arrow(pos=ball.pos, axis=vscale*ball.velocity, color=color.yellow)
#scene.autoscale = False
while t < 3:
rate(100)
if ball.pos.x > wallR.pos.x or ball.pos.x<wallL.pos.x:
ball.velocity.x = -ball.velocity.x
if ball.pos.y > wallU.pos.y or ball.pos.y<wallD.pos.y:
ball.velocity.y = -ball.velocity.y
if ball.pos.z<wallB.pos.z:
ball.velocity.z = -ball.velocity.z
ball.pos = ball.pos + ball.velocity*deltat
varr.axis=vscale*ball.velocity
varr.pos=ball.pos
t = t + deltat
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment