Ejemplo n.º 1
0
class PauseScreen:
    def __init__(self):
        self.hidden = True
        self.width = 0
        self.max_witdh = 200

        self.init_buttons()

    def init_buttons(self):
        self.btn_back = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Back', color=COLOR_WHITE),
                               on_left_click=self.load_prev)

        self.btn_menu = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Main Menu', color=COLOR_WHITE),
                               on_left_click=self.load_menu)

        self.btn_quit = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Quit', color=COLOR_WHITE),
                               on_left_click=quit_game)

    def hide(self):
        self.width = 0
        self.hidden = True

    def load_menu(self):
        self.hide()
        ACTIVE.append('menu')

    def load_prev(self):
        self.hide()
        ACTIVE.pop()

    def render(self):
        if self.hidden:
            tint = pygame.Surface((SCREEN_SIZE.W, SCREEN_SIZE.H),
                                  pygame.SRCALPHA)
            tint.fill((0, 0, 0, 150))
            SCREEN.blit(tint, (0, 0))
            self.hidden = False

        SCREEN.fill((100, 100, 100),
                    (SCREEN_SIZE.W - self.width, 0, self.width, SCREEN_SIZE.H))

        self.btn_back.render((SCREEN_SIZE.W - self.width, 0))
        self.btn_menu.render((SCREEN_SIZE.W - self.width, 50))
        self.btn_quit.render((SCREEN_SIZE.W - self.width, 100))

        if self.width < self.max_witdh:
            self.width += 50
