From 3a8d3bb4de9d46d23fb97ef0ea8f2ea28d3c4e33 Mon Sep 17 00:00:00 2001
From: Rajesh Gupta N <cb.en.u4cse16238@cb.students.amrita.edu>
Date: Wed, 2 Jan 2019 13:01:56 +0530
Subject: [PATCH] Upload New File

---
 cse16238_lab4.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 cse16238_lab4.py

diff --git a/cse16238_lab4.py b/cse16238_lab4.py
new file mode 100644
index 0000000..96c345e
--- /dev/null
+++ b/cse16238_lab4.py
@@ -0,0 +1,46 @@
+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) 
+wallT = box(pos=vector(0,6,0), size=vector(12,0.2,12), color=color.blue)
+wallB = box(pos=vector(0,-6,0), size=vector(12,0.2,12), color=color.blue)
+wallBa = box(pos=vector(0,0,-6), size=vector(12,12,0.2), color=color.red)
+ball.velocity = vector(5,5,0)
+deltat = 0.005  
+t = 0  
+#ball.pos = ball.pos + ball.velocity*deltat 
+vscale = 0.1  
+varr = arrow(pos=ball.pos, axis=vscale*ball.velocity, color=color.yellow) 
+
+
+
+
+while t >= 0:     
+    rate(100)
+    if ball.pos.x > wallR.pos.x or ball.pos.x < wallL.pos.x: 
+       # ball.velocity.x = -ball.velocity.x  
+        print("game over")
+        break
+    if ball.pos.y > wallT.pos.y or ball.pos.y < wallB.pos.y: 
+        #ball.velocity.y = -ball.velocity.y
+        print("game over")
+        break
+    if ball.pos.z < wallBa.pos.z:
+        #ball.velocity.z = -ball.velocity.z
+    #ball.pos = ball.pos + ball.velocity*deltat 
+    varr.pos = ball.pos
+    varr.axis = vscale*ball.velocity
+    t=t+deltat
+
+def onpress(event):
+    s=event.key
+    if s='up':
+        ball.velocity.y+=1
+    else if s='down':
+        ball.velocity.y-=1
+    else if s='left':
+        ball.velocity.x-=1
+    else if s='right':
+        ball.velocity.x+=1
+scene.bind('keydown',onpress)
\ No newline at end of file
-- 
GitLab