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


Python Stage.the_limits方法代码示例

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


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

示例1: Vacuum

# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import the_limits [as 别名]

#.........这里部分代码省略.........
                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)
            self.dummy.rect.top = the_limits[0]*self.level.ratio
            self.dummy2.rect.top = the_limits[1]*self.level.ratio
            self.dummy.rect.height = 2
            self.dummy2.rect.height = 2
            self.dummy.rect.left = self.ship.rect.left
            self.dummy2.rect.left = self.ship.rect.left

        #draw the level
        all_sprites = pygame.sprite.Group()
        all_sprites.add(self.player.sprites())
        all_sprites.add(self.enemies.sprites())
        all_sprites.add(self.minibosses.sprites())
        all_sprites.add(self.powerups.sprites())
        all_sprites.add(self.buddies.sprites())
        all_sprites.add(self.fire.sprites())
        all_sprites.add(self.enemylasers.sprites())
        all_sprites.add(self.hud.sprites())
        all_sprites.add(self.explosions.sprites())
        all_sprites.update()
        if len(self.minibosses.sprites()) == 0:
            self.level.update()
        self.background.update()

        #Move and draw the background

        self.screen.blit(self.background, (0, 0))
        self.screen.blit(self.level, (-self.level.scrolled, 0))

        if self.level_finished == True:
            level_text = self.font.render("Level finished", 2, (255, 255, 255))
            self.screen.blit(level_text, (280, 200))
        elif self.game_finished == True:
            gameover_text = self.font.render("Game Over", 2, (255, 255, 255))
            self.screen.blit(gameover_text, (280, 200))
            gameover_text = self.font.render("Press Esc", 2, (255, 255, 255))
            self.screen.blit(gameover_text, (280, 230))
        else:
            all_sprites.draw(self.screen)
            all_sprites.empty()
开发者ID:timepilot,项目名称:VacuumFire,代码行数:104,代码来源:vacuum.py


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