# Problem 2, HWK 3, PHY307 Fall 2002 # Race a yellow sphere, blue ring and white cube. Staggered by # a distance of 2 in the z direction, they breathtakingly race to the # right. # # The 3 objects are intially created, then their positions are # changed by adding a small amount to each objects' x position # in a loop, whose rate is controlled by the rate() statement. from visual import * racer1 = sphere(color=color.yellow, z=0) racer2 = ring(color=color.blue, z=2) racer3 = box(color=color.white,z=4) # for bonus kicks, draw a starting line startline = cylinder(axis=(0,0,4),radius=0.1,color=color.red) # prevent autoscaling, so that motion can be seen more cleanly scene.autoscale=0 while 1: rate(40) racer1.x = racer1.x + 0.01 racer2.x = racer2.x + 0.015 racer3.x = racer3.x + 0.02