Beispiel #1
0
# setup matrices
mtrx = Matrix()

# Fetch key presses
mykeys = Keyboard()
mymouse = Mouse()
mymouse.start()

omx=mymouse.x
omy=mymouse.y

# Display scene and rotate cuboid
while 1:
  display.clear()

  mtrx.identity()
  mtrx.rotate(tilt, 0, 0)
  mtrx.rotate(0, rot, 0)
  mtrx.translate(xm,ym,zm)

  myecube.draw(ectex,xm,ym,zm)
  mymap.draw(mountimg1)
  mygrass.drawAll(grassimg)
  mytrees1.drawAll(tree2img)
  mytrees2.drawAll(tree1img)
  mytrees3.drawAll(hb2img)

  mx=mymouse.x
  my=mymouse.y

  #if mx>display.left and mx<display.right and my>display.top and my<display.bottom:
Beispiel #2
0
max_speed = 0.2

# Fetch key presses
mykeys = Keyboard()
mymouse = Mouse()
mymouse.start()

omx=mymouse.x
omy=mymouse.y

camera = Matrix()

while True:
  display.clear()

  camera.identity()
  camera.translate(xm,-2+ym-mapheight,-maphalf-2.5)

  myecube.draw(ectex,xm,ym,zm)
  mymap.draw(groundimg)

  #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)