# Fetch key presses mykeys = pi3d.key() mymouse = pi3d.mouse() mymouse.start() omx=mymouse.x omy=mymouse.y # Display scene and rotate cuboid while 1: display.clear() pi3d.identity() pi3d.rotate(tilt,0,0) pi3d.rotate(0,rot,0) pi3d.position(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
# Fetch key presses mykeys = pi3d.key() # mastrix and rotate variables rot=0 #create a light mylight = pi3d.createLight(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() pi3d.identity() pi3d.position(0,0,-40) pi3d.rotate(0,rot,0) rot += 3 mymodel.draw() k = mykeys.read() if k >-1: if k==112: display.screenshot("Triceratops.jpg") elif k==27: mykeys.close() texs.deleteAll() display.destroy() break else: print k
import pi3d # Setup display and initialise pi3d display = pi3d.display() display.create3D(100,100,1200,900) # x,y,width,height display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha # load model_loadmodel mymodel = pi3d.loadModel("models/teapot.egg","teapot", 0,-1,0) # Fetch key presses mykeys = pi3d.key() # rotate variable rot=0 #create a light mylight = pi3d.createLight(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() pi3d.identity() pi3d.position(0,0,-10) pi3d.rotate(0,rot,0) rot += 3 mymodel.draw() display.swapBuffers()
drx, dry, drz = 0, 0, 0 max_speed = 0.1 # Fetch key presses mykeys = pi3d.key() mymouse = pi3d.mouse() mymouse.start() omx=mymouse.x omy=mymouse.y while 1: display.clear() pi3d.identity() pi3d.position(xm,-2+ym-mapheight,-maphalf+2) myecube.draw(ectex,xm,ym,zm) mymap.draw(groundimg) monster.draw(monstimg) ball.draw(groundimg) #monster movement drx = sx - rx if abs(drx) > max_speed: drx = drx/abs(drx) * max_speed dry = sy - ry if abs(dry) > max_speed: dry = dry/abs(dry) * max_speed rx += drx ry += dry
def set_view(self): '''Set up camera transformation before drawing''' pi3d.identity() pi3d.rotate(self.tilt, 0, 0) pi3d.rotate(0, self.rot, 0) pi3d.position(self.x, self.y, self.z)