コード例 #1
0
class GameOverScene(SceneInterface):
    def __init__(self, hud: HudManager):
        self.hud = hud
        self.window = hud.get_window()
        self.background = GameImage(BACKGROUND_HOME_OVER)
        self.text = CenterText(self.window,
                               self.window.width / 2,
                               50,
                               WHITE,
                               text="Você perdeu!")

        self.voltar_button = Button(self.window, self.window.width / 2,
                                    self.window.height / 2, "VOLTAR")

    def handle_event(self, fps, state):
        if self.voltar_button.is_button_pressed():
            self.window.main_scene.change_scene('Main')

    def draw(self, state):
        self.background.draw()
        self.text.draw()
        self.voltar_button.draw()

    def update(self, state):
        self.voltar_button.update()
コード例 #2
0
class HistoryScene(SceneInterface):
    def __init__(self,
                 hud: HudManager,
                 imageHistory,
                 nextScene,
                 continue_game=True):
        self.hud = hud
        self.window = hud.get_window()
        self.fundo = GameImage(imageHistory)
        self.nextScene = nextScene
        self.continue_game = continue_game

        if self.continue_game:
            self.button_continuar = Button(self.window, WINDOW_SIZE[0] - 200,
                                           WINDOW_SIZE[1] - 100, "CERTO!")

    def handle_event(self, speed: int, scene: bool):
        pass

    def draw(self, state: bool):
        self.fundo.draw()
        if self.continue_game:
            self.button_continuar.draw()

    def update(self, state: bool):
        if self.continue_game:
            if self.button_continuar.is_button_pressed():
                self.window.main_scene.change_scene(self.nextScene)
コード例 #3
0
    def __init__(self, hud: HudManager):
        self.hud = hud
        self.window = hud.get_window()
        self.background = GameImage(BACKGROUND_HOME_OVER)
        self.text = CenterText(self.window,
                               self.window.width / 2,
                               50,
                               WHITE,
                               text="Você perdeu!")

        self.voltar_button = Button(self.window, self.window.width / 2,
                                    self.window.height / 2, "VOLTAR")
コード例 #4
0
    def __init__(self, window):
        self.hud = HudManager(window)
        self.window = window
        self.fundo = GameImage(BACKGROUND_HOME_TITLE)
        self.sound_background = GameImage(SOUND_BACKGROUND)
        self.sound_background.set_position(
            500 - self.sound_background.width / 2, 540)
        self.is_option = False

        self.sound_enable_button = ButtonClick(SOUND_ENABLE, self.window, 96,
                                               600)
        self.sound_disabled_button = ButtonClick(SOUND_DISABLED, self.window,
                                                 96, 600)
        self.jogar_button = Button(self.window, 250, self.window.height - 96,
                                   "JOGAR")
        self.sair_button = Button(self.window, self.window.width - 250,
                                  self.window.height - 96, "SAIR")
        self.opcoes_button = Button(self.window, self.window.width / 2,
                                    self.window.height - 96, "OPÇÕES")
        self.voltar_button = Button(self.window, self.window.width - 250, 600,
                                    "VOLTAR")
        self.text = CenterText(window,
                               500,
                               600,
                               color=GOLD,
                               text="SONS E MÚSICAS")
        self.time = 0.0
コード例 #5
0
    def __init__(self,
                 hud: HudManager,
                 imageHistory,
                 nextScene,
                 continue_game=True):
        self.hud = hud
        self.window = hud.get_window()
        self.fundo = GameImage(imageHistory)
        self.nextScene = nextScene
        self.continue_game = continue_game

        if self.continue_game:
            self.button_continuar = Button(self.window, WINDOW_SIZE[0] - 200,
                                           WINDOW_SIZE[1] - 100, "CERTO!")
コード例 #6
0
    def __init__(self, window):
        self.window = window
        self.button = GameImage(PAUSE_HUD)
        self.button.set_position(self.window.width - self.button.width - 10,
                                 self.window.height - 130)
        self.points = 0

        self.menu_screen = GameImage(PAUSE_SCREEN)
        self.menu_screen.set_position(
            self.window.width / 2 - self.menu_screen.width / 2, 85)

        self.menu_button = Button(self.window, self.window.width / 2, 320,
                                  "MENU")
        self.return_button = Button(self.window, self.window.width / 2, 500,
                                    "VOLTAR")

        self.show_menu = False
