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


Python Object.always_visible方法代码示例

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


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

示例1: new_game

# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import always_visible [as 别名]
def new_game():
    global player, inventory, game_msgs, game_state, dungeon_level

    #create object representing the player
    entity_component = Entity(5)
    GameState.player = Object(0, 0, '@', 'player', libtcod.white, blocks=True, entity=entity_component)

    GameState.player.level = 1

    #generate map (at this point it's not drawn to the screen)
    dungeon_level = 1
    Map.make_map()
    initialize_fov()

    game_state = 'playing'
    GameState.inventory = []

    #create the list of game messages and their colors, starts empty
    GameState.game_msgs = []

    #a warm welcoming message!
    GUI.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)

    #initial equipment: a dagger
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component)
    GameState.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
开发者ID:edrobot,项目名称:PythonRoguelike_Spring-2014,代码行数:31,代码来源:GameFlow.py

示例2: new_game

# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import always_visible [as 别名]
def new_game():
    fighter_component = Fighter(hp=30, defense=2, power=5,
                                xp=0, death_function=player_death)
    settings.player = Object(0, 0, '@', 'player', color.white, blocks=True,
                             fighter=fighter_component)

    settings.player.level = 1
    settings.dungeon_level = 1
    make_map()
    handle_keys.initialize_fov()
    settings.game_state = 'playing'
    settings.inventory = []
    settings.game_msgs = []

    message('Welcome stranger. Prepare to perish in the ' +
            'Tombs of the Ancient Kings.', color.red)
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', color.sky,
                 equipment=equipment_component)
    settings.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
开发者ID:Akhier,项目名称:Py-TutMut,代码行数:24,代码来源:new_game.py

示例3: place_objects

# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import always_visible [as 别名]
def place_objects(room):
    #this is where we decide the chance of each monster or item appearing.

    #maximum number of monsters per room
    max_monsters = from_dungeon_level([[2, 1], [3, 4], [5, 6]])

    #chance of each monster
    monster_chances = {}
    monster_chances['orc'] = 80  #orc always shows up, even if all other monsters have 0 chance
    monster_chances['troll'] = from_dungeon_level([[15, 3], [30, 5], [60, 7]])

    #maximum number of items per room
    max_items = from_dungeon_level([[1, 1], [2, 4]])

    #chance of each item (by default they have a chance of 0 at level 1, which then goes up)
    item_chances = {}
    item_chances['heal'] = 35  #healing potion always shows up, even if all other items have 0 chance
    item_chances['lightning'] = from_dungeon_level([[25, 4]])
    item_chances['fireball'] =  from_dungeon_level([[25, 6]])
    item_chances['confuse'] =   from_dungeon_level([[10, 2]])
    item_chances['sword'] =     from_dungeon_level([[5, 4]])
    item_chances['shield'] =    from_dungeon_level([[15, 8]])


    #choose random number of monsters
    num_monsters = libtcod.random_get_int(0, 0, max_monsters)

    for i in range(num_monsters):
        #choose random spot for this monster
        x = libtcod.random_get_int(0, room.x1+1, room.x2-1)
        y = libtcod.random_get_int(0, room.y1+1, room.y2-1)

        #only place it if the tile is not blocked
        if not is_blocked(x, y):
            choice = random_choice(monster_chances)
            if choice == 'orc':
                #create an orc
                fighter_component = Fighter(hp=20, defense=0, power=4, xp=35, death_function= GameFlow.monster_death)
                ai_component = MonsterAIs.BasicMonster()

                monster = Object(x, y, 'o', 'orc', libtcod.desaturated_green,
                                 blocks=True, fighter=fighter_component, ai=ai_component)

            elif choice == 'troll':
                #create a troll
                fighter_component = Fighter(hp=30, defense=2, power=8, xp=100, death_function= GameFlow.monster_death)
                ai_component = MonsterAIs.BasicMonster()

                monster = Object(x, y, 'T', 'troll', libtcod.darker_green,
                                 blocks=True, fighter=fighter_component, ai=ai_component)

            GameState.objects.append(monster)

    #choose random number of items
    num_items = libtcod.random_get_int(0, 0, max_items)

    for i in range(num_items):
        #choose random spot for this item
        x = libtcod.random_get_int(0, room.x1+1, room.x2-1)
        y = libtcod.random_get_int(0, room.y1+1, room.y2-1)

        #only place it if the tile is not blocked
        if not is_blocked(x, y):
            choice = random_choice(item_chances)
            if choice == 'heal':
                #create a healing potion
                item_component = Item(use_function=None)
                item = Object(x, y, '!', 'healing potion', libtcod.violet, item=item_component)

            elif choice == 'lightning':
                #create a lightning bolt scroll
                item_component = Item(use_function=None)
                item = Object(x, y, '#', 'scroll of lightning bolt', libtcod.light_yellow, item=item_component)

            elif choice == 'fireball':
                #create a fireball scroll
                item_component = Item(use_function=None)
                item = Object(x, y, '#', 'scroll of fireball', libtcod.light_yellow, item=item_component)

            elif choice == 'confuse':
                #create a confuse scroll
                item_component = Item(use_function=None)
                item = Object(x, y, '#', 'scroll of confusion', libtcod.light_yellow, item=item_component)

            elif choice == 'sword':
                #create a sword
                equipment_component = Equipment(slot='right hand', power_bonus=3)
                item = Object(x, y, '/', 'sword', libtcod.sky, equipment=equipment_component)

            elif choice == 'shield':
                #create a shield
                equipment_component = Equipment(slot='left hand', defense_bonus=1)
                item = Object(x, y, '[', 'shield', libtcod.darker_orange, equipment=equipment_component)

            GameState.objects.append(item)
            item.send_to_back()  #items appear below other objects
            item.always_visible = True  #items are visible even out-of-FOV, if in an explored area
