當前位置: 首頁>>代碼示例>>Python>>正文


Python Stage.getenemies方法代碼示例

本文整理匯總了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))
開發者ID:codelurker,項目名稱:VacuumFire,代碼行數:69,代碼來源:main.py

示例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)
開發者ID:timepilot,項目名稱:VacuumFire,代碼行數:70,代碼來源:vacuum.py


注:本文中的stage.Stage.getenemies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。