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


Python Background.warning方法代码示例

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


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

示例1: Vacuum

# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import warning [as 别名]
class Vacuum():

    def __init__(self):
        if not pygame.font: print 'Warning, fonts disabled'
        if not pygame.mixer: print 'Warning, sound disabled'
        self.initialise()
        self.loop()

    def initialise(self):
        """this function is called when the program starts.
           it initializes everything it needs, then runs in
           a loop until the function returns."""
        #Initialize Everything
        pygame.init()
        self.screen = pygame.display.set_mode((640, 480))
        pygame.display.set_caption('VacuumFire')
        pygame.mouse.set_visible(0)
        #icon
        icon, foo = utils.load_image('icon.png')
        pygame.display.set_icon(icon)

        self.game_paused = False
        #sounds
        self.sounds = {};
        self.sounds['music'] = utils.load_sound('archivo.ogg')
        self.sounds['warning'] = utils.load_sound('warning.wav')
        self.sounds['powerup'] = utils.load_sound('powerup.wav')
        self.sounds['music'].play()
        #Create The Backgound
        self.background = Background(self.screen.get_size())
        #game variables
        self.score = 0
        #Display The Background
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()


        #The player's ship
        self.ship = Ship()
        #The player's ship
        self.lifemeter = LifeMeter()
        self.player    = pygame.sprite.RenderPlain((self.ship))
        #group that stores all enemies
        self.enemies    = pygame.sprite.Group()
        #group that stores all powerups
        self.powerups    = pygame.sprite.Group()
        #group that stores all the lasers the player shoots
        self.fire        = pygame.sprite.Group()
        #group for information sprites in the screen, should be rendered the last one
        self.hud         = pygame.sprite.Group()
        self.explosions  = pygame.sprite.Group()
        self.hud.add(self.lifemeter)
        #The level
        self.level = Stage('level_1')
        self.font = utils.load_font('4114blasterc.ttf', 36)


        self.clock = pygame.time.Clock()

        self.game_started = False
        self.game_finished = False

    def handle_keys(self):
        #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT:
                #exit
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE and self.game_finished == True:
                pygame.quit()
                quit()
                
            if event.type == KEYDOWN:
                self.game_started = True
                if event.key == K_ESCAPE:
                    return false   #exit
                elif event.key == K_SPACE:
                    #shoot a laser if the max number is not reached
                    if Laser.num < Laser.max_lasers:
                        self.laser = Laser(self.ship)
                        self.fire.add(self.laser)
                elif event.key == K_LEFT:
                    self.ship.move_left()
                elif event.key == K_RIGHT:
                    self.ship.move_right()
                elif event.key == K_UP:
                    self.ship.move_up()
                elif event.key == K_DOWN:
                    self.ship.move_down()
                elif event.key == K_p:
                    self.game_paused = not self.game_paused

            if event.type == KEYUP:
                if event.key == K_LEFT:
                    self.ship.stop_move_left()
                elif event.key == K_RIGHT:
                    self.ship.stop_move_right()
                elif event.key == K_UP:
                    self.ship.stop_move_up()
                elif event.key == K_DOWN:
#.........这里部分代码省略.........
开发者ID:codelurker,项目名称:VacuumFire,代码行数:103,代码来源:main.py

示例2: Vacuum

# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import warning [as 别名]
class Vacuum():

    def __init__(self, screen):
        self.screen = screen

        self.game_paused = False
        #sounds
        self.sounds = {};
        self.sounds['warning'] = utils.load_sound('warning.wav')
        self.sounds['powerup'] = utils.load_sound('powerup.wav')
        #Load explosions
        a = Explosion(pygame.Rect(0,0,10,10))
        #Create The Backgound
        self.background = Background(self.screen.get_size())
        #game variables
        self.score = Score_Meter((10,10))
        #Display The Background
        self.screen.blit(self.background, (0, 0))

        font = utils.load_font('4114blasterc.ttf', 36)
        text_color = (255,255,255)
        text = font.render("Initialising", 1, text_color)
        self.screen.blit(text, (200, 300))
        pygame.display.flip()

        if show_dummies:
            self.dummy = Dummy()
            self.dummy2 = Dummy()

        #The player's ship
        self.ship = Ship()
        #The dash indicators
        self.lifemeter = LifeMeter()
        self.powerup_speed  = SpeedMeter(pygame.Rect(500,400,0,0))
        self.powerup_weapon = WeaponMeter(pygame.Rect(540,400,0,0))
        self.powerup_buddy  = BuddyMeter(pygame.Rect(580,400,0,0))

        self.player    = pygame.sprite.RenderPlain((self.ship))
        self.buddies   = pygame.sprite.Group()
        #self.buddies.add(Buddy(self.ship)) # add a testing buddy
        #self.ship.buddies += 1
        #group that stores all enemies
        self.enemies    = pygame.sprite.Group()
        self.minibosses = pygame.sprite.Group()
        #group that stores all powerups
        self.powerups   = pygame.sprite.Group()
        #group that stores all the lasers the player shoots
        self.fire       = pygame.sprite.Group()
        #group for information sprites in the screen, should be rendered the last one
        self.hud         = pygame.sprite.Group()
        self.explosions  = pygame.sprite.Group()
        self.enemylasers = pygame.sprite.Group()
        self.hud.add(self.lifemeter)
        self.hud.add(self.score)
        self.hud.add((self.powerup_speed, self.powerup_weapon, self.powerup_buddy))
        if show_dummies:
            self.hud.add(self.dummy)
            self.hud.add(self.dummy2)
        #The level
        self.level = Stage('level_1')
        self.font = utils.load_font('4114blasterc.ttf', 36)

        self.game_started       = True
        self.game_finished      = False
        self.level_finished     = False
        self.scene_finished     = False

    def handle_keys(self):
        #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT:
                #exit
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE and self.game_finished == False:
                self.game_finished = True
            elif event.type == KEYDOWN and event.key == K_ESCAPE and self.game_finished == True:
                self.scene_finished = True
                
            if event.type == KEYDOWN:
                self.game_started = True
                if event.key == K_ESCAPE:
                    return False   #exit
                elif event.key == K_SPACE:
                    #shoot a laser if the max number is not reached
                    if Laser.num < Laser.max_lasers:
                        #print "There's {0} lasers in the screen and the max is {1}".format(Laser.num, Laser.max_lasers)
                        laser = Laser(self.ship)
                        self.fire.add(laser)
                        if self.ship.buddies > 0:
                            self.fire.add(DiagonalLaser(self.ship, "up"))
                        if self.ship.buddies > 1:
                            self.fire.add(DiagonalLaser(self.ship, "down"))
                        if self.ship.buddies > 2:
                            self.fire.add(DiagonalLaser(self.ship, "back"))
                elif event.key == K_LEFT:
                    self.ship.move_left()
                elif event.key == K_RIGHT:
                    self.ship.move_right()
                elif event.key == K_UP:
                    self.ship.move_up()
#.........这里部分代码省略.........
开发者ID:timepilot,项目名称:VacuumFire,代码行数:103,代码来源:vacuum.py


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