Exemplo n.º 1
0
    def __init__(self, menu):
        AbstractScreen.__init__(self,
                                menu,
                                "backgrounds/main_menu.jpg",
                                song="ulerime.ogg")

        self._gui_elements.append(PlayButton(self, (self._x_total_half, 270)))
        self._gui_elements.append(
            HighscoresButton(self, (self._x_total_half, 340)))
        self._gui_elements.append(ExitButton(self, (self._x_total_half, 410)))

        white = (255, 255, 255)
        font_64 = ResourceManager.load_font_asset("8bit.ttf", 64)
        font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)
        font_24 = ResourceManager.load_font_asset("8bit.ttf", 24)
        font_16 = ResourceManager.load_font_asset("8bit.ttf", 16)

        title = TextGUI(self, font_64, white, "COVIDeogame",
                        (self._x_total_half, 120))
        play = TextGUI(self, font_32, white, "Jugar",
                       (self._x_total_half, 270))
        highscores = TextGUI(self, font_32, white, "Highscores",
                             (self._x_total_half, 340))
        exit = TextGUI(self, font_32, white, "Salir",
                       (self._x_total_half, 410))
        group = TextGUI(self, font_24, white, "Universidade da Coruña",
                        (self._x_total_half, 570))

        self._gui_elements.append(title)
        self._gui_elements.append(play)
        self._gui_elements.append(exit)
        self._gui_elements.append(highscores)
        self._gui_elements.append(group)
Exemplo n.º 2
0
    def __init__(self, menu):
        AbstractScreen.__init__(self, menu, "backgrounds/main_menu.jpg")

        self._gui_elements.append(MainMenuButton(self, (self._x_total_half, self._y_total * 14 / 16)))

        white = (255, 255, 255)
        font_64 = ResourceManager.load_font_asset("8bit.ttf", 64)
        # font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)
        font_24 = ResourceManager.load_font_asset("8bit.ttf", 24)
        # font_16 = ResourceManager.load_font_asset("8bit.ttf", 16)

        title = TextGUI(self, font_64, white, "Highscores", (self._x_total_half, self._y_total * 2 / 16))

        hs_rect = HSBackground(self, (self._x_total_half, self._y_total>>1), 500, 325)

        self.hs1 = TextGUI(self, font_24, white, "None", (self._x_total_half, self._y_total * 5 / 16))
        self.hs2 = TextGUI(self, font_24, white, "None", (self._x_total_half, self._y_total * 6.5 / 16))
        self.hs3 = TextGUI(self, font_24, white, "None", (self._x_total_half, self._y_total * 8 / 16))
        self.hs4 = TextGUI(self, font_24, white, "None", (self._x_total_half, self._y_total * 9.5 / 16))
        self.hs5 = TextGUI(self, font_24, white, "None", (self._x_total_half, self._y_total * 11 / 16))

        back_button = TextGUI(self, font_24, white, "Menú Principal", (self._x_total_half, self._y_total * 14 / 16))

        self._gui_elements.append(title)
        self._gui_elements.append(hs_rect)
        self._gui_elements.append(self.hs1)
        self._gui_elements.append(self.hs2)
        self._gui_elements.append(self.hs3)
        self._gui_elements.append(self.hs4)
        self._gui_elements.append(self.hs5)
        self._gui_elements.append(back_button)
Exemplo n.º 3
0
    def __init__(self, menu):
        AbstractScreen.__init__(self, menu, "backgrounds/main_menu.jpg")
        Rocker.action(Rocker.AUD_DEFEAT)
        self._gui_elements.append(RetryButton(self, (self._x_total_half, 270)))
        self._gui_elements.append(ExitButton(self, (self._x_total_half, 340)))

        white = (255, 255, 255)
        font_64 = ResourceManager.load_font_asset("8bit.ttf", 64)
        font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)

        title = TextGUI(self, font_64, white, "Has perdido",
                        (self._x_total_half, 120))
        retry = TextGUI(self, font_32, white, "Reintentar",
                        (self._x_total_half, 270))
        exit = TextGUI(self, font_32, white, "Salir",
                       (self._x_total_half, 340))

        self._gui_elements.append(title)
        self._gui_elements.append(retry)
        self._gui_elements.append(exit)
Exemplo n.º 4
0
    def __init__(self, menu):
        AbstractScreen.__init__(self, menu, "backgrounds/main_menu.jpg")
        self._gui_elements.append(ExitButton(self, (self._x_total_half, 480)))

        repo = ResourceManager.get_player_repository()
        score = int(repo.get_parameter(PlayerRepository.ATTR_TOTAL_TIME))
        ResourceManager.append_hs(score)

        white = (255, 255, 255)
        font_64 = ResourceManager.load_font_asset("8bit.ttf", 64)
        font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)

        title = TextGUI(self, font_64, white, "Has ganado",
                        (self._x_total_half, 120))
        score = TextGUI(self, font_64, white, f"Score: {score} sec",
                        (self._x_total_half, 300))
        exit = TextGUI(self, font_32, white, "Salir",
                       (self._x_total_half, 480))

        self._gui_elements.append(title)
        self._gui_elements.append(score)
        self._gui_elements.append(exit)
Exemplo n.º 5
0
    def __init__(self, menu):
        AbstractScreen.__init__(self, menu, "backgrounds/main_menu.jpg")

        self._gui_elements.append(PlayButton(self, (self._x_total_half, 270)))
        self._gui_elements.append(ExitButton(self, (self._x_total_half, 340)))

        white = (255, 255, 255)
        font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)

        play = TextGUI(self, font_32, white, "Reanudar",
                       (self._x_total_half, 270))
        exit = TextGUI(self, font_32, white, "Salir",
                       (self._x_total_half, 340))

        self._gui_elements.append(play)
        self._gui_elements.append(exit)
