def __init__(self, master, *args, **kwargs):
     RectangleShape.__init__(self, *args, **kwargs)
     self.prog_name = Text(str(), (FONT["death_star"], 80),
                           YELLOW,
                           justify="center")
     self.prog_comment = Text(str(), (FONT["death_star"], 80),
                              YELLOW,
                              justify="center")
     self.infos_nb_selected = Text(f"0/{MAX_NB_PLAYERS}",
                                   (FONT["death_star"], 80), YELLOW)
     params_button = {
         "bg": BLUE,
         "hover_bg": BLUE_LIGHT,
         "active_bg": BLUE_DARK,
         "active_fg": YELLOW,
         "hover_sound": AUDIO["clank"],
         "on_click_sound": AUDIO["laser"],
         "outline": 5,
     }
     self.button_battle = Button(master,
                                 "Play",
                                 font=(FONT["death_star"], 80),
                                 **params_button,
                                 command=master.launch_game)
     self.default_width = 0
 def __init__(self, title: str, extension="", round_n=1, **kwargs):
     Text.__init__(self, **kwargs)
     self.__title = title
     self.__extension = extension
     self.__round_n = round_n
     self.__clock = Clock()
     self.value = 0
    def __init__(self, master: Window, action: str):
        Window.__init__(self, master=master, bg_music=master.bg_music)

        self.action = action

        self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170))
        self.frame = RectangleShape(0.4 * self.width,
                                    0.4 * self.height,
                                    BLACK,
                                    outline=3,
                                    outline_color=WHITE)
        self.escape = Text(
            "Echap (clavier) ou bouton START (manette): Annuler",
            font=("calibri", 30),
            color=WHITE)
        self.instruction = Text("Appuyez sur une touche",
                                font=("calibri", 50),
                                color=WHITE)

        for event in (pygame.KEYDOWN, pygame.JOYBUTTONDOWN,
                      pygame.JOYAXISMOTION, pygame.JOYHATMOTION):
            self.bind_event(event, self.choose)
        self.bind_key(pygame.K_ESCAPE,
                      lambda event: self.stop(sound=RESOURCES.SFX["back"]))
        self.bind_joystick(
            0, "START", lambda event: self.stop(sound=RESOURCES.SFX["back"]))
Esempio n. 4
0
 def __init__(self, master, **kwargs):
     Dialog.__init__(self, master=master, bg_color=GREEN_DARK, **kwargs)
     self.start_game = master.start_game
     self.text_title = Text("Waiting for Player 2", font=("calibri", 50))
     self.text_ip_address = Text(font=("calibri", 40))
     self.text_port_of_connection = Text(font=("calibri", 40))
     self.button_cancel = Button(self, "Return to menu", theme="option", callback=self.stop)
     self.lets_play_countdown = CountDown(self, 3, "Player 2 connected.\nGame start in {seconds} seconds", font=("calibri", 35), color=YELLOW, justify="center")
 def __init__(self, master, gameplay: FourInARowGameplay):
     Section.__init__(self, master, "Local Multiplaying", gameplay)
     self.form = Form(self)
     self.form.add_entry("P1", Text("P1 Name:", theme="form"), Entry(self))
     self.form.add_entry("P2", Text("P2 Name:", theme="form"), Entry(self))
     self.button_play = Button(self,
                               "Play",
                               theme=["option", "section"],
                               callback=self.play)
Esempio n. 6
0
 def __init__(self, master):
     Text.__init__(self,
                   str(), (FONT["death_star"], 200),
                   YELLOW,
                   center=master.center)
     self.ready_sound = pygame.mixer.Sound(AUDIO["ready"])
     self.finish_sound = pygame.mixer.Sound(AUDIO["finish"])
     self.master = master
     self.winner = None
