本文整理汇总了Python中stage.Stage.getenemies方法的典型用法代码示例。如果您正苦于以下问题:Python Stage.getenemies方法的具体用法?Python Stage.getenemies怎么用?Python Stage.getenemies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stage.Stage
的用法示例。
在下文中一共展示了Stage.getenemies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Vacuum
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import getenemies [as 别名]
#.........这里部分代码省略.........
elif powerup_obtained.type == 2 and Laser.max_lasers < 8:
print "Increase lasers to {0}".format(Laser.max_lasers)
Laser.max_lasers += 1
elif powerup_obtained.type == 3 and self.ship.powerup['penetrate'] == False:
print "Activate penetration"
self.ship.powerup['penetrate'] = True
else:
print "No more powerups available"
#Main Loop
def loop(self):
count = 0
while 1:
count = (count+1)%50
self.clock.tick(25)
#handle input events
ok = self.handle_keys()
if ok == False:
return
if self.game_started == False:
start_text = self.font.render('Press any key to start', 2, (0,0,0))
self.screen.blit(start_text, (150, 200))
pygame.display.flip()
continue
if self.game_paused == 1:
start_text = self.font.render('Game paused', 2, (255,255,255))
self.screen.blit(start_text, (150, 200))
pygame.display.flip()
continue
new_enemies = self.level.getenemies()
for enemy_y in new_enemies:
#if random.randint(0,50) == 0:
alien = Alien(enemy_y)
alien.set_target(self.ship)
self.enemies.add(alien)
#aliens damaging the player, remove them
damage = pygame.sprite.spritecollide(self.ship, self.enemies, True)
self.process_powerups()
#check colisions with stage
if self.level.checkcollide(self.ship.rect):
#add some fancy explosions in the damage area
self.explosions.add(Explosion(pygame.Rect(self.ship.rect.x,self.ship.rect.y,0,0)))
damage.append(1)
#Apply damages to the player
if len(damage) > 0:
self.background.warning()
self.ship.damage()
self.lifemeter.shake()
self.explosions.add(Explosion(self.ship.rect))
self.sounds['warning'].play()
self.lifemeter.life = self.ship.life
if self.lifemeter.life < 1:
self.game_finished = True
self.sounds['warning'].stop()
#print (pygame.sprite.spritecollide(ship, level, True))
示例2: Vacuum
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import getenemies [as 别名]
#.........这里部分代码省略.........
if dead.has_powerup():
powerup = Powerup(dead.rect, dead.value)
self.powerups.add(powerup)
self.add_explosion(fireball.rect)
scored = (1+dead.value)*1000
self.score.add_score(scored)
self.hud.add(Flying_Label( fireball.rect, scored))
if penetration == False:
fireball.kill()
#Main Loop
def loop(self):
count = 0
count = (count+1)%50
#handle input events
ok = self.handle_keys()
if ok == False:
return
if self.game_started == False:
start_text = self.font.render('Press any key to start', 2, (0,0,0))
self.screen.blit(start_text, (150, 200))
pygame.display.flip()
return
if self.game_paused == 1:
start_text = self.font.render('Game paused', 2, (255,255,255))
self.screen.blit(start_text, (150, 200))
pygame.display.flip()
return
try:
(new_enemies, new_minibosses, new_bosses, end) = self.level.getenemies()
for enemy_y in new_enemies:
alien = Alien(enemy_y)
alien.set_target(self.ship)
self.enemies.add(alien)
for enemy_y in new_minibosses:
miniboss = Miniboss(enemy_y, self)
miniboss.set_target(self.ship)
self.minibosses.add(miniboss)
if end:
self.level_finished = True
except ValueError:
self.level_finished = True
#aliens damaging the player, remove them
damage = pygame.sprite.spritecollide(self.ship, self.enemies, True)
damage.extend(pygame.sprite.spritecollide(self.ship, self.enemylasers, True))
for miniboss in self.minibosses:
if pygame.sprite.collide_mask(self.ship, miniboss):
damage.append(miniboss)
self.process_powerups()
collisions = self.process_stagecollisions()
for collision in collisions:
damage.append(1)
self.process_damage(damage)
self.process_killedaliens()
#Dummy lines to show the ship's current limits
if show_dummies:
the_limits = self.level.the_limits(self.ship.rect)