Exemple #1
0
  #Press ESCAPE to terminate
  k = mykeys.read()
  if k > -1:
    if k == 119:    #key W
      xm -= math.sin(math.radians(rot))
      zm += math.cos(math.radians(rot))
    elif k == 115:  #kry S
      xm += math.sin(math.radians(rot))
      zm -= math.cos(math.radians(rot))
    elif k == 39:   #key '
      tilt -= 2.0
      print(tilt)
    elif k == 47:   #key /
      tilt += 2.0
    elif k == 97:   #key A
      rot -= 2
    elif k == 100:  #key D
      rot += 2
    elif k == 112:  #key P
      screenshot("BuckfastAbbey"+str(scshots)+".jpg")
      scshots += 1
    elif k == 27:    #Escape key
      mykeys.close()
      mymouse.stop()
      DISPLAY.destroy()
      break
    else:
      print(k)

quit()
Exemple #2
0
    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()

    # write up the score
    score0.draw()
    score1.draw()

    camera.was_moved = False

    #Press ESCAPE to terminate
    k = mykeys.read()

    if k == 27:  #Escape key
        DISPLAY.destroy()
        mykeys.close()
        mymouse.stop()
        break
    elif k == 112:  #key P
        screenshot("pong.jpg")

# attempt to tidy up!
quit()
Exemple #3
0
      xm -= math.sin(math.radians(rot))
      zm += math.cos(math.radians(rot))
      ym = mymap.calcHeight(xm, zm) + avhgt
    elif k==115:  #kry S
      xm += math.sin(math.radians(rot))
      zm -= math.cos(math.radians(rot))
      ym = mymap.calcHeight(xm, zm) + avhgt
    elif k==39:   #key '
      tilt -= 2.0
    elif k==47:   #key /
      tilt += 2.0
    elif k==97:   #key A
      rot -= 2
    elif k==100:  #key D
      rot += 2
    elif k==112:  #key P
      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)

  CAMERA.was_moved = False
quit()
Exemple #4
0
    def write(self):

        frame = screenshot()
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        self.writer.write(frame)
Exemple #5
0
            xm += math.sin(math.radians(rot))
            zm -= math.cos(math.radians(rot))
            ym = mymap.calcHeight(xm, zm) + avhgt
        elif k == 39:  #key '
            tilt -= 2.0
        elif k == 47:  #key /
            tilt += 2.0
        elif k == 97:  #key A
            rot -= 2
        elif k == 100:  #key D now used for point_at monolith!
            rot += 2
            tilt, rot = CAMERA.point_at(
                [monolith.x(), monolith.y(),
                 monolith.z()])
        elif k == 112:  #key P
            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()
Exemple #6
0
   win.resized = False
 if win.ev == "key":
   if win.key == "w":
     xm -= math.sin(math.radians(tankrot)) * 2
     zm -= math.cos(math.radians(tankrot)) * 2
     ym = (mymap.calcHeight(xm, zm) + avhgt)
   if win.key == "s":
     xm += math.sin(math.radians(tankrot)) * 2
     zm += math.cos(math.radians(tankrot)) * 2
     ym = (mymap.calcHeight(xm, zm) + avhgt)
   if win.key == "a":
     tankrot -= 2
   if win.key == "d":
     tankrot += 2
   if win.key == "p":
     screenshot("TigerTank.jpg")
   if win.key == "Escape":
     try:
       print("bye,bye1")
       DISPLAY.destroy()
       try:
         win.destroy()
       except:
         pass
       mymouse.stop()
       exit()
     except:
       pass
 if win.ev=="drag" or win.ev=="click" or win.ev=="wheel":
   xm -= math.sin(math.radians(tankrot)) * 2
   zm -= math.cos(math.radians(tankrot)) * 2
Exemple #7
0
  mysprite.draw()
  myshape.draw()
  defocus.end_blur()
  # 2. drawing now back to screen. The texture can now be used by defocus.blur()

  # 3. redraw these two objects applying a distance blur effect ###############
  defocus.blur(myshape, 4, 9, 5) # 4 is focal distance, >= 9 distance will get
  defocus.blur(mysprite, 4, 9, 5) # 5 x blurring, nearer than focus also blurs

  myshape.rotateIncY(1.247)
  myshape.rotateIncX(0.1613)

  mystring.draw()
  mystring.rotateIncZ(0.05)

  if time.time() > next_time:
    print("FPS:", tick / 2.0)
    tick=0
    next_time = time.time() + 2.0
  tick+=1

  k = mykeys.read()
  if k==112: 
    screenshot("blur1.jpg")
  elif k==27:
    mykeys.close()
    DISPLAY.destroy()
    break

