Esempio n. 1
0
    def initialize(self):
        GameStage.initialize(self)

        self.tests = None
        self.h_key = None
        self.v_key = None
        self.map_character = None
        self.named_layers = None
        self.collisions = None
        self.map_manager = None

        if self.game.datastore.datamodel.current_map_index:
            self.current_map_index = self.game.datastore.datamodel.current_map_index
            self.game.datastore.datamodel.current_map_index = None
        else:
            self.current_map_index = 4

        # Load the sound
        self.street_ambience_sound = assets.load_sound(
            'DGI_street_ambience.ogg')
        self.street_ambience_sound.play(-1)
Esempio n. 2
0
    def initialize(self):
        GameStage.initialize(self)

        # Load the sound
        self.item_found_sound = assets.load_sound('DGI_item_found.ogg')
Esempio n. 3
0
    def initialize(self):
        GameStage.initialize(self)
        stream = file('data/fonts.yaml', 'r')
        fonts = load(stream)
        for font in fonts:
            setattr(
                self, font,
                assets.load_font(fonts[font]['file_name'],
                                 fonts[font]['size']))

        self.data = DictClass(load(file('data/memory.yaml')))

        self.game_over_layer = Layer()
        image = assets.load_image(
            self.data.game_over[self.game.datastore.datamodel.character].src)
        item = ItemImage(self.data.game_over.left, self.data.game_over.top,
                         image)
        self.game_over_layer.add(item)

        self.main_layer = Layer()
        self.top_layer = Layer()

        self.time = self.data.time.max
        self.timer = DictClass({})
        image = assets.load_image(self.data.time.src)
        self.timer['skin'] = ItemImage(self.data.time.left, self.data.time.top,
                                       image)
        self.timer['value'] = ItemText(self.data.time.left,
                                       self.data.time.top,
                                       self.font,
                                       0,
                                       format_time(self.time),
                                       width=image.get_width(),
                                       height=image.get_height(),
                                       h_align=2,
                                       v_align=2)
        self.top_layer.add(self.timer.skin)
        self.top_layer.add(self.timer.value)

        self.score = 0
        self.score_board = DictClass({})
        image = assets.load_image(self.data.score.src)
        self.score_board['skin'] = ItemImage(self.data.score.left,
                                             self.data.score.top, image)
        self.score_board['value'] = ItemText(self.data.score.left,
                                             self.data.score.top,
                                             self.font,
                                             0,
                                             str(self.score),
                                             width=image.get_width(),
                                             height=image.get_height(),
                                             h_align=2,
                                             v_align=2)
        self.top_layer.add(self.score_board.skin)
        self.top_layer.add(self.score_board.value)

        self.deck = []
        image_back = assets.load_image(self.data.board.card_back)
        for k in range(0, len(self.data.board.cards)):
            image = assets.load_image(self.data.board.cards[k])
            self.deck.append([
                Card(self, k, image, image_back),
                Card(self, k, image, image_back)
            ])

        self.range = self.data.start
        self.cards = []
        self.deal()

        # Load the sound
        self.card_flip_sound = assets.load_sound('DGI_card_flip.ogg')
        self.item_found_sound = assets.load_sound('DGI_item_found.ogg')
        self.wrong_sound = assets.load_sound('DGI_wrong.ogg')
        self.lose_bell_sound = assets.load_sound('DGI_lose_bell.ogg')
        self.lose_music_sound = assets.load_sound('DGI_lose_music.ogg')
Esempio n. 4
0
 def initialize(self):
     GameStage.initialize(self)
     self.character = None
     self.character_group = OptionGroup()
     self.level_group = OptionGroup()
     self.continued = False