Esempio n. 7
0
 def __init__(self, master: Window, **kwargs):
     Dialog.__init__(self, master=master, bg_color=GREEN, **kwargs)
     title_font = ("calibri", 32, "bold")
     simple_font = ("calibri", 32)
     self.text = DrawableListVertical(offset=50)
     self.text.add(
         Text("Backgroun musics and SFX\nby Eric Matyas: www.soundimage.org", font=simple_font, justify=Text.T_CENTER),
         Text("Images\ntaken in Google Image\n(except the logo)", font=simple_font, justify=Text.T_CENTER),
     )
     for text in self.text:
         text.set_custom_line_font(0, title_font)
Esempio n. 8
0
 def __init__(self, master, **kwargs):
     Dialog.__init__(self, master=master, bg_color=GREEN_DARK, **kwargs)
     self.start_game = master.start_game
     self.text_title = Text("Connect to Player 1", font=("calibri", 50))
     self.form = Form(self)
     self.form.add_entry("IP", Text("IP address", font=("calibri", 40), color=YELLOW), Entry(self, width=15, font=("calibri", 30), bg=GREEN, highlight_color=YELLOW, outline=2))
     self.form.add_entry("Port", Text("Port", font=("calibri", 40), color=YELLOW), Entry(self, width=15, font=("calibri", 30), bg=GREEN, highlight_color=YELLOW, outline=2))
     self.text_connection = Text(font=("calibri", 25), color=YELLOW)
     self.text_connection.hide()
     self.button_connect = Button(self, "Connection", theme="option", callback=self.connection)
     self.button_cancel = Button(self, "Return to menu", theme="option", callback=self.stop)
     self.lets_play_countdown = CountDown(self, 3, "Connected.\nGame start in {seconds} seconds", font=("calibri", 35), color=YELLOW, justify="center")
    def __init__(self, master):
        Window.__init__(self,
                        bg_color=master.bg_color,
                        bg_music=master.bg_music)
        params_for_button = {
            "highlight_color": YELLOW,
            "hover_sound": RESOURCES.SFX["select"],
            "on_click_sound": RESOURCES.SFX["back"]
        }
        self.master = master
        self.button_back = ImageButton(self,
                                       img=RESOURCES.IMG["blue_arrow"],
                                       **params_for_button,
                                       callback=self.stop)

        self.objects.add(master.text_highscore, master.text_money)

        self.text_title = Text("ENVIRONMENT", (RESOURCES.FONT["algerian"], 90),
                               GREEN_DARK,
                               shadow=True,
                               shadow_x=2,
                               shadow_y=2)
        self.environment = ButtonListHorizontal(offset=15)
        self.texts = DrawableList()
        for name, color in ENVIRONMENT.items():
            b = Button(self,
                       img=Image(RESOURCES.IMG[name],
                                 max_width=180,
                                 max_height=180),
                       compound="center",
                       outline=3,
                       callback=lambda env=name: self.play(env),
                       bg=color,
                       hover_bg=change_saturation(color, -20),
                       active_bg=change_brightness(color, -20),
                       hover_sound=RESOURCES.SFX["select"],
                       on_click_sound=RESOURCES.SFX["validate"],
                       highlight_color=YELLOW)
            b.set_size(200)
            self.texts.add(
                Text(name.upper(), (RESOURCES.FONT["algerian"], 50),
                     GREEN_DARK,
                     shadow=True,
                     shadow_x=2,
                     shadow_y=2))
            self.environment.add(b)

        self.bind_key(pygame.K_ESCAPE,
                      lambda event: self.stop(sound=RESOURCES.SFX["back"]))
        self.bind_joystick(
            0, "B", lambda event: self.stop(sound=RESOURCES.SFX["back"]))
 def __init__(self, master, gameplay: FourInARowGameplay):
     Section.__init__(self, master, "Play as P1", gameplay)
     self.form = Form(self)
     self.form.add_entry("P1", Text("Your Name:", theme="form"),
                         Entry(self))
     self.button_start_server = Button(self, theme=["option", "section"])
     self.text_game_status = Text(font=RESOURCES.font("heavy", 20),
                                  shadow_x=1,
                                  shadow_y=1)
     self.text_server_ip = Text(font=RESOURCES.font("afterglow", 45),
                                shadow_x=2,
                                shadow_y=1)
     self.text_server_port = Text(font=RESOURCES.font("afterglow", 45),
                                  shadow_x=2,
                                  shadow_y=1)