开发者ID:edrobot,项目名称:PythonRoguelike_Spring-2014,代码行数:99,代码来源:Map.py

示例4: place_objects

# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import always_visible [as 别名]
    def place_objects(self,room):
        #this is where we decide the chance of each monster or item appearing.

        #maximum number of monsters per room
        max_monsters = self.from_dungeon_level([[2, 1], [3, 4], [5, 6]])

        #chance of each monster
        monster_chances = {}
        monster_chances['orc'] = 80  #orc always shows up, even if all other monsters have 0 chance
        monster_chances['goblin'] = self.from_dungeon_level([[15, 3], [30, 5], [60, 7]])

        #maximum number of items per room
        max_items = self.from_dungeon_level([[1, 1], [2, 4]])

        #chance of each item (by default they have a chance of 0 at level 1, which then goes up)
        item_chances = {}
        item_chances['heal'] = 35  #healing potion always shows up, even if all other items have 0 chance
        item_chances['lightning'] = self.from_dungeon_level([[25, 4]])
        item_chances['fireball'] =  self.from_dungeon_level([[25, 6]])
        item_chances['confuse'] =   self.from_dungeon_level([[10, 2]])
        item_chances['sword'] =     self.from_dungeon_level([[5, 4]])
        item_chances['shield'] =    self.from_dungeon_level([[15, 8]])


        #choose random number of monsters
        num_monsters = libtcod.random_get_int(0, 0, max_monsters)

        for i in range(num_monsters):
            #choose random spot for this monster
            x = libtcod.random_get_int(0, room.x1+1, room.x2-1)
            y = libtcod.random_get_int(0, room.y1+1, room.y2-1)

            #only place it if the tile is not blocked
            if not self.is_blocked(x, y):
                choice = self.random_choice(monster_chances)
                if choice == 'orc':
                    monster = Monsters.Orc(x, y, self)
                    monster.ai = AI.GenericType(monster)

                elif choice == 'goblin':
                    #create a goblin
                    monster = Monsters.Goblin(x, y, self)
                    monster.ai = AI.GenericType(monster)

                GameState.objects.append(monster)

        #choose random number of items
        num_items = libtcod.random_get_int(0, 0, max_items)

        for i in range(num_items):
            #choose random spot for this item
            x = libtcod.random_get_int(0, room.x1+1, room.x2-1)
            y = libtcod.random_get_int(0, room.y1+1, room.y2-1)

            #only place it if the tile is not blocked
            if not self.is_blocked(x, y):
                choice = self.random_choice(item_chances)
                if choice == 'heal':
                    #create a healing potion
                    #TODO: Make Item Component
                    item_component = Item(None)# (use_function=None)
                    item = Object(x, y, self, '!', 'healing potion', libtcod.violet, item=item_component)
                    item_component.owner = item

                elif choice == 'lightning':
                    #create a lightning bolt scroll
                    #TODO: Make Item Component
                    item_component = Item(None)# (use_function=None)
                    item = Object(x, y, self, '#', 'scroll of lightning bolt', libtcod.light_yellow, item=item_component)

                elif choice == 'fireball':
                    #create a fireball scroll
                    #TODO: Make Item Component
                    item_component = Item(None)# (use_function=None)
                    item = Object(x, y, self, '#', 'scroll of fireball', libtcod.light_yellow, item=item_component)
                    item_component.owner = item

                elif choice == 'confuse':
                    #create a confuse scroll
                    #TODO: Make Item Component
                    item_component = Item(None)# (use_function=None)
                    item = Object(x, y, self, '#', 'scroll of confusion', libtcod.light_yellow, item=item_component)
                    item_component.owner = item

                elif choice == 'sword':
                    #create a sword
                    #TODO: Make Item Component
                    equipment_component = Equipment.DragonSword()
                    item = Object(x, y, self, '/', 'sword', libtcod.sky, equipment=equipment_component)

                elif choice == 'shield':
                    #create a shield
                    #TODO: Make Item Component
                    equipment_component = Equipment.Shield(BodyParts.Hand)
                    item = Object(x, y, self, '[', 'shield', libtcod.darker_orange, equipment=equipment_component)

                GameState.objects.append(item)
                item.send_to_back()  #items appear below other objects
                item.always_visible = True  #items are visible even out-of-FOV, if in an explored area
开发者ID:edrobot,项目名称:PythonRoguelike_Spring-2014,代码行数:101,代码来源:Map.py


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