本文整理汇总了Python中enemy.Enemy.add方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.add方法的具体用法?Python Enemy.add怎么用?Python Enemy.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_next_stage
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import add [as 别名]
def start_next_stage(self):
# Se generan las posiciones al azar de los enemigos en "enemies_bucket"
enemies_sd = GameConfig.get_enemies(self.stage)
enemies_bucket = []
for (enemy_type, enemy_quantity) in enemies_sd:
for x in range(0, enemy_quantity):
enemies_bucket.append(enemy_type)
random.shuffle(enemies_bucket)
total_enemies = len(enemies_bucket)
#Se calculan los objetos especiales
items_sd = GameConfig.get_items(self.stage)
items_bucket = []
for (item_type, item_quantity) in items_sd:
for x in range(0, item_quantity):
items_bucket.append(item_type)
while len(items_bucket) < total_enemies:
items_bucket.append(0)
random.shuffle(items_bucket)
# Creando los sprites de los enemigos
great_rect = None
enemy_shoots = pygame.sprite.RenderPlain()
enemies = pygame.sprite.RenderPlain()
x = -1
for etype in enemies_bucket:
x += 1
start_position = self.get_start_position_for_enemy(x, total_enemies)
enemy = Enemy((etype - 1), items_bucket[x], start_position, enemy_shoots)
enemy.add(enemies)
if great_rect is None:
great_rect = enemy.get_rect().copy()
else:
great_rect.union_ip(enemy.get_rect())
enemy_box = EnemyBox(great_rect, GameConfig.get_move(self.stage))
for e in enemies:
e.set_enemy_box(enemy_box)
# Se generan los prisioneros
prisoners = pygame.sprite.RenderPlain()
nprisoners = GameConfig.get_prisoners(self.stage)
screen = pygame.display.get_surface()
gap = (screen.get_width() - (self.PRISONER_SPRITE_WIDTH * nprisoners)) / (nprisoners + 1)
for p in range(0, nprisoners):
start_position = (self.PRISONER_SPRITE_WIDTH * p) + (gap * (p + 1)), 3
prisoner = Prisoner(start_position)
prisoner.add(prisoners)
# Comienza el juego!
pygame.time.set_timer(USEREVENT+2, 0) # Ready screen
pygame.time.set_timer(USEREVENT+1, 1000) # Game's time
return enemies, prisoners, enemy_shoots, enemy_box