Esempio n. 11
0
 def __init__(self, master: Window):
     Window.__init__(self, bg_color=BLUE_DARK, bg_music=AUDIO["crusaders"])
     loading_page = Loading(font=(FONT["death_star"], 270))
     loading_page.show(master)
     self.bg_title = RectangleShape(self.width, self.height, self.bg_color)
     self.title = Text("Battle",
                       font=(FONT["death_star"], 150),
                       color=YELLOW)
     self.subtitle = Text("Choose your champions for the fight",
                          font=(FONT["death_star"], 70),
                          color=YELLOW)
     self.params_for_all_buttons = {
         "font": (FONT["death_star"], 80),
         "color": YELLOW,
         "hover_fg": (255, 255, 128),
         "hover_sound": AUDIO["clank"],
         "on_click_sound": AUDIO["laser"],
         "outline": 2,
         "outline_color": YELLOW,
         "offset": 6,
     }
     self.button_menu = TextButton(self,
                                   "Menu",
                                   **self.params_for_all_buttons,
                                   command=self.stop)
     self.champions = list()
     champion_files = sorted(
         os.path.join(CHAMPIONS_FOLDER, file)
         for file in os.listdir(CHAMPIONS_FOLDER) if file.endswith(".s"))
     for file in champion_files:
         name = get_champion_name(file)
         champion = ChampionViewer(self, file, name,
                                   **self.params_for_all_buttons)
         self.champions.append(champion)
         self.add(champion)
     self.selected = list()
     self.start_champion = 0
     self.move_champion_up = False
     self.move_champion_down = False
     self.infos = Infos(self,
                        1,
                        1,
                        self.bg_color,
                        outline=3,
                        outline_color=YELLOW)
     self.bind_key(pygame.K_ESCAPE, lambda key: self.stop())
     self.bind_event(pygame.MOUSEBUTTONDOWN, self.move_champion_list)
     loading_page.hide(self)
Esempio n. 12
0
 def __init__(self, master, **kwargs):
     Dialog.__init__(self, master=master, bg_color=GREEN_DARK, **kwargs)
     params_for_all_buttons = {
         "font": ("calibri", 30),
         "bg": GREEN,
         "hover_bg": GREEN_LIGHT,
         "active_bg": GREEN_DARK,
         "outline": 3,
         "highlight_color": YELLOW
     }
     self.start_game = master.start_game
     self.text_title = Text("Waiting for Player 2", ("calibri", 50))
     self.text_ip_address = Text(font=("calibri", 40))
     self.text_port_of_connection = Text(font=("calibri", 40))
     self.button_cancel = Button(self, "Return to menu", callback=self.stop, **params_for_all_buttons)
     self.lets_play_countdown = CountDown(self, 3, "Player 2 connected.\nGame start in {seconds} seconds", font=("calibri", 35), color=YELLOW, justify="center")
Esempio n. 13
0
 def __init__(self, master, victory: bool):
     Window.__init__(
         self,
         master=master,
         bg_music=None if victory is None else RESOURCES.MUSIC["end"])
     self.master = master
     self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170))
     self.frame = RectangleShape(0.5 * self.width,
                                 0.5 * self.height,
                                 GREEN_DARK,
                                 outline=2)
     self.victory = victory
     if victory is not None:
         message = "{winner} won".format(
             winner="You" if victory else "Enemy")
     else:
         message = "The enemy has left\nthe game"
     self.text_finish = Text(message, font=(None, 70))
     params_for_all_buttons = {
         "font": (None, 40),
         "bg": GREEN,
         "hover_bg": GREEN_LIGHT,
         "active_bg": GREEN_DARK,
         "highlight_color": YELLOW
     }
     self.button_restart = Button(self,
                                  "Restart",
                                  callback=self.restart,
                                  **params_for_all_buttons)
     self.button_return_to_menu = Button(self,
                                         "Return to menu",
                                         callback=self.stop,
                                         **params_for_all_buttons)
     self.ask_restart = False
     self.bind_key(pygame.K_ESCAPE, lambda event: self.stop())
