Beispiel #1
0
pino=10

# Setup array of random x,y,z coords and initial rotation
xyz=[]
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:
Beispiel #2
0
      score[0] += 1
      radius = 0.1 + (radius - 0.1)*0.75 # ball gets smaller each time you score
      ball = Sphere(radius,12,12,0.0,"sphere",0,0,0)
      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")
Beispiel #3
0
while True:

  display.clear()

  maxDepth = 0
  axDepthIndex = 0
  # this is easier to understand, the z position of each cloud is (only) held in cxyz[][2]
  # it stops the clouds appearing in front of nearer clouds!
  # first go through the clouds to find index of furthest away
  for i in range(len(cxyz)):
    cxyz[i][2] = (cxyz[i][2] - speed) % cloud_depth
    if (cxyz[i][2] > maxDepth):
      maxDepth = cxyz[i][2]
      maxDepthIndex = i

  # paint the clouds from background to foreground
  for i in range(maxDepthIndex, maxDepthIndex + cloudno):
    c = cxyz[i%cloudno]
    Draw.sprite(clouds[c[3]], c[0], c[1], -c[2], 8, 5)

  #Press ESCAPE to terminate
  if mykeys.read() == 27:
    mykeys.close()
    texs.deleteAll()
    display.destroy()
    break

  display.swapBuffers()
  time.sleep(0.01)
Beispiel #4
0
  mytcone.draw(coffimg)
  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()