You are on page 1of 1

# labl_challenge.

py
# Creating a basketball court
from __future__ import division
from visual import*
# Object Parameters
floor_size = vector(20, 0.5, 10)
center_court = vector(0, -5.25, 0)
post_dimensions = vector(0, 10, 0)
post_radius = 0.1
post_location = vector(10, 0, 0) + center_court
backboard_size = vector(0.1, 3, 3)
backboard_offset = vector(-backboard_size.x, 0, 0)
hoop_radius = 1
hoop_thickness = 0.05
hoop_offset = vector(-0.5*backboard_size.x-hoop_radius, -0.5*backboard_size.y, 0
)
net_length = hoop_radius
net_direction = vector(0,-1,0)
ball_location = vector(0,6,0) + center_court
ball_velocity = vector(3, 2, 0)
ball_size = 0.75
# Objects
floor = box(pos=center_court, color=color.orange, size=(floor_size))
post = cylinder(pos=post_location, color=color.blue, axis=(post_dimensions), rad
ius=(post_radius))
backboard = box(pos=post.pos + post.axis + backboard_offset, color=color.white,
size=(backboard_size))
hoop = cylinder(pos=backboard.pos + hoop_offset, color=color.red, axis=(-net_dir
ection*hoop_thickness), radius=(hoop_radius))
net = cylinder(pos=hoop.pos, color=color.cyan, axis=(net_length*net_direction),
radius=(hoop_radius-hoop_thickness))
ball = sphere(pos=ball_location, color=color.red, radius=(ball_size))
ball_v = arrow(pos=ball.pos, color=color.green, axis=(ball_velocity))