Esempio n. 14
0
 def __init__(self, master: Window, champion_list: List[Tuple[str]]):
     Window.__init__(self, bg_music=AUDIO["battle"], bg_color=BLUE_DARK)
     self.bind_key(pygame.K_ESCAPE, lambda key: self.stop())
     loading_page = Loading(font=(FONT["death_star"], 270))
     loading_page.show(master)
     self.champions = list()
     self.not_created = list()
     for file, name in champion_list:
         champion = Champion(file, name)
         if not champion.create():
             self.not_created.append(name)
         else:
             self.champions.append(champion)
             self.add(champion)
     if len(self.not_created) == 0:
         self.memory_size = (0, 0)
         self.init_gameplay()
     else:
         msg = "\n".join(f" - {name} cannot be created"
                         for name in self.not_created)
         msg += "\n" + "\n" + "Press Escape to return\nto the menu"
         self.error_message = Text(msg, (FONT["death_star"], 70),
                                   YELLOW,
                                   justify="center",
                                   center=self.center)
     loading_page.hide(self)
 def __init__(self, master):
     Window.__init__(self, master=master, bg_music=master.bg_music)
     self.bg = RectangleShape(*self.size, (0, 0, 0, 170))
     self.frame = RectangleShape(0.50 * self.width,
                                 0.50 * self.height,
                                 GREEN,
                                 outline=3)
     self.text = Text("Are you sure you want\nto buy this car ?",
                      (RESOURCES.FONT["algerian"], 60),
                      justify=Text.T_CENTER)
     self.button_yes = Button(self,
                              "Yes",
                              self.text.font,
                              bg=GREEN,
                              hover_bg=GREEN_LIGHT,
                              active_bg=GREEN_DARK,
                              hover_sound=RESOURCES.SFX["select"],
                              on_click_sound=RESOURCES.SFX["validate"],
                              highlight_color=YELLOW,
                              callback=self.buy)
     self.button_red_cross = ImageButton(
         self,
         img=RESOURCES.IMG["red_cross"],
         active_img=RESOURCES.IMG["red_cross_hover"],
         hover_sound=RESOURCES.SFX["select"],
         on_click_sound=RESOURCES.SFX["back"],
         callback=self.stop,
         highlight_color=YELLOW)
     self.buyed = False
     self.bind_key(pygame.K_ESCAPE,
                   lambda event: self.stop(sound=RESOURCES.SFX["back"]))
     self.bind_joystick(
         0, "B", lambda event: self.stop(sound=RESOURCES.SFX["back"]))
 def __init__(self, master, gameplay: FourInARowGameplay):
     Section.__init__(self, master, "Play as P2", gameplay)
     self.form = Form(self)
     self.form.add_entry("name", Text("Your Name:", theme="form"),
                         Entry(self))
     self.form.add_entry("IP", Text("IP address:", theme="form"),
                         Entry(self, width=15))
     self.form.add_entry("port", Text("Port:", theme="form"),
                         Entry(self, width=15))
     self.button_connect = Button(self,
                                  "Connect to P1",
                                  theme=["option", "section"],
                                  callback=self.connection)
     self.text_game_status = Text(font=RESOURCES.font("heavy", 30),
                                  shadow_x=1,
                                  shadow_y=1)
 def __init__(self, master=None):
     Window.__init__(self, bg_color=None)
     if master is not None:
         self.bg = master.bg
     self.frame = RectangleShape(0.5 * self.w, 0.5 * self.h, BLUE, outline=3)
     self.title = Text("Settings", font=(FONT["death_star"], 50), color=YELLOW)
     params_for_all_scales = {
         "width": 0.7 * self.frame.w,
         "height": 50,
         "color": BLUE_DARK,
         "scale_color": BLUE_LIGHT,
         "from_": 0,
         "to": 100,
         "outline": 3
     }
     params_for_all_buttons = {
         "font": (FONT["death_star"], 45),
         "color": YELLOW,
         "hover_sound": AUDIO["clank"],
         "on_click_sound": AUDIO["laser"],
     }
     self.scale_sound_volume = Scale(
         self, **params_for_all_scales, default=Window.sound_volume() * 100,
         command=self.update_sound_volume
     )
     self.scale_music_volume = Scale(
         self, **params_for_all_scales, default=Window.music_volume() * 100,
         command=self.update_music_volume
     )
     self.button_return = TextButton(self, "Return", **params_for_all_buttons, command=self.stop)
     self.bind_key(pygame.K_ESCAPE, lambda key: self.stop())