Esempio n. 5
0
    def initialize(self):
        GameStage.initialize(self)
        stream = file('data/fonts.yaml', 'r')
        fonts = load(stream)
        for font in fonts:
            setattr(
                self, font,
                assets.load_font(fonts[font]['file_name'],
                                 fonts[font]['size']))

        self.data = DictClass(load(file('data/asteroids.yaml')))

        self.game_over_layer = Layer()
        image = assets.load_image(
            self.data.game_over[self.game.datastore.datamodel.character].src)
        item = ItemImage(self.data.game_over.left, self.data.game_over.top,
                         image)
        self.game_over_layer.add(item)

        self.main_layer = Layer()
        self.top_layer = Layer()

        self.time = self.data.time.max
        self.timer = DictClass({})
        image = assets.load_image(self.data.time.src)
        self.timer['skin'] = ItemImage(self.data.time.left, self.data.time.top,
                                       image)
        self.timer['value'] = ItemText(self.data.time.left,
                                       self.data.time.top,
                                       self.font,
                                       0,
                                       format_time(self.time),
                                       width=image.get_width(),
                                       height=image.get_height(),
                                       h_align=2,
                                       v_align=2)
        self.top_layer.add(self.timer.skin)
        self.top_layer.add(self.timer.value)

        self.score = 0
        self.score_board = DictClass({})
        image = assets.load_image(self.data.score.src)
        self.score_board['skin'] = ItemImage(self.data.score.left,
                                             self.data.score.top, image)
        self.score_board['value'] = ItemText(self.data.score.left,
                                             self.data.score.top,
                                             self.font,
                                             0,
                                             str(self.score),
                                             width=image.get_width(),
                                             height=image.get_height(),
                                             h_align=2,
                                             v_align=2)
        self.top_layer.add(self.score_board.skin)
        self.top_layer.add(self.score_board.value)

        self.level = self.data.start
        self.asteroids = []

        self.max_width = 0
        self.max_height = 0
        for a in self.data.asteroids:
            item = assets.load_image(a)
            if self.max_width < item.get_width():
                self.max_width = item.get_width()
            if self.max_height < item.get_height():
                self.max_height = item.get_height()
        self.max_col = int(SCREEN_WIDTH / self.max_width)
        self.max_row = int(SCREEN_HEIGHT / self.max_height)
        self.margin_left = (SCREEN_WIDTH % self.max_width) / 2
        self.margin_top = (SCREEN_HEIGHT % self.max_height) / 2

        # Load the sound
        self.click_sound = assets.load_sound('DGI_Click.ogg')
        self.item_found_sound = assets.load_sound('DGI_item_found.ogg')
        self.wrong_sound = assets.load_sound('DGI_wrong.ogg')
        self.lose_bell_sound = assets.load_sound('DGI_lose_bell.ogg')
        self.lose_music_sound = assets.load_sound('DGI_lose_music.ogg')
Esempio n. 6
0
 def initialize(self):
     GameStage.initialize(self)
Esempio n. 7
0
    def initialize(self):
        GameStage.initialize(self)
        stream = file('data/fonts.yaml', 'r')

        fonts = load(stream)
        for font in fonts:
            setattr(
                self, font,
                assets.load_font(fonts[font]['file_name'],
                                 fonts[font]['size']))

        self.data = DictClass(load(file('data/invaders.yaml')))

        self.good = self.data.start.good
        self.velocity = self.data.start.velocity
        self.interval = self.data.start.interval

        self.game_over_layer = Layer()
        image = assets.load_image(
            self.data.bad[self.game.datastore.datamodel.character].src)
        item = ItemImage(self.data.bad.left, self.data.bad.top, image)
        self.game_over_layer.add(item)
        image = assets.load_image(
            self.data.game_over[self.game.datastore.datamodel.character].src)
        item = ItemImage(self.data.game_over.left, self.data.game_over.top,
                         image)
        self.game_over_layer.add(item)

        image = assets.load_image(
            self.data.good[self.game.datastore.datamodel.character].src)
        self.good_indicator = ItemImage(self.data.good.left,
                                        self.data.good.top, image)

        self.text_indicators = []

        self.main_layer = Layer()
        self.top_layer = Layer()

        self.score = 0
        self.score_board = DictClass({})
        image = assets.load_image(self.data.score.src)
        self.score_board['skin'] = ItemImage(self.data.score.left,
                                             self.data.score.top, image)
        self.score_board['value'] = ItemText(self.data.score.left,
                                             self.data.score.top,
                                             self.font,
                                             0,
                                             str(self.score),
                                             width=image.get_width(),
                                             height=image.get_height(),
                                             h_align=2,
                                             v_align=2)
        self.top_layer.add(self.score_board.skin)
        self.top_layer.add(self.score_board.value)

        data = DictClass(load(file('data/map/common.yaml')))
        params = data.character[self.game.datastore.datamodel.character]
        params['base'] = data.character.base[
            self.game.datastore.datamodel.character].big
        self.character_animation = Character(**params)
        self.character = self.character_animation.item
        self.character.set_left(
            (SCREEN_WIDTH - self.character.get_width()) / 2)
        self.character.set_top(SCREEN_HEIGHT - self.character.get_height())
        left = self.character.get_left() + self.data.collision.left
        top = self.character.get_top() + self.data.collision.top
        width = self.character.get_width(
        ) - self.data.collision.left - self.data.collision.right
        height = self.character.get_height(
        ) - self.data.collision.top - self.data.collision.bottom
        if DEBUG:
            self.debug_character = ItemRect(left,
                                            top,
                                            width,
                                            height,
                                            border=(255, 255, 255))
        self.invaders = []

        # Load the sound
        self.item_found_sound = assets.load_sound('DGI_item_found.ogg')
        self.lose_hit_sound = assets.load_sound('DGI_lose_hit.ogg')
        self.lose_music_sound = assets.load_sound('DGI_lose_music.ogg')