Apr
28
3D Ball Collision in Python with Visual Module.
I only compute the collision between bed and blue one. They're bola[1] and bola[2] respectively
from visual import * from random import uniform,random from visual.controls import * def change(): global jalan if b.value: jalan = True for ball in(bola): ball.vx = uniform(-7,7) ball.vy = uniform(-7,7) ball.vz = uniform(-7,7) else: jalan = False c = controls(title='Tempat Tombol',x=800, y=0, width=300, height=300, range=50) b = toggle( pos=(0,0), width=20, height=20, text='Click me', action=lambda: change() ) display(center=(0,0,0),background=(1,1,1), #autoscale=False, width=600, height=600, forward=(-0.4,-0.3,-1)) #arah kamera g = -1. dt = .1 e = 1. b.value = True jalan = True l = 17.
from visual import * from random import uniform,random from visual.controls import * def change(): global jalan if b.value: jalan = True for ball in(bola): ball.vx = uniform(-7,7) ball.vy = uniform(-7,7) ball.vz = uniform(-7,7) else: jalan = False c = controls(title='Tempat Tombol',x=800, y=0, width=300, height=300, range=50) b = toggle( pos=(0,0), width=20, height=20, text='Click me', action=lambda: change() ) display(center=(0,0,0),background=(1,1,1), #autoscale=False, width=600, height=600, forward=(-0.4,-0.3,-1)) #arah kamera g = -1. dt = .1 e = 1. b.value = True jalan = True l = 17.