Пример #1
0
    def __init__(self, game_opts):
        # initialize the state
        State.__init__(self, constants.SCENES['intro'])

        ## the game's command line options
        self.game_opts = game_opts

        ## intro slides
        slide_num = len(constants.FILES['graphics']['intro']['slides'])
        self.slides = [
            graphics.load_image(
                constants.FILES['graphics']['intro']
                ['slides'][i])[0] for i in range(slide_num)
            ]

        ## cut scenes object
        self.cutscenes = IntroCutScene(self.slides)

        # set sound volume to minimum
        pygame.mixer.music.set_volume(0.0)

        # play the background music theme
        sound_mixer.play_music(
            constants.FILES['sounds']['menu']['share']['bg'][0])

        # pause or unpause music according to user preference
        if self.game_opts.music:
            pygame.mixer.music.unpause()
        else:
            pygame.mixer.music.pause()

        # set sound volume to maximum
        pygame.mixer.music.set_volume(MAX_VOLUME)
class Intro(State):

    def __init__(self, game_opts):
        State.__init__(self, constants.SCENES['intro'])
        self.game_opts = game_opts
        parser = ConfigParser(constants.MAIN_CFG, constants.CFG_XMLNS)

        # intro slides
        dir_name = parser.first_match('intro').attrib
        slides = [i.text for i in parser.all_matches('slide')]
        slides = [path.join(dir_name['dir'], i) for i in slides]
        slide_num = len(slides)
        self.slides = [ResourceManager().getImage(slides[i]) for i in range(slide_num)]
        self.cutscenes = IntroCutScene(self.slides)

        pygame.mixer.music.set_volume(0.0)
        sound_mixer.play_music(
            constants.FILES['sounds']['menu']['share']['bg'][0])
        if self.game_opts.music:
            pygame.mixer.music.unpause()
        else:
            pygame.mixer.music.pause()
        pygame.mixer.music.set_volume(MAX_VOLUME)

    def do_actions(self):
        # run the intro slideshow
        self.cutscenes.run()

    def check_conditions(self):
        # if the scene is finished, return back
        # to the caller the name of the next one
        if self.cutscenes.controller.is_finished:
            return constants.SCENES['menu']
        return None
Пример #3
0
class Intro(State):

    ## initialize the intro screen
    #
    # @param self the object pointer
    # @param game_opts the game's command line options
    def __init__(self, game_opts):
        # initialize the state
        State.__init__(self, constants.SCENES['intro'])

        ## the game's command line options
        self.game_opts = game_opts

        ## intro slides
        slide_num = len(constants.FILES['graphics']['intro']['slides'])
        self.slides = [
            graphics.load_image(
                constants.FILES['graphics']['intro']
                ['slides'][i])[0] for i in range(slide_num)
            ]

        ## cut scenes object
        self.cutscenes = IntroCutScene(self.slides)

        # set sound volume to minimum
        pygame.mixer.music.set_volume(0.0)

        # play the background music theme
        sound_mixer.play_music(
            constants.FILES['sounds']['menu']['share']['bg'][0])

        # pause or unpause music according to user preference
        if self.game_opts.music:
            pygame.mixer.music.unpause()
        else:
            pygame.mixer.music.pause()

        # set sound volume to maximum
        pygame.mixer.music.set_volume(MAX_VOLUME)

    ## what to do when the intro is enabled
    #
    # @param self the object pointer
    def do_actions(self):
        # run the intro slideshow
        self.cutscenes.run()

    ## what should be satisfied for enabling the next scene
    #
    # @param self the object pointer        
    # @return the name of the next scene        
    def check_conditions(self):
        # if the scene is finished, returns back
        # to the caller the name of the next one
        if self.cutscenes.controller.is_finished:
            return constants.SCENES['menu']
        return None
    def __init__(self, game_opts):
        State.__init__(self, constants.SCENES['intro'])
        self.game_opts = game_opts
        parser = ConfigParser(constants.MAIN_CFG, constants.CFG_XMLNS)

        # intro slides
        dir_name = parser.first_match('intro').attrib
        slides = [i.text for i in parser.all_matches('slide')]
        slides = [path.join(dir_name['dir'], i) for i in slides]
        slide_num = len(slides)
        self.slides = [ResourceManager().getImage(slides[i]) for i in range(slide_num)]
        self.cutscenes = IntroCutScene(self.slides)

        pygame.mixer.music.set_volume(0.0)
        sound_mixer.play_music(
            constants.FILES['sounds']['menu']['share']['bg'][0])
        if self.game_opts.music:
            pygame.mixer.music.unpause()
        else:
            pygame.mixer.music.pause()
        pygame.mixer.music.set_volume(MAX_VOLUME)