Exemplo n.º 1
0
Arquivo: Pong.py Projeto: JamesR1/pi3d
ball = Sphere(radius,12,12,0.0,"sphere",-4,8,-7)
#monster
monster = Plane(5.0, 5.0, "monster", 0,0,0, 0,0,0)

# Create elevation map
mapwidth=50.0
mapdepth=50.0
maphalf=22.0
mapheight=40.0
#set smooth to give proper normals the bouncing won't work properly without and it doesn't look as good
mymap = ElevationMap("textures/pong.jpg",mapwidth,mapdepth,mapheight,32,32,4,"sub",0,0,0, smooth=True)

# lighting. The default light is a point light but I have made the position method capable of creating
# a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about
light = Light(0, 2, 2, 1, "", 1,2,3, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' with low level blueish ambient
light.position(1,2,3,0) # set to directional light by setting position with 0 fourth parameter
light.on()

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym=mapheight
lastX0=0.0
lastZ0=0.0

arialFont = Font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
score = [0,0]
Exemplo n.º 2
0
  for g in shed.vGroup:
    shedgp[g].drawAll(shed.vGroup[g].texID)

  # movement and rotations of light
  myfog.off()

  mx=mymouse.x
  my=mymouse.y

  rot += (mx-omx)*0.2
  tilt -= (my-omy)*0.2
  omx=mx
  omy=my
  v1 = rotate_vec_y(rot,  0, 1, -2)
  v2 = rotate_vec_x(tilt,v1[0], v1[1], v1[2])
  light.position(v2[0], v2[1], v2[2], 0) #fourth parameter in function sets (1=point light , default) or (0=distant light)
  # the light has to be turned as the scene rotates, it took ages to work out how to do this by reversing the rotation order!!!
  dx = -math.sin(rot*rads)
  dz = math.cos(rot*rads)
  dy = math.sin(tilt*rads)
  if (walk):
    if (fly):
      xm += dx*3
      zm += dz*3
      ym += dy*3
    else:
      dy = -(mymap.calcHeight(xm + dx*1.5, zm + dz*1.5)+avhgt) - ym
      if dy > -1.0: # limit steepness so can't climb up walls
        xm += dx
        zm += dz
        ym += dy