Esempio n. 18
0
 def show_winner(self):
     winner = self.winner[self.winner.find("(") +
                          1:self.winner.find(")")] + "\nhas won."
     text = Text(winner, self.font, YELLOW)
     text.set_width(self.width)
     text.move(centerx=self.centerx, top=self.bottom + 10)
     self.master.add(text)
Esempio n. 19
0
    def __init__(self, master: Window):
        Window.__init__(self, bg_color=BACKGROUND_COLOR)
        self.bind_key(pygame.K_ESCAPE, lambda event: self.stop())

        self.master = master
        self.logo = Image(RESOURCES.IMG["logo"])
        arrow = pygame.transform.flip(RESOURCES.IMG["arrow"], True, False)
        self.button_back = ImageButton(self,
                                       img=arrow,
                                       width=100,
                                       callback=self.stop,
                                       active_offset=(0, 5),
                                       highlight_color=YELLOW)
        self.grid = FourInARowGrid(self, self.width / 2, self.height * 0.75)
        self.__player_turn = 0
        self.player_who_start_first = 0
        self.player = 0
        self.__turn = str()
        self.__turn_dict = dict()
        self.__score_player = self.__score_enemy = 0
        self.__highlight_line_window_callback = None
        self.enemy = str()

        self.ai = FourInARowAI()

        self.text_score = Text()
        self.text_player_turn = Text()
        self.left_options = ButtonListVertical(offset=50)
        self.left_options.add(
            Button(self, "Restart", theme="option", callback=self.restart),
            Button(self, "Quit game", theme="option", callback=self.quit_game))
        self.text_winner = Text()
        self.text_drawn_match = Text("Drawn match.")

        self.token_players = Grid(self)
        for row in range(2):
            self.token_players.place(CircleShape(20,
                                                 PLAYER_TOKEN_COLOR[row + 1],
                                                 outline=2,
                                                 outline_color=WHITE),
                                     row,
                                     column=1,
                                     padx=5,
                                     pady=5,
                                     justify="left")

        self.enemy_quit_dialog = EnemyQuitGame(self)
    def __init__(self, master):
        super().__init__(master, width_ratio=0.25, height_ratio=1, outline=1, outline_color=WHITE, bg_color=BLUE, bind_escape=False)
        self.bind_key(pygame.K_ESCAPE, lambda event: self.stop())
        self.bind_event(pygame.MOUSEBUTTONDOWN, self.__handle_mouse_event)

        self.master = master
        self.text_title = Text("Options", font=("calibri", 50), color=WHITE)
        self.button_list = ButtonListVertical(offset=20, justify="right")
Esempio n. 21
0
 def __init__(self, master):
     Window.__init__(self, master=master, bg_music=master.bg_music)
     self.master = master
     self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170))
     self.frame = RectangleShape(0.5 * self.width,
                                 0.5 * self.height,
                                 GREEN_DARK,
                                 outline=2)
     self.text = Text("Waiting for enemy", font=(None, 70))