コード例 #7
0
class MenuHud:
    def __init__(self, window):
        self.window = window
        self.button = GameImage(PAUSE_HUD)
        self.button.set_position(self.window.width - self.button.width - 10,
                                 self.window.height - 130)
        self.points = 0

        self.menu_screen = GameImage(PAUSE_SCREEN)
        self.menu_screen.set_position(
            self.window.width / 2 - self.menu_screen.width / 2, 85)

        self.menu_button = Button(self.window, self.window.width / 2, 320,
                                  "MENU")
        self.return_button = Button(self.window, self.window.width / 2, 500,
                                    "VOLTAR")

        self.show_menu = False

    def draw(self):
        self.button.draw()
        if self.show_menu:
            self.menu_screen.draw()
            self.menu_button.draw()
            self.return_button.draw()

    def update(self):
        if self.window.get_mouse().is_button_pressed(
                1) and self.window.get_mouse().is_over_object(self.button):
            BUTTON_SOUND.play()
            self.window.main_scene.running = False
            self.show_menu = True
        elif self.window.get_keyboard().key_pressed(
                "ESCAPE") or self.return_button.is_button_pressed():
            self.window.main_scene.running = True
            self.show_menu = False
        elif self.menu_button.is_button_pressed():
            self.window.main_scene.running = True
            self.show_menu = False
            self.window.main_scene.change_scene()
コード例 #8
0
class MenuScene(SceneInterface):
    def __init__(self, window):
        self.hud = HudManager(window)
        self.window = window
        self.fundo = GameImage(BACKGROUND_HOME_TITLE)
        self.sound_background = GameImage(SOUND_BACKGROUND)
        self.sound_background.set_position(
            500 - self.sound_background.width / 2, 540)
        self.is_option = False

        self.sound_enable_button = ButtonClick(SOUND_ENABLE, self.window, 96,
                                               600)
        self.sound_disabled_button = ButtonClick(SOUND_DISABLED, self.window,
                                                 96, 600)
        self.jogar_button = Button(self.window, 250, self.window.height - 96,
                                   "JOGAR")
        self.sair_button = Button(self.window, self.window.width - 250,
                                  self.window.height - 96, "SAIR")
        self.opcoes_button = Button(self.window, self.window.width / 2,
                                    self.window.height - 96, "OPÇÕES")
        self.voltar_button = Button(self.window, self.window.width - 250, 600,
                                    "VOLTAR")
        self.text = CenterText(window,
                               500,
                               600,
                               color=GOLD,
                               text="SONS E MÚSICAS")
        self.time = 0.0

    def handle_event(self, speed, state):
        self.time -= self.window.delta_time()
        if not self.is_option:
            if self.time > 0:
                return
            if self.jogar_button.is_button_pressed():
                self.window.main_scene.change_scene('FirstHistory')
            elif self.sair_button.is_button_pressed():
                pygame.display.quit()
                pygame.quit()
                exit()
            elif self.opcoes_button.is_button_pressed():
                self.is_option = not self.is_option
        else:
            if self.voltar_button.is_button_pressed():
                self.time = 0.5
                self.is_option = not self.is_option
            if self.window.sound.get_sound_state():
                if self.sound_enable_button.is_button_pressed():
                    self.window.sound.change_sound_state()
            elif not self.window.sound.get_sound_state():
                if self.sound_disabled_button.is_button_pressed():
                    self.window.sound.change_sound_state()

    def draw(self, state):
        self.fundo.draw()

        if not self.is_option:
            self.jogar_button.draw()
            self.sair_button.draw()
            self.opcoes_button.draw()
        else:
            self.voltar_button.draw()
            self.sound_background.draw()
            self.text.draw()
            if self.window.sound.get_sound_state():
                self.sound_enable_button.draw()
            else:
                self.sound_disabled_button.draw()

    def update(self, state):
        self.jogar_button.update()
        self.voltar_button.update()
        self.sair_button.update()
        self.opcoes_button.update()