当前位置: 首页>>代码示例>>Python>>正文


Python Level.pick_up方法代码示例

本文整理汇总了Python中level.Level.pick_up方法的典型用法代码示例。如果您正苦于以下问题:Python Level.pick_up方法的具体用法?Python Level.pick_up怎么用?Python Level.pick_up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在level.Level的用法示例。


在下文中一共展示了Level.pick_up方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import pick_up [as 别名]

#.........这里部分代码省略.........
    add_time = False #The ingame time counter toggle - this is False when the player can't control the character

    if not scripted_event_on and not level.flipping and not fading and not paused \
    and player.current_animation != "dying" and player.current_animation != "exit":
      #There isn't anything special going on: player can control the character
      #Translates input to commands to the player object
      add_time = True
      if inputs.has_key("LEFT"):
        player.move((-PLAYER_MAX_ACC, 0))
        moved = True

      if inputs.has_key("RIGHT"):
        player.move((PLAYER_MAX_ACC, 0))
        moved = True

      if inputs.has_key("JUMP"):
        if (player.on_ground):
          count = 0
          while (count < 5):
            count += 1
            particles.append(Particle(screen, 10, player.rect.centerx - player.dx / 4 + random.uniform(-3, 3), player.rect.bottom, -player.dx * 0.1, -0.5, 0.3, level.dust_color, 4))
          player.jump()

          #The blobs always try to jump when the player jumps

          for o in objects:
            if o.itemclass == "blob":
              o.jump()

      if inputs.has_key("UP") and not player.on_ground:
        player.jump()

      if inputs.has_key("DOWN"):
        pick_up_item = level.pick_up(player.x, player.y)
        if pick_up_item != None:
          play_sound("coins")
          player.inventory.append(pick_up_item)
          scripted_event_trigger = pick_up_item.itemclass

        #If the level is not flipping at the moment, the player can trigger stuff in the level
        if flip_wait == -1:
          trigger = level.trigger(player.x, player.y)

      #Debug command for flipping:
      if inputs.has_key("SPECIAL"):
        trigger = Trigger(TRIGGER_FLIP, player.x, player.y)

    if inputs.has_key("PAUSE") and player.current_animation != "dying":
      paused = not paused

    #Decelerates the player, if he doesn't press any movement keys or when he is dead and on the ground
    if ((player.current_animation != "dying" and not moved) or (player.current_animation == "dying" and player.on_ground)) and not paused:
      player.dec((PLAYER_MAX_ACC, 0))

    if trigger != None and trigger.trigger_type == TRIGGER_FLIP:
      if flip_wait == -1:
        flip_wait = 0
        flip_trigger_position = (trigger.x, trigger.y)
        play_sound("woosh")

    if flip_wait != -1 and not paused:
      flip_wait += 1
      if flip_wait > FLIP_DELAY:
        flip_direction = flip_direction_from_position(flip_trigger_position)
        flip_wait = -1
        level.flip(flip_direction)
开发者ID:IndexErrorCoders,项目名称:PygamesCompilation,代码行数:70,代码来源:game.py

示例2: run

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import pick_up [as 别名]

#.........这里部分代码省略.........
      else:
        keys_released["J_B1"] = True


    if scripted_event_on:
      if inputs[JUMP] or inputs[DOWN]:
        cleared = True

    moved = False

    analog_multiplier = 1

    if not scripted_event_on and not level.flipping:
      if inputs[LEFT]:
        player.move((-PLAYER_MAX_ACC, 0))
        moved = True

      if inputs[RIGHT]:
        player.move((PLAYER_MAX_ACC, 0))
        moved = True

      if inputs[JUMP]:
        if (player.on_ground):
          count = 0
          while (count < 5):
            count += 1
            particles.append(Particle(screen, 10, player.rect.centerx - player.dx / 4 + random.uniform(-3, 3), player.rect.bottom, -player.dx * 0.1, -0.5, 0.3, COLOR_DUST, 4))
          player.jump()

      if inputs[UP] and not player.on_ground:
        player.jump()

      if inputs[DOWN]:
        pick_up_item = level.pick_up(player.x, player.y)
        if pick_up_item != None:
          play_sound("coins")
          player.inventory.append(pick_up_item)
          scripted_event_trigger = pick_up_item.itemclass

        trigger = level.trigger(player.x, player.y)

      if inputs[SPECIAL]:
        trigger = TRIGGER_FLIP

    if not moved or (player.current_animation == "dying" and player.on_ground):
      player.dec((PLAYER_MAX_ACC, 0))

    if trigger == TRIGGER_FLIP:
      if flip_wait == -1:
        flip_wait = 0
        play_sound("woosh")

    if flip_wait != -1:
      flip_wait += 1
      if flip_wait > FLIP_DELAY:
        flip_wait = -1
        level.flip()
        for o in objects:
          o.flip()
        for p in particles:
          p.flip()

    #Rendering and updating objects:

    if scripted_event_trigger == TRIGGER_NONE:
      scripted_event_trigger = level.update()
开发者ID:geofmatthews,项目名称:csci321,代码行数:70,代码来源:game.py


注:本文中的level.Level.pick_up方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。