Exemplo n.º 6
0
    def populate_hs_list(self, list):
        font_24 = ResourceManager.load_font_asset("8bit.ttf", 24)
        white = (255, 255, 255)
        self._gui_elements.remove(self.hs1)
        self._gui_elements.remove(self.hs2)
        self._gui_elements.remove(self.hs3)
        self._gui_elements.remove(self.hs4)
        self._gui_elements.remove(self.hs5)

        self.hs1 = TextGUI(self, font_24, white, f"{list[0][0]}    -    {list[0][1]} sec", (self._x_total_half, self._y_total * 5 / 16))
        self.hs2 = TextGUI(self, font_24, white, f"{list[1][0]}    -    {list[1][1]} sec", (self._x_total_half, self._y_total * 6.5 / 16))
        self.hs3 = TextGUI(self, font_24, white, f"{list[2][0]}    -    {list[2][1]} sec", (self._x_total_half, self._y_total * 8 / 16))
        self.hs4 = TextGUI(self, font_24, white, f"{list[3][0]}    -    {list[3][1]} sec", (self._x_total_half, self._y_total * 9.5 / 16))
        self.hs5 = TextGUI(self, font_24, white, f"{list[4][0]}    -    {list[4][1]} sec", (self._x_total_half, self._y_total * 11 / 16))

        self._gui_elements.append(self.hs1)
        self._gui_elements.append(self.hs2)
        self._gui_elements.append(self.hs3)
        self._gui_elements.append(self.hs4)
        self._gui_elements.append(self.hs5)
Exemplo n.º 7
0
    def __init__(self, position=(0, 0), text="dummy", scroll=(0, 0), color=(255, 255, 255),
                 custom_duration=None, custom_speed=None):
        AbstractSprite.__init__(self)

        font = ResourceManager.load_font_asset("8bit.ttf", 16)

        self.image = font.render(text, True, color)
        self.rect = self.image.get_rect()
        self._text = text
        self.duration = self._DEFAULT_DUR
        self.speed = self._DEFAULT_SPD

        if custom_duration is not None:
            self.cust_dur = custom_duration

        if custom_speed is not None:
            self.speed = custom_speed

        self._dur = 0
        self._scroll = scroll

        self.set_global_position(position)
        self.set_position(self._scroll)
Exemplo n.º 8
0
    def __init__(self, menu, background, title, text, options):
        AbstractScreen.__init__(self,
                                menu,
                                "backgrounds/dialog.jpg",
                                transform=True)

        self._text_area = pygame.Rect(
            self.rect.centerx - int(DialogScreen.TEXT_AREA_WIDTH / 2),
            self.rect.top + DialogScreen.TEXT_AREA_TOP_GAP,
            DialogScreen.TEXT_AREA_WIDTH, DialogScreen.TEXT_AREA_HEIGHT)
        self.round_rect(self.image, self._text_area, 50,
                        DialogScreen.TEXT_AREA_COLOR)

        self._options_area = pygame.Rect(
            self.rect.centerx - int(DialogScreen.OPTIONS_AREA_WIDTH / 2),
            self._text_area.centery -
            int(DialogScreen.OPTIONS_AREA_HEIGHT / 2) +
            DialogScreen.OPTIONS_AREA_TEXT_AREA_GAP,
            DialogScreen.OPTIONS_AREA_WIDTH, DialogScreen.OPTIONS_AREA_HEIGHT)
        self.round_rect(self.image, self._options_area, 50,
                        DialogScreen.OPTIONS_AREA_COLOR)

        title_font = ResourceManager.load_font_asset(
            "8bit.ttf", DialogScreen.TITLE_FONT_SIZE)
        text_font = ResourceManager.load_font_asset(
            "8bit.ttf", DialogScreen.TEXT_FONT_SIZE)

        index = 0
        for option in options:
            x_offset, y_offset = text_font.size(option.get_text())
            bpos = (self._options_area.left + x_offset,
                    self._options_area.centery)
            tpos = (self._options_area.left + x_offset,
                    self._options_area.centery)
            otext = TextGUI(self, text_font, DialogScreen.TEXT_COLOR,
                            option.get_text(), tpos)
            self._gui_elements.append(
                OptionButton(self, bpos, x_offset, y_offset,
                             option.is_valid()))
            self._gui_elements.append(otext)

            index = index + 1

        lines = self.split_text_to_fit(text, DialogScreen.TEXT_FONT_SIZE,
                                       DialogScreen.TEXT_AREA_WIDTH)
        title = TextGUI(self, title_font, DialogScreen.TITLE_COLOR, title,
                        (self._text_area.centerx, self._text_area.top +
                         DialogScreen.TITLE_TEXT_AREA_GAP))
        self._gui_elements.append(title)

        background = os.path.join("heads", background)
        self._gui_elements.append(
            EmptyButton(self,
                        (self._text_area.left + DialogScreen.HEAD_LEFT_GAP,
                         self._text_area.centery + DialogScreen.HEAD_TOP_GAP),
                        100, 100, background))

        index = 0
        for line in lines:
            ltext = TextGUI(self, text_font, DialogScreen.TEXT_COLOR,
                            "".join(line),
                            (self._text_area.centerx, self._text_area.top +
                             DialogScreen.TITLE_TEXT_AREA_GAP +
                             DialogScreen.TEXT_TITLE_GAP +
                             (DialogScreen.TEXT_FONT_SIZE * index)))
            self._gui_elements.append(ltext)
            index = index + 1