本文整理汇总了Python中Object.Object.send_to_back方法的典型用法代码示例。如果您正苦于以下问题:Python Object.send_to_back方法的具体用法?Python Object.send_to_back怎么用?Python Object.send_to_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object.Object
的用法示例。
在下文中一共展示了Object.send_to_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_objects
# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import send_to_back [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
示例2: place_objects
# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import send_to_back [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