quit()
Exemple #8
0
  #Press ESCAPE to terminate
  k = mykeys.read()
  if k >-1:
    if k==119:    #key W
      xm-=math.sin(math.radians(rot))
      zm+=math.cos(math.radians(rot))
      ym = (mymap.calcHeight(xm,zm)+avhgt)
    elif k==115:  #kry S
      xm+=math.sin(math.radians(rot))
      zm-=math.cos(math.radians(rot))
      ym = (mymap.calcHeight(xm,zm)+avhgt)
    elif k==39:   #key '
      tilt -= 2.0
      print(tilt)
    elif k==47:   #key /
      tilt += 2.0
    elif k==97:   #key A
        rot -= 2
    elif k==100:  #key D
        rot += 2
    elif k==112:  #key P
        screenshot("walkaboutRobot.jpg")
    elif k==27:    #Escape key
      mykeys.close()
      mymouse.stop()
      DISPLAY.destroy()
      break
    else:
        print(k)
Exemple #9
0
    g.draw()

  #key press ESCAPE to terminate
  k = mykeys.read()
  if k >-1:
    if k==119: #key W toggle NB no longer need to hold down all the time
      walk = not(walk)
    elif k==115: #kry S
      walk = False
      dy = -(mymap.calcHeight(xm - dx, zm - dz)+avhgt) - ym
      if dy > -1.0:
        xm -= dx
        zm -= dz
        ym += dy
    elif k==112: #key P
      screenshot("amazing"+str(scshots)+".jpg")
      scshots += 1
    elif k==32 and hp > 0: #key SPACE
      walk = False
      dy = mymap.calcHeight(xm + dx, zm + dz) + avhgt + ym
      xm += dx
      zm += dz
      ym += dy
      hp -= 1
    #elif k==102: #f key to fire
    #  missile.fire(xm, ym, zm, -dx, -math.sin(tilt*rads), -dz, 10)
    elif k==27: #Escape key
      DISPLAY.destroy()
      mykeys.close()
      mymouse.stop()
      break
Exemple #10
0
   CAMERA.reset((DISPLAY.near, DISPLAY.far, DISPLAY.fov, 
               DISPLAY.width / float(DISPLAY.height)))
   win.resized = False
 if win.ev == "key":
   if win.key == "w":
     xm-=math.sin(mouserot*rads)*2
     zm+=math.cos(mouserot*rads)*2
   if win.key == "s":
     xm+=math.sin(mouserot*rads)*2
     zm-=math.cos(mouserot*rads)*2
   if win.key == "a":
     mouserot -= 2
   if win.key == "d":
     mouserot += 2
   if win.key == "p":
     screenshot("ConferenceHall.jpg")
   if win.key == "Escape":
     try:
       print("bye,bye1")
       DISPLAY.destroy()
       try:
         win.destroy()
       except:
         pass
       mymouse.stop()
       exit()
     except:
       pass
 if win.ev=="drag" or win.ev=="click" or win.ev=="wheel":
   xm-=math.sin(mouserot*rads)*2
   zm+=math.cos(mouserot*rads)*2
Exemple #11
0
# Display scene and rotate cuboid
while DISPLAY.loop_running():

    CAMERA.reset()
    CAMERA.rotate(tilt, 0, 0)
    CAMERA.rotate(0, rot, 0)

    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.4
    tilt += (my - omy) * 0.4
    omx = mx
    omy = my

    #Press ESCAPE to terminate
    k = mykeys.read()
    if k > -1:
        if k == 112:  #key P
            screenshot('envcube.jpg')
        elif k == 27:  #Escape key
            mykeys.close()
            mymouse.stop()
            DISPLAY.stop()
            break
        else:
            print(k)
