Exemplo n.º 1
0
    def prepare(self):
        self.screen.fill((0,0,0));

        self.introImage = pygame.image.load('resources/intro.png')
        self.introImage = self.introImage.convert()

        self.introImage.set_alpha(0)

        introSound = pygame.mixer.Sound("resources/intro.wav")
        introSound.set_volume( Settings.getMusicLevel() )
        introSound.play()
Exemplo n.º 2
0
Arquivo: Game.py Projeto: PGcpp/Game
        def __init__(self):
                pygame.init()
                pygame.mixer.init()
                
                icon = pygame.image.load("resources/icon.png")
                pygame.display.set_icon(icon)
                pygame.display.set_caption("Vikings Defense")
                self.screen = pygame.display.set_mode(self.SCREEN_SIZE, self.BUFFER_MODE)

                self.menuSound = pygame.mixer.Sound("resources/menu.wav")
                self.gameSound = pygame.mixer.Sound("resources/gameMusic.ogg")
                self.effectsSound = pygame.mixer.Sound("resources/ambient.ogg")
                
                introScene = IntroScene.IntroScene(self.screen)
                introScene.start()
                
                while introScene.state == STATE.RUNNING:
                        pass

                if introScene.state == STATE.EXIT:
                        self.Exit()

                while True:

                        self.menuSound.set_volume( Settings.getMusicLevel() )
                        self.gameSound.set_volume( Settings.getMusicLevel() )
                        self.effectsSound.set_volume( Settings.getEffectsLevel() )
                        
                        if self.startMenuSound:
                                self.menuSound.play(-1)
                        
                        self.menuScene = MenuScene.MenuScene(self.screen)
                        self.settingsScene = SettingsScene.SettingsScene(self.screen)
                        self.settingsScene.setSound(self.menuSound)
                        self.defenseScene = DefenseScene.DefenseScene(self.screen)

                        self.menuScene.start()
                        while self.menuScene.state == STATE.RUNNING:
                                pass
      
                        if self.menuScene.state == MENU.PLAY:
                                self.menuSound.stop()

                                if self.startGameSound:
                                        self.gameSound.play(-1)
                                if self.startEffectsSound:
                                        self.effectsSound.play(-1)
                                
                                self.defenseScene.start()

                                while self.defenseScene.state == STATE.RUNNING:
                                        pass

                                if self.defenseScene.state == STATE.EXIT:
                                        self.Exit()
                                        break

                                elif self.defenseScene.state == STATE.STOPPED:
                                        self.gameSound.stop()
                                        self.effectsSound.stop()
                                        self.startMenuSound = True
                                        continue
                                        
                        elif self.menuScene.state == MENU.OPTIONS:
                                self.settingsScene.start()

                                while self.settingsScene.state == STATE.RUNNING:
                                        pass

                                if self.settingsScene.state == STATE.EXIT:
                                        self.menuSound.stop()
                                        self.Exit()
                                        break

                                elif self.settingsScene.state == STATE.STOPPED:
                                        self.menuSound.set_volume( Settings.getMusicLevel() )
                                        self.startMenuSound = False
                                        continue
                                        
                        elif self.menuScene.state == STATE.EXIT:
                                self.Exit()
                                break