Ejemplo n.º 2
0
class Menu:
    def __init__(self):
        self.bg = pygame.transform.scale(
            pygame.image.load('menu/menu.png'),
            (SCREEN_SIZE.W, SCREEN_SIZE.H))

        self.init_buttons()

    def init_buttons(self):
        self.game = Button('menu', (
                (305 / 1024.0) * SCREEN_SIZE.W,
                (305 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g.png'),
            fg=pygame.image.load('menu/gf.png'),
            on_left_click=lambda: load_game(1)
        )

        self.btn_1 = Button('menu', (
                (143 / 1024.0) * SCREEN_SIZE.W,
                (143 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g1.png'),
            fg=pygame.image.load('menu/g1f.png'),
            text=Text('Game 1'),
            on_left_click=lambda: load_game(1)
        )

        self.btn_2 = Button('menu', (
                (143 / 1024.0) * SCREEN_SIZE.W,
                (143 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g2.png'),
            fg=pygame.image.load('menu/g2f.png'),
            text=Text('Game 2'),
            on_left_click=lambda: load_game(2)
        )

        self.btn_3 = Button('menu', (
                (143 / 1024.0) * SCREEN_SIZE.W,
                (143 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g3.png'),
            fg=pygame.image.load('menu/g3f.png'),
            text=Text('Game 3'),
            on_left_click=lambda: load_game(3)
        )

        self.btn_4 = Button('menu', (
                (143 / 1024.0) * SCREEN_SIZE.W,
                (143 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g4.png'),
            fg=pygame.image.load('menu/g4f.png'),
            text=Text('Game 4')
        )

        self.btn_5 = Button('menu', (
                (143 / 1024.0) * SCREEN_SIZE.W,
                (143 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/g5.png'),
            fg=pygame.image.load('menu/g5f.png'),
            text=Text('Game 5')
        )

        self.profile = Button('menu', (
                (467 / 1024.0) * SCREEN_SIZE.W,
                (92 / 768.0) * SCREEN_SIZE.H),
            bg=pygame.image.load('menu/p.png'),
            fg=pygame.image.load('menu/pf.png'),
            text=Text('VIEW MY PROFILE')
        )

    def render(self):
        SCREEN.blit(self.bg, (0, 0))

        self.game.render((
            (22 / 1024.0) * SCREEN_SIZE.W,
            (94 / 768.0) * SCREEN_SIZE.H))
        self.btn_1.render((
            (345 / 1024.0) * SCREEN_SIZE.W,
            (94 / 768.0) * SCREEN_SIZE.H))
        self.btn_2.render((
            (345 / 1024.0) * SCREEN_SIZE.W,
            (257 / 768.0) * SCREEN_SIZE.H))
        self.btn_3.render((
            (345 / 1024.0) * SCREEN_SIZE.W,
            (420 / 768.0) * SCREEN_SIZE.H))
        self.btn_4.render((
            (184 / 1024.0) * SCREEN_SIZE.W,
            (420 / 768.0) * SCREEN_SIZE.H))
        self.btn_5.render((
            (22 / 1024.0) * SCREEN_SIZE.W,
            (420 / 768.0) * SCREEN_SIZE.H))
        self.profile.render((
            (22 / 1024.0) * SCREEN_SIZE.W,
            (582 / 768.0) * SCREEN_SIZE.H))
Ejemplo n.º 3
0
class Menu:
    def __init__(self):
        self.bg = pygame.transform.scale(pygame.image.load('menu/menu.png'),
                                         (SCREEN_SIZE.W, SCREEN_SIZE.H))

        self.init_buttons()

    def init_buttons(self):
        self.game = Button('menu', ((305 / 1024.0) * SCREEN_SIZE.W,
                                    (305 / 768.0) * SCREEN_SIZE.H),
                           bg=pygame.image.load('menu/g.png'),
                           fg=pygame.image.load('menu/gf.png'),
                           on_left_click=lambda: load_game(1))

        self.btn_1 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g1.png'),
                            fg=pygame.image.load('menu/g1f.png'),
                            text=Text('Game 1'),
                            on_left_click=lambda: load_game(1))

        self.btn_2 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g2.png'),
                            fg=pygame.image.load('menu/g2f.png'),
                            text=Text('Game 2'),
                            on_left_click=lambda: load_game(2))

        self.btn_3 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g3.png'),
                            fg=pygame.image.load('menu/g3f.png'),
                            text=Text('Game 3'),
                            on_left_click=lambda: load_game(3))

        self.btn_4 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g4.png'),
                            fg=pygame.image.load('menu/g4f.png'),
                            text=Text('Game 4'))

        self.btn_5 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g5.png'),
                            fg=pygame.image.load('menu/g5f.png'),
                            text=Text('Game 5'))

        self.profile = Button('menu', ((467 / 1024.0) * SCREEN_SIZE.W,
                                       (92 / 768.0) * SCREEN_SIZE.H),
                              bg=pygame.image.load('menu/p.png'),
                              fg=pygame.image.load('menu/pf.png'),
                              text=Text('VIEW MY PROFILE'))

    def render(self):
        SCREEN.blit(self.bg, (0, 0))

        self.game.render(
            ((22 / 1024.0) * SCREEN_SIZE.W, (94 / 768.0) * SCREEN_SIZE.H))
        self.btn_1.render(
            ((345 / 1024.0) * SCREEN_SIZE.W, (94 / 768.0) * SCREEN_SIZE.H))
        self.btn_2.render(
            ((345 / 1024.0) * SCREEN_SIZE.W, (257 / 768.0) * SCREEN_SIZE.H))
        self.btn_3.render(
            ((345 / 1024.0) * SCREEN_SIZE.W, (420 / 768.0) * SCREEN_SIZE.H))
        self.btn_4.render(
            ((184 / 1024.0) * SCREEN_SIZE.W, (420 / 768.0) * SCREEN_SIZE.H))
        self.btn_5.render(
            ((22 / 1024.0) * SCREEN_SIZE.W, (420 / 768.0) * SCREEN_SIZE.H))
        self.profile.render(
            ((22 / 1024.0) * SCREEN_SIZE.W, (582 / 768.0) * SCREEN_SIZE.H))
Ejemplo n.º 4
0
class PauseScreen:
    def __init__(self):
        self.hidden = True
        self.width = 0
        self.max_witdh = 200

        self.init_buttons()

    def init_buttons(self):
        self.btn_back = Button(
            'pause-screen',
            (self.max_witdh, 50),
            bg=(80, 80, 80),
            fg=(50, 50, 50),
            text=Text('Back', color=COLOR_WHITE),
            on_left_click=self.load_prev)

        self.btn_menu = Button(
            'pause-screen',
            (self.max_witdh, 50),
            bg=(80, 80, 80),
            fg=(50, 50, 50),
            text=Text('Main Menu', color=COLOR_WHITE),
            on_left_click=self.load_menu)

        self.btn_quit = Button(
            'pause-screen',
            (self.max_witdh, 50),
            bg=(80, 80, 80),
            fg=(50, 50, 50),
            text=Text('Quit', color=COLOR_WHITE),
            on_left_click=quit_game)

    def hide(self):
        self.width = 0
        self.hidden = True

    def load_menu(self):
        self.hide()
        ACTIVE.append('menu')

    def load_prev(self):
        self.hide()
        ACTIVE.pop()

    def render(self):
        if self.hidden:
            tint = pygame.Surface(
                (SCREEN_SIZE.W, SCREEN_SIZE.H),
                pygame.SRCALPHA)
            tint.fill((0, 0, 0, 150))
            SCREEN.blit(tint, (0, 0))
            self.hidden = False

        SCREEN.fill(
            (100, 100, 100),
            (SCREEN_SIZE.W - self.width, 0, self.width, SCREEN_SIZE.H))

        self.btn_back.render((SCREEN_SIZE.W - self.width, 0))
        self.btn_menu.render((SCREEN_SIZE.W - self.width, 50))
        self.btn_quit.render((SCREEN_SIZE.W - self.width, 100))

        if self.width < self.max_witdh:
            self.width += 50