Beispiel #1
0
tick = 0
av_fps = 0
i_n=0
spf = 0.1 # seconds per frame, i.e. water image change
next_time = time.time() + spf
dx = 0.02
offset = 0.0 # uv offset
do = -0.001 # uv increment

# Fetch key presses.
mykeys = Keyboard()
fr = 0
# Display scene and rotate shape
while DISPLAY.loop_running():

  myshape.draw()
  myshape.rotateIncY(0.247)
  myshape.rotateIncZ(0.1613)
  myshape.translateX(dx)
  if myshape.x() > 5: dx = -0.05
  elif myshape.x() < -5: dx = 0.05

  mywater.draw()
  offset = (offset + do) % 1.0 # move texture offset in v direction
  mywater.set_offset((0.0, offset))

  mystring.draw()
  mystring.rotateIncZ(0.05)

  if time.time() > next_time:
    i_n = (i_n + 1) % num_n
Beispiel #2
0
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
  k = mykeys.read()
Beispiel #3
0
        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
        if mSx < -mapwidth / 2: mSx = -mapwidth / 2
        if mSx > mapwidth / 2: mSx = mapwidth / 2
Beispiel #4
0
            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
quit()
Beispiel #5
0
tick = 0
av_fps = 0
i_n = 0
spf = 0.1  # seconds per frame, i.e. water image change
next_time = time.time() + spf
dx = 0.02
offset = 0.0  # uv offset
do = -0.001  # uv increment

# Fetch key presses.
mykeys = Keyboard()
fr = 0
# Display scene and rotate shape
while DISPLAY.loop_running():

    myshape.draw()
    myshape.rotateIncY(0.247)
    myshape.rotateIncZ(0.1613)
    myshape.translateX(dx)
    if myshape.x() > 5: dx = -0.05
    elif myshape.x() < -5: dx = 0.05

    mywater.draw()
    offset = (offset + do) % 1.0  # move texture offset in v direction
    mywater.set_offset((0.0, offset))

    mystring.draw()
    mystring.rotateIncZ(0.05)

    if time.time() > next_time:
        i_n = (i_n + 1) % num_n
Beispiel #6
0
        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
    if mSx < -mapwidth/2: mSx = -mapwidth/2
    if mSx > mapwidth/2: mSx = mapwidth/2
    if mSz < -mapdepth/2: mSz = -mapdepth/2
Beispiel #7
0
while DISPLAY.loop_running():

  CAMERA.reset()
  #tilt can be used as a means to prevent the view from going under the landscape!
  if tilt < -1: sf = 15 - 12.5/abs(tilt)
  else: sf = 2.5
  xoff = sf*math.sin(math.radians(rot))
  yoff = abs(1.25*sf*math.sin(math.radians(tilt))) + 3.25
  zoff = -sf*math.cos(math.radians(rot))
  CAMERA.rotate(tilt, rot, 0)
  CAMERA.position((xm + xoff, ym + yoff, zm + zoff))   #zoom CAMERA out so we can see our robot

  #draw robot
  robot.position(xm, ym, zm)
  robot.rotateToY(-rot)
  robot.draw()

  station.draw()
  mymap.draw() #Draw the landscape
  myecube.draw() #Draw environment cube
  myecube.position(xm, ym, zm)

  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.1
  omx = mx
  omy = my

  #Press ESCAPE to terminate
Beispiel #8
0
    CAMERA.reset()
    #tilt can be used as a means to prevent the view from going under the landscape!
    if tilt < -1: sf = 15 - 12.5 / abs(tilt)
    else: sf = 2.5
    xoff = sf * math.sin(math.radians(rot))
    yoff = abs(1.25 * sf * math.sin(math.radians(tilt))) + 3.25
    zoff = -sf * math.cos(math.radians(rot))
    CAMERA.rotate(tilt, rot, 0)
    CAMERA.position((xm + xoff, ym + yoff,
                     zm + zoff))  #zoom CAMERA out so we can see our robot

    #draw robot
    robot.position(xm, ym, zm)
    robot.rotateToY(-rot)
    robot.draw()

    station.draw()
    mymap.draw()  #Draw the landscape
    myecube.draw()  #Draw environment cube
    myecube.position(xm, ym, zm)

    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.1
    omx = mx
    omy = my

    #Press ESCAPE to terminate