Esempio n. 22
0
 def __init__(self, master: Window):
     Window.__init__(self,
                     bg_color=BLUE_DARK,
                     bg_music=AUDIO["dark_techno_city"])
     loading_page = Loading(font=(FONT["death_star"], 270))
     loading_page.show(master)
     self.title = Text("Editor",
                       font=(FONT["death_star"], 150),
                       color=YELLOW)
     self.subtitle = Text("Choose the champion to edit",
                          font=(FONT["death_star"], 70),
                          color=YELLOW)
     self.params_for_all_buttons = {
         "font": (FONT["death_star"], 80),
         "color": YELLOW,
         "hover_fg": (255, 255, 128),
         "hover_sound": AUDIO["clank"],
         "on_click_sound": AUDIO["laser"],
         "outline": 2,
         "outline_color": YELLOW,
         "offset": 6,
     }
     self.button_menu = TextButton(self,
                                   "Menu",
                                   **self.params_for_all_buttons,
                                   command=self.stop)
     self.champions = list()
     champion_files = sorted(
         os.path.join(CHAMPIONS_FOLDER, file)
         for file in os.listdir(CHAMPIONS_FOLDER) if file.endswith(".s"))
     for file in champion_files:
         name = get_champion_name(file)
         champion = ChampionEditor(self, file, name,
                                   **self.params_for_all_buttons)
         self.champions.append(champion)
         self.add(champion)
     self.new_file = TextButton(self,
                                "New",
                                **self.params_for_all_buttons,
                                command=self.launch_assembly_editor)
     self.editors = list()
     self.bind_key(pygame.K_ESCAPE, lambda key: self.stop())
     loading_page.hide(self)
Esempio n. 23
0
 def __init__(self, master):
     Window.__init__(self, master=master)
     self.master = master
     self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170))
     self.frame = RectangleShape(0.5 * self.width, 0.5 * self.height, GREEN_DARK, outline=2)
     self.victory = None
     self.text_finish = Text(font=(None, 70))
     self.button_restart = Button(self, "Restart", font=(None, 40), callback=self.restart)
     self.button_return_to_menu = Button(self, "Return to menu", font=(None, 40), callback=self.stop)
     self.ask_restart = False
     self.bind_key(pygame.K_ESCAPE, lambda event: self.stop())
 def __init__(self, master, title: str, gameplay: FourInARowGameplay):
     Dialog.__init__(self, master, bg_color=BLUE)
     self.master = master
     self.gameplay = gameplay
     arrow = pygame.transform.flip(RESOURCES.IMG["arrow"], True, False)
     self.button_back = ImageButton(self,
                                    img=arrow,
                                    width=50,
                                    callback=self.stop,
                                    active_offset=(0, 5),
                                    highlight_color=YELLOW)
     self.title = Text(title)
Esempio n. 25
0
 def __init__(self, master, **kwargs):
     Dialog.__init__(self, master=master, bg_color=GREEN_DARK, **kwargs)
     params_for_all_buttons = {
         "font": ("calibri", 30),
         "bg": GREEN,
         "hover_bg": GREEN_LIGHT,
         "active_bg": GREEN_DARK,
         "highlight_color": YELLOW,
         "outline": 3
     }
     self.start_game = NavySetup(2)
     self.text_title = Text("Connect to Player 1", ("calibri", 50))
     self.ip = Entry(self, width=15, font=("calibri", 40), bg=GREEN, highlight_color=YELLOW, outline=2)
     self.text_ip_address = Text("IP address", ("calibri", 40), YELLOW)
     self.port = Entry(self, width=15, font=("calibri", 40), bg=GREEN, highlight_color=YELLOW, outline=2)
     self.text_port_of_connection = Text("Port", ("calibri", 40), YELLOW)
     self.text_connection = Text(font=("calibri", 25), color=YELLOW)
     self.text_connection.hide()
     self.button_connect = Button(self, "Connection", callback=self.connection, **params_for_all_buttons)
     self.button_cancel = Button(self, "Return to menu", callback=self.stop, **params_for_all_buttons)
     self.lets_play_countdown = CountDown(self, 3, "Connected.\nGame start in {seconds} seconds", font=("calibri", 35), color=YELLOW, justify="center")
