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 tilt -= (my-omy)*0.2 omx=mx omy=my #Press ESCAPE to terminate k = mykeys.read()
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() mx=mymouse.x my=mymouse.y #if mx>display.left and mx<display.right and my>display.top and my<display.bottom:
# 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(landimg) #myclip.enable() #mymap2.draw(surface1) #myclip.disable() 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 tilt -= (my-omy)*0.2 omx=mx omy=my #Press ESCAPE to terminate k = mykeys.read() if k >-1:
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) mDx -= 0.01*mDelx/mDist mDz -= 0.01*mDelz/mDist monst.rotateIncY(100.0/mDist) if mDist > 100: #far away so teleport it nearer mSx, mSz = -xm + 100*random.random() - 50, -zm + 100*random.random() - 50 if mSx < -mapwidth/2: mSx = -mapwidth/2 if mSx > mapwidth/2: mSx = mapwidth/2 if mSz < -mapdepth/2: mSz = -mapdepth/2