Exemple #12
0
while DISPLAY.loop_running():

  CAMERA.reset()
  CAMERA.rotate(tilt, 0, 0)
  CAMERA.rotate(0, rot, 0)

  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.4
  tilt += (my - omy)*0.4
  omx = mx
  omy = my

  #Press ESCAPE to terminate
  k = mykeys.read()
  if k >-1:
    if k==112:  #key P
      screenshot('envcube.jpg')
    elif k==27:    #Escape key
      mykeys.close()
      mymouse.stop()
      DISPLAY.stop()
      break
    else:
      print(k)


Exemple #13
0
  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()

  # write up the score
  score0.draw()
  score1.draw()

  camera.was_moved = False

  #Press ESCAPE to terminate
  k = mykeys.read()

  if k==27: #Escape key
    DISPLAY.destroy()
    mykeys.close()
    mymouse.stop()
    break
  elif k==112:  #key P
    screenshot("pong.jpg")

# attempt to tidy up!
quit()
Exemple #14
0
    #Press ESCAPE to terminate
    k = mykeys.read()
    if k > -1:
        if k == 119:  #key W
            xm -= math.sin(math.radians(rot))
            zm += math.cos(math.radians(rot))
            ym = (mymap.calcHeight(xm, zm) + avhgt)
        elif k == 115:  #kry S
            xm += math.sin(math.radians(rot))
            zm -= math.cos(math.radians(rot))
            ym = (mymap.calcHeight(xm, zm) + avhgt)
        elif k == 39:  #key '
            tilt -= 2.0
            print(tilt)
        elif k == 47:  #key /
            tilt += 2.0
        elif k == 97:  #key A
            rot -= 2
        elif k == 100:  #key D
            rot += 2
        elif k == 112:  #key P
            screenshot("walkaboutRobot.jpg")
        elif k == 27:  #Escape key
            mykeys.close()
            mymouse.stop()
            DISPLAY.destroy()
            break
        else:
            print(k)
Exemple #15
0
        g.draw()

    #key press ESCAPE to terminate
    k = mykeys.read()
    if k > -1:
        if k == 119:  #key W toggle NB no longer need to hold down all the time
            walk = not (walk)
        elif k == 115:  #kry S
            walk = False
            dy = -(mymap.calcHeight(xm - dx, zm - dz) + avhgt) - ym
            if dy > -1.0:
                xm -= dx
                zm -= dz
                ym += dy
        elif k == 112:  #key P
            screenshot("amazing" + str(scshots) + ".jpg")
            scshots += 1
        elif k == 32 and hp > 0:  #key SPACE
            walk = False
            dy = mymap.calcHeight(xm + dx, zm + dz) + avhgt + ym
            xm += dx
            zm += dz
            ym += dy
            hp -= 1
        #elif k==102: #f key to fire
        #  missile.fire(xm, ym, zm, -dx, -math.sin(tilt*rads), -dz, 10)
        elif k == 27:  #Escape key
            DISPLAY.destroy()
            mykeys.close()
            mymouse.stop()
            break
Exemple #16
0
    defocus.end_blur()
    # 2. drawing now back to screen. The texture can now be used by defocus.blur()

    # 3. redraw these two objects applying a distance blur effect ###############
    defocus.blur(myshape, 4, 9,
                 5)  # 4 is focal distance, >= 9 distance will get
    defocus.blur(mysprite, 4, 9,
                 5)  # 5 x blurring, nearer than focus also blurs

    myshape.rotateIncY(1.247)
    myshape.rotateIncX(0.1613)

    mystring.draw()
    mystring.rotateIncZ(0.05)

    if time.time() > next_time:
        print("FPS:", tick / 2.0)
        tick = 0
        next_time = time.time() + 2.0
    tick += 1

    k = mykeys.read()
    if k == 112:
        screenshot("blur1.jpg")
    elif k == 27:
        mykeys.close()
        DISPLAY.destroy()
        break

quit()
Exemple #17
0
                x=0,
                y=-1,
                z=40,
                sx=0.005,
                sy=0.005,
                sz=0.005)
mymodel.set_shader(shader)

# Fetch key presses
mykeys = Keyboard()

while 1:
    DISPLAY.clear()

    mymodel.draw()
    mymodel.rotateIncZ(0.001)
    mymodel.rotateIncX(-0.00317543)
    mymodel.rotateIncY(0.11)

    k = mykeys.read()
    if k > -1:
        if k == 112: screenshot('Triceratops.jpg')
        elif k == 27:
            mykeys.close()
            DISPLAY.destroy()
            break
        else:
            print(k)

    DISPLAY.swap_buffers()