Esempio n. 26
0
 def on_quit(self):
     if len(self.editors) > 0:
         bg = RectangleShape(self.w, self.h, (0, 0, 0, 128))
         bg.draw(self.window)
         text = Text("Waiting for you to close all the editors",
                     (FONT["death_star"], 70), YELLOW)
         text.move(center=self.center)
         text.draw(self.window)
         self.refresh()
         while len(self.editors) > 0:
             self.check_process()
             self.main_clock.tick(self.fps)
             pygame.event.pump()
Esempio n. 27
0
 def __init__(self):
     Window.__init__(self, bg_color=(0, 200, 255))
     self.player_id = 0
     self.button_back = ImageButton(self, RESOURCES.IMG["arrow_blue"], rotate=180, size=50, callback=self.stop, highlight_color=YELLOW)
     self.player_grid = PlayerNavy(self, self.client_socket)
     self.opposite_grid = OppositeNavy(self, self.client_socket)
     self.ai = AI()
     self.turn_checker = TurnArrow()
     self.restart = False
     self.bind_key(pygame.K_ESCAPE, lambda event: self.stop())
     self.text_finish = Text("Finish !!!", font=(None, 120), color=WHITE)
     self.window_finish = FinishWindow(self)
     self.game_finished = False
Esempio n. 28
0
 def draw_selected_champions(self):
     selected = "\n".join(f"{i + 1} - {champion.get_text()}"
                          for i, champion in enumerate(self.selected))
     for _ in range(len(self.selected), MAX_NB_PLAYERS + 2):
         selected += "\n"
     selected += "Let's play !"
     text = Text(selected, (FONT["death_star"], 80), YELLOW)
     length = len(selected)
     while text.width > self.infos.default_width:
         length -= 1
         text.string = textwrap.fill(selected, width=length)
     text.move(centerx=self.infos.centerx, top=self.infos.top + 10)
     self.add(text)
     return text
Esempio n. 29
0
 def __init__(self, master: Window):
     Dialog.__init__(self,
                     master,
                     bg_color=BLUE,
                     outline=2,
                     outline_color=WHITE)
     self.master = master
     self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170))
     self.text = Text(font=RESOURCES.font("heavy", 50))
     self.button_quit = Button(self,
                               "Return to menu",
                               theme=["section"],
                               font=RESOURCES.font("heavy", 40),
                               y_add_size=-25,
                               callback=self.stop)
     self.objects.set_priority(self.bg, 0)
     self.master = master
Esempio n. 30
0
 def __init__(self, master: Window):
     Window.__init__(self)
     self.bg = master.bg
     self.title = Text("Game", font=(FONT["death_star"], 220), color=YELLOW)
     params_for_all_buttons = {
         "bg": BLUE,
         "hover_bg": BLUE_LIGHT,
         "active_bg": BLUE_DARK,
         "active_fg": YELLOW,
         "hover_sound": AUDIO["clank"],
         "on_click_sound": AUDIO["laser"],
         "outline": 5,
     }
     params_for_section_button = {
         "font": (FONT["death_star"], 200)
     }
     self.button_battle = Button(self, "Battle", **params_for_all_buttons, **params_for_section_button, command=self.launch_battle)
     self.button_edit = Button(self, "Editor", **params_for_all_buttons, **params_for_section_button, command=self.launch_editor)
     self.button_menu = Button(self, "Menu", **params_for_all_buttons, font=(FONT["death_star"], 80), command=self.stop)