if dy < 1.2: # limit steepness so can't climb up walls xm += dx*0.5 zm += dz*0.5 ym += dy*0.5 if (xm < -490 or xm > 490 or zm < -490 or zm > 490): fly = True #reached the edge of the maze! if not (mx == omx and my == omy and oxm == xm and ozm == zm): CAMERA.reset() CAMERA.rotate(tilt, 0, 0) CAMERA.rotate(0, rot, 0) CAMERA.position((xm, ym, zm)) omx = mx omy = my oxm = xm ozm = zm myecube.position(xm, ym, zm) myecube.draw() mymap.draw() mytrees1.draw() raspberry.draw() monst.draw() # monster movement mDy -= gravity mDelx,mDelz = mSx-xm, mSz-zm #distance from monster mDist = math.sqrt(mDelx**2 + mDelz**2) mDx = -0.1*mDelx/mDist mDz = -0.1*mDelz/mDist monst.rotateIncY(100.0/mDist) if mDist > 100: #far away so teleport it nearer mSx, mSz = xm + 100*random.random() - 50, zm + 100*random.random() - 50
xm += dx * 0.5 zm += dz * 0.5 ym += dy * 0.5 if (xm < -490 or xm > 490 or zm < -490 or zm > 490): fly = True #reached the edge of the maze! if not (mx == omx and my == omy and oxm == xm and ozm == zm): CAMERA.reset() CAMERA.rotate(tilt, 0, 0) CAMERA.rotate(0, rot, 0) CAMERA.position((xm, ym, zm)) omx = mx omy = my oxm = xm ozm = zm myecube.position(xm, ym, zm) myecube.draw() mymap.draw() mytrees1.draw() raspberry.draw() monst.draw() # monster movement mDy -= gravity mDelx, mDelz = mSx - xm, mSz - zm #distance from monster mDist = math.sqrt(mDelx**2 + mDelz**2) mDx = -0.1 * mDelx / mDist mDz = -0.1 * mDelz / mDist monst.rotateIncY(100.0 / mDist) if mDist > 100: #far away so teleport it nearer mSx, mSz = xm + 100 * random.random() - 50, zm + 100 * random.random(
man = SolidObject("man", Size(1, avhgt, 1), Position(0, (mymap.calcHeight(5, 5) + avhgt/2), 0), 1) inputs = InputEvents() inputs.get_mouse_movement() mouseOn = True frame = 400 record = False CAMERA = Camera.instance() while DISPLAY.loop_running() and not inputs.key_state("KEY_ESC"): CAMERA.reset() CAMERA.rotate(tilt, rot, 0) CAMERA.position((man.x(), man.y(), man.z() - aveyeleveladjust)) myecube.position(man.x(), man.y(), man.z() - aveyeleveladjust) SolidObject.drawall() building.drawAll() mymap.draw() myecube.draw() inputs.do_input_events() """On some combined keyboard/mouse arrangements you might need to change this to inputs.get_mouse_movement(1) in order to get the correct input """ mx, my, mv, mh, md = inputs.get_mouse_movement() rot -= (mx)*0.2