Beispiel #1
0
            dsz = -1 * abs(dsz)
        else:
            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()
Beispiel #2
0
    # returns the components of normal vector if clash
    nx, ny, nz =  clash[1], clash[2], clash[3]
    # move it away a bit to stop it getting trapped inside if it has tunelled
    sx, sy, sz = sx - 0.1*radius*nx, sy - 0.1*radius*ny, sz - 0.1*radius*nz
    # clash[4] is also the ground level below the mid point of the object so this could be used to 'lift' it up

    # use R = I - 2(N.I)N
    rfact = 2.10*(nx*dsx + ny*dsy + nz*dsz) #small extra boost by using value > 2 to top up energy in defiance of 1st LOT
    dsx, dsy, dsz = dsx - rfact*nx, dsy - rfact*ny, dsz - rfact*nz
    # stop the speed increasing too much
    if dsx > 0.8: dsx = 0.7
    if dsz > 0.4: dsz = 0.3    
   
     

  ball.position(sx, sy, sz) #########################################################

  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==119:    #key W
      xm-=math.sin(rot*rads)
Beispiel #3
0
    else:
      sx, sy, sz = 0, mapheight/3, 0
      dsx, dsy, dsz = 0.3*random.random()-0.15, 0, 0.1
      score[1] += 1
  if sz < -maphalf: #monster end
    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()
Beispiel #4
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

  k = mykeys.read()
  if k >-1:
    if k==112: display.screenshot("earthPic.jpg")
    elif k==27:
      mykeys.close()
      texs.deleteAll()