ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==115: #kry S xm+=math.sin(math.radians(rot)) zm-=math.cos(math.radians(rot)) ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==39: #key ' tilt -= 2.0 print tilt elif k==47: #key / tilt += 2.0 elif k==97: #key A rot -= 2 elif k==100: #key D rot += 2 elif k==112: #key P display.screenshot("forestWalk"+str(scshots)+".jpg") scshots += 1 elif k==10: #key RETURN mc = 0 elif k==27: #Escape key mykeys.close() mymouse.stop() texs.deleteAll() display.destroy() break else: print k display.swapBuffers() quit()
# mastrix and rotate variables rot=0 #create a light mylight = Light(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() Utility.load_identity() Utility.translatef(0,0, -40) Utility.rotatef(rot, 0, 1, 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 display.swapBuffers()
mykeys = Keyboard() # setup matrices mtrx = Matrix() #create a light mylight = Light(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() mtrx.identity() mtrx.translate(0,0,-10) mymodel.draw() mymodel.rotateIncY(3.0) k = mykeys.read() if k >-1: if k==112: display.screenshot("teapot.jpg") elif k==27: mykeys.close() texs.deleteAll() display.destroy() break else: print k display.swapBuffers()
ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==115: #kry S xm+=math.sin(math.radians(rot)) zm-=math.cos(math.radians(rot)) ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==39: #key ' tilt -= 2.0 print tilt elif k==47: #key / tilt += 2.0 elif k==97: #key A rot -= 2 elif k==100: #key D rot += 2 elif k==112: #key P display.screenshot("ForestWalk2.jpg") elif k==10: #key RETURN mc = 0 elif k==27: #Escape key mymouse.stop() mykeys.close() texs.deleteAll() display.destroy() break else: print k display.swapBuffers() quit()
mtrx.rotate(0, rot, 0) #Utility.translatef(xm, ym, zm) myecube.draw(ectex, 0.0, 0.0, 0.0) 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: if k==112: #key P display.screenshot("envcube.jpg") elif k==27: #Escape key mykeys.close() mymouse.stop() texs.deleteAll() display.destroy() break else: print k display.swapBuffers() quit()
for b in range (0, pino): xyz.append((random.random()*8-4,random.random() * 8,random.random() * 4 + 3, random.random() * 360)) # Fetch key presses mykeys = Keyboard() # Display scene and rotate cuboid while 1: display.clear() for b in range (0, pino): Draw.sprite(raspimg,xyz[b][0],5-xyz[b][1],-xyz[b][2],1,1,xyz[b][3]) #draw a rectangle(x,y,z,scaleX,scaleY,rotation) r = xyz[b][3]+1 y = (xyz[b][1]+0.1) % 10 if y<0.06: xyz[b] = ((random.random()*8-4, y, xyz[b][2], r)) else: xyz[b] = ((xyz[b][0], y, xyz[b][2], r)) k = mykeys.read() if k >-1: if k==27: mykeys.close() texs.deleteAll() display.destroy() break elif k==112: display.screenshot("raspberryRain.jpg") display.swapBuffers()
if k >-1: if k==119: #key W xm-=math.sin(math.radians(rot)) zm+=math.cos(math.radians(rot)) ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==115: #kry S xm+=math.sin(math.radians(rot)) zm-=math.cos(math.radians(rot)) ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==39: #key ' tilt -= 2.0 print tilt elif k==47: #key / tilt += 2.0 elif k==97: #key A rot -= 2 elif k==100: #key D rot += 2 elif k==112: #key P display.screenshot("walkaboutRobot.jpg") elif k==27: #Escape key mykeys.close() mymouse.stop() texs.deleteAll() display.destroy() break else: print k display.swapBuffers()
maxdsz += 0.01 # max speed in z direction increases too sx, sy, sz = 0, mapheight/3, 0 dsx, dsy, dsz = 0.3*random.random()-0.15, 0, -0.1 ball.position(sx, sy, sz) ball.rotateIncX(dsz/radius*50) monster.draw(monstimg) ball.draw(ballimg) # write up the score Draw.string(arialFont, str(score[0]), -10, 20, -5, 0.0, 0.05, 0.05) Draw.string(arialFont, str(score[1]), 10, 20, -5, 0.0, 0.05, 0.05) display.swapBuffers() #Press ESCAPE to terminate k = mykeys.read() if k==27: #Escape key display.destroy() mykeys.close() mymouse.stop() break elif k==112: #key P display.screenshot("pong.jpg") # attempt to tidy up! quit()
#dx = -math.sin(rot*rads) #dz = math.cos(rot*rads) #dy = -(mymap.calcHeight(xm + dx*1.5, zm + dz*1.5) + avhgt) - ym #if dy > -1.0: # remember camera locations all work in reverse!! # xm, ym, zm = xm + dx, ym + dy, zm + dz elif k==115: #kry S xm+=math.sin(rot*rads) zm-=math.cos(rot*rads) ym = -(mymap.calcHeight(xm,zm)+avhgt) elif k==39: #key ' tilt -= 2.0 print tilt elif k==47: #key / tilt += 2.0 elif k==97: #key A rot -= 2 elif k==100: #key D rot += 2 elif k==112: #key P display.screenshot("Piom.jpg") elif k==27: #Escape key mykeys.close() texs.deleteAll() display.destroy() break else: print k display.swapBuffers()
mytcone.rotateIncY(2) mytcone.rotateIncZ(-1) mytorus.draw(patimg) mytorus.rotateIncY(3) mytorus.rotateIncZ(1) mylathe.draw(patimg) mylathe.rotateIncY(2) mylathe.rotateIncZ(1) myPlane.draw(coffimg) myPlane.rotateIncY(9) Draw.string(arialFont, "Raspberry Pi ROCKS!", -0.8, -0.7, -2.2, 10.0, 0.003, 0.003) #pi3d.drawString(destineFont,"Some nice OpenGL bitmap fonts to play with",-1.3,-0.3,-2.2, 10.0, 0.002,0.002) k = mykeys.read() if k >-1: if k==112: display.screenshot("shapesPic.jpg") elif k==27: mykeys.close() texs.deleteAll() display.destroy() break else: print k display.swapBuffers()
myplane.rotateIncZ(0.01) mysphere.draw(earthimg) mysphere.rotateIncY(0.1) mysphere2.draw(cloudimg) mysphere2.rotateIncY(.15) mymoon.draw(moonimg) mymoon.position(mysphere.x+m1Rad*sin(rot1),mysphere.y+0,mysphere.z-m1Rad*cos(rot1)) mymoon.rotateIncY(0.2) mymoon2.draw(watimg) mymoon2.position(mymoon.x+m2Rad*sin(rot2),mymoon.y+0,mymoon.z-m2Rad*cos(rot2)) mymoon2.rotateIncY(3) rot1 -= 0.005 rot2 -= 0.021 k = mykeys.read() if k >-1: if k==112: display.screenshot("earthPic.jpg") elif k==27: mykeys.close() texs.deleteAll() display.destroy() break else: print k display.swapBuffers()
if k >-1: if k==119: #key W xm-=math.sin(math.radians(rot)) zm+=math.cos(math.radians(rot)) elif k==115: #kry S xm+=math.sin(math.radians(rot)) zm-=math.cos(math.radians(rot)) elif k==39: #key ' tilt -= 2.0 print tilt elif k==47: #key / tilt += 2.0 elif k==97: #key A rot -= 2 elif k==100: #key D rot += 2 elif k==112: #key P display.screenshot("BuckfastAbbey"+str(scshots)+".jpg") scshots += 1 elif k==27: #Escape key mykeys.close() mymouse.stop() texs.deleteAll() display.destroy() break else: print k display.swapBuffers() quit()
if (xm < -490 or xm > 490 or zm < -490 or zm > 490): fly = True #reached the edge of the maze! #key press ESCAPE to terminate k = mykeys.read() if k >-1: if k==119: #key W toggle NB no longer need to hold down all the time walk = not(walk) elif k==115: #kry S walk = False dy = -(mymap.calcHeight(xm - dx, zm - dz)+avhgt) - ym if dy > -1.0: xm -= dx zm -= dz ym += dy elif k==112: #key P display.screenshot("critters3D"+str(scshots)+".jpg") scshots += 1 elif k==32 and hp > 0: #key SPACE walk = False dy = -(mymap.calcHeight(xm + dx, zm + dz)+avhgt) - ym xm += dx zm += dz ym += dy hp -= 1 elif k==102: #f key to fire missile.fire(xm, ym, zm, -dx, -math.sin(tilt*rads), -dz, 10) elif k==27: #Escape key display.destroy() mykeys.close() mymouse.stop() break