Exemple #18
0
#========================================
# load bump and reflection textures
bumptex = Texture("textures/floor_nm.jpg")
shinetex = Texture("textures/stars.jpg")

# load model_loadmodel
mymodel = Model(file_string='models/teapot.egg', name='teapot', x=0, y=0, z=10)
mymodel.set_shader(shader)
# material is set in the file
mymodel.set_normal_shine(bumptex, 4.0, shinetex, 0.2, is_uv = False)

# Fetch key presses
mykeys = Keyboard()

while DISPLAY.loop_running():
  mymodel.draw()
  mymodel.rotateIncY(2.0)
  mymodel.rotateIncZ(0.1)
  mymodel.rotateIncX(0.3)

  k = mykeys.read()
  if k >-1:
    if k == 112:
      screenshot('teapot.jpg')
    elif k==27:
      mykeys.close()
      DISPLAY.close()
      break
    else:
      print(k)
Exemple #19
0
#========================================

# load model_loadmodel
mymodel = Model(file_string='models/Triceratops/Triceratops.egg',
                name='Triceratops', x=0, y=-1, z=40,
                sx=0.005, sy=0.005, sz=0.005)
mymodel.set_shader(shader)

# Fetch key presses
mykeys = Keyboard()

while 1:
  DISPLAY.clear()

  mymodel.draw()
  mymodel.rotateIncZ(0.001)
  mymodel.rotateIncX(-0.00317543)
  mymodel.rotateIncY(0.11)

  k = mykeys.read()
  if k >-1:
    if k==112: screenshot('Triceratops.jpg')
    elif k==27:
      mykeys.close()
      DISPLAY.destroy()
      break
    else:
      print(k)

  DISPLAY.swap_buffers()
Exemple #20
0
    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
        mywater.buf[0].textures[0] = waterbump[i_n]
        next_time = time.time() + spf
        av_fps = av_fps * 0.9 + tick / spf * 0.1  # exp smooth moving average
        print(av_fps, "FPS")
        tick = 0

    tick += 1

    #screenshot("/media/E856-DA25/New/fr%03d.jpg" % fr)
    #fr += 1

    k = mykeys.read()
    if k == 112:
        screenshot("water1.jpg")
    elif k == 27:
        mykeys.close()
        DISPLAY.destroy()
        break

quit()
Exemple #21
0
  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
    mywater.buf[0].textures[0] = waterbump[i_n]
    next_time = time.time() + spf
    av_fps = av_fps*0.9 + tick/spf*0.1 # exp smooth moving average
    print(av_fps,"FPS")
    tick = 0

  tick += 1

  #screenshot("/media/E856-DA25/New/fr%03d.jpg" % fr)
  #fr += 1

  k = mykeys.read()
  if k==112: 
    screenshot("water1.jpg")
  elif k==27:    
    mykeys.close()
    DISPLAY.destroy()
    break

quit()
Exemple #22
0
  if inFlag and abs(man.z() - building.zpos) > 55:
    inFlag = False
    for b in building.model:
      b.set_light(outLight, 0)
    mymap.set_light(outLight, 0)

  if inputs.key_state("KEY_APOSTROPHE"):  #key '
    tilt -= 2.0
  if inputs.key_state("KEY_SLASH"):  #key /
    tilt += 2.0
  if inputs.key_state("KEY_A"):  #key A
    rot += 2
  if inputs.key_state("KEY_D"): #key D
    rot -= 2
  if inputs.key_state("KEY_P"): #key P
    #record = not(record)
    while inputs.key_state("KEY_P"):
    	inputs.do_input_events()		# wait for key to go up
    screenshot("silo"+str(scshots)+".jpg")
    scshots += 1
  if inputs.key_state("KEY_ENTER"):  #key RETURN
    mc = 0
  if inputs.key_state("KEY_X"):  #key RETURN
    while inputs.key_state("KEY_X"):
      inputs.do_input_events() # wait for key to go up
    mouseOn != mouseOn
    inputs.grab_by_type("keyboard", grab=mouseOn)

inputs.release()
DISPLAY.destroy()