Beispiel #1
0
mymouse = Mouse(restrict = False)
mymouse.start()

omx, omy = mymouse.position()

CAMERA = Camera.instance()

# Display scene and rotate cuboid
while DISPLAY.loop_running():
  CAMERA.reset()
  CAMERA.rotate(tilt, rot, 0)
  CAMERA.position((xm, ym, zm))

  # for opaque objects it is more efficient to draw from near to far as the
  # shader will not calculate pixels already concealed by something nearer
  monolith.draw()
  mytrees1.draw()
  mytrees2.draw()
  mytrees3.draw()
  mymap.draw()
  myecube.draw()

  mx, my = mymouse.position()

  #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
Beispiel #2
0
        elif k == 112:  #key P
            screenshot("forestWalk" + str(scshots) + ".jpg")
            scshots += 1
        elif k == 10:  #key RETURN
            mc = 0
        elif k == 27:  #Escape key
            mykeys.close()
            mymouse.stop()
            DISPLAY.stop()
            break
        else:
            print(k)

    # for opaque objects it is more efficient to draw from near to far as the
    # shader will not calculate pixels already concealed by something nearer
    monolith.draw()
    mytrees1.draw()
    mytrees2.draw()
    mytrees3.draw()
    mymap.draw()
    myecube.draw()

    mx, my = mymouse.position()

    #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

    CAMERA.was_moved = False
Beispiel #3
0
            score0.set_shader(flatsh)
            radius = 0.1 + (
                radius - 0.1) * 0.75  # ball gets smaller each time you score
            ball = Sphere(camera, light, radius, 12, 12, 0.0, "sphere", 0, 0,
                          0)
            ball.buf[0].set_draw_details(shader, [ballimg], 0.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)

    defocus.start_blur()
    ball.draw()
    mymap.draw()
    myecube.draw()
    defocus.end_blur()

    defocus.blur(ball, 4, 15, 2)
    defocus.blur(mymap, 4, 15, 2)
    defocus.blur(myecube, 4, 15, 2)

    monster.draw()

    # write up the score
    score0.draw()
    score1.draw()

    camera.was_moved = False
Beispiel #4
0
    if (sx-rx)**2 + (sy-ry)**2 < 10:
      dsz = abs(dsz)
    else:
      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
Beispiel #5
0
#############################################################################################

while 1:
  display.clear()
  
  camera.identity()
  camera.rotate(tilt, 0, 0) ####################
  camera.rotate(0, rot, 0) ####################
  #camera.translate(xm,-2+ym-mapheight,-maphalf+2)
  # I think you want to walk around inside your map so need xm, ym and zm (like ForestWalk etc)
  camera.translate(xm, ym, zm) ###################
  
  myecube.draw(ectex,xm,ym,zm)
  mymap.draw(groundimg)
  
  ball.draw(monstimg)
  
  ###################### you haven't got a monster, you are using ball instead
  """
  #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
  
  monster.position(rx, ry, -maphalf)
  """
  
  dsy -= gravity
Beispiel #6
0
arialFont = Font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
destineFont = Font("AR_Destine", "#0055ff")


# Fetch key presses
mykeys = Keyboard()

#create a light
mylight = Light(0, 2,2,2, "", 1,0,0, 0.1,0.1,0.1, 0)
mylight.on()

# Display scene
while 1:
  display.clear()

  mysphere.draw(patimg)
  mysphere.rotateIncY( 0.5 )

  myhemisphere.draw(coffimg)
  myhemisphere.rotateIncY( .5 )

  myhelix.draw(patimg)
  myhelix.rotateIncY(3)
  myhelix.rotateIncZ(1)

  mytube.draw(coffimg)
  mytube.rotateIncY(3)
  mytube.rotateIncZ(2)

  myextrude.draw(coffimg,patimg,patimg)
  myextrude.rotateIncY(-2)
Beispiel #7
0
      score[0] += 1
      score0 = String(camera, light,  arialFont, str(score[0]), 0, 12, -5, 0.05, 0.05)
      score0.set_shader(flatsh)
      radius = 0.1 + (radius - 0.1)*0.75 # ball gets smaller each time you score
      ball = Sphere(camera, light, radius,12,12,0.0,"sphere",0,0,0)
      ball.buf[0].set_draw_details(shader,[ballimg], 0.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)

  defocus.start_blur()
  ball.draw()
  mymap.draw()
  myecube.draw()
  defocus.end_blur()

  defocus.blur(ball, 4, 15, 2)
  defocus.blur(mymap, 4, 15, 2)
  defocus.blur(myecube, 4, 15, 2)

  monster.draw()

  # write up the score
  score0.draw()
  score1.draw()

  camera.was_moved = False
Beispiel #8
0
m1Rad = 4 # radius of moon orbit
m2Rad = 0.55 # radius moon's moon orbit


#create a light
mylight = Light(0,5,5,5,"sun",10,0,6, .1,.1,.2, 0)
mylight.on()

# Display scene
while 1:
  display.clear()

  myplane.draw(starsimg)
  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