mtrx = Matrix() # Fetch key presses mykeys = Keyboard() mymouse = Mouse() mymouse.start() omx=mymouse.x omy=mymouse.y # Display scene and rotate cuboid while 1: display.clear() mtrx.identity() mtrx.rotate(tilt, 0, 0) mtrx.rotate(0, rot, 0) mtrx.translate(xm,ym,zm) myecube.draw(ectex,xm,ym,zm) mymap.draw(mountimg1) mygrass.drawAll(grassimg) mytrees1.drawAll(tree2img) mytrees2.drawAll(tree1img) mytrees3.drawAll(hb2img) mx=mymouse.x my=mymouse.y #if mx>display.left and mx<display.right and my>display.top and my<display.bottom: rot += (mx-omx)*0.2
xm=0.0 zm=0.0 ym= -avhgt #create a light mylight = Light(0,1,1,1,"",0,200,200,0.4,0.4,0.4) mtrx=Matrix() omx=mymouse.x omy=mymouse.y while 1: display.clear() mtrx.identity() mtrx.rotate(tilt, rot, 0) mtrx.translate(xm,ym,zm) mtrx.push() mtrx.rotate(0, 180, 0) myecube.draw(ectex,xm,ym,zm) mtrx.pop() mylight.on() mymodel.draw() mylight.off() mx=mymouse.x my=mymouse.y if mx>display.left and mx<display.right and my>display.top and my<display.bottom: rot += (mx-omx)*0.5
omx=mymouse.x omy=mymouse.y myfog = Fog(0.002,(0.3,0.8,0.6,0.5)) mylight = Light(0,1,1,1,"",10,10,10, .9,.7,.6) # Display scene and rotate cuboid while 1: display.clear() mtrx.identity() #tilt can be used as a means to prevent the view from going under the landscape! if tilt<-1: sf=1.0/-tilt else: sf=1.0 mtrx.translate(0,-10*sf-5.0,-40*sf) #zoom camera out so we can see our robot mtrx.rotate(tilt, 0, 0) #Robot still affected by scene tilt #draw robot mylight.on() robot.drawAll(metalimg) mylight.off() mtrx.rotate(0, rot, 0) #rotate rest of scene around robot mtrx.translate(xm,ym,zm) #translate rest of scene relative to robot position myecube.draw(ectex,xm,ym,zm)#Draw environment cube myfog.on() mymap.draw(mountimg1) #Draw the landscape station.drawAll(metalimg) myfog.off()
mymouse.start() omx=mymouse.x omy=mymouse.y fly = False walk = False # Display scene and rotate cuboid angle = 0 #################################################### LOOP ############################################### while 1: display.clear() camera.identity() camera.rotate(tilt,0,0) camera.rotate(0,rot,0) camera.translate(xm,ym,zm) myecube.draw(ectex,xm,ym,zm) myfog.on() mymap.draw(rockimg1) mymap2.draw(rockimg2) mytrees1.drawAll(tree2img) raspberry.drawAll(raspimg) monst.draw(monstimg) # monster movement mDy -= gravity mDelx,mDelz = mSx+xm, mSz+zm #distance from monster mDist = math.sqrt(mDelx**2 + mDelz**2)