Exemplo n.º 1
0
 def update(self, *args):
     self.gui_obj.pos = Config.get_width() // 2, Config.get_height() - 100
     if self._collider is not None and self._player_collider is not None:
         if self._collider.detect_collision(self._player_collider):
             if not self._button_shown:
                 GUI.add_element(self.gui_obj)
                 self._button_shown = True
         else:
             if self._button_shown:
                 GUI.del_element(self.gui_obj.name)
                 self._button_shown = False
Exemplo n.º 2
0
 def add_buttons():
     GUI.add_element(
         MedievalButton(
             (Config.get_width() // 2, Config.get_height() // 2 + 180),
             'Connect', 29, 'connect_with_server',
             lambda: Myultyplayer.connect_with_server(
                 GUI.get_element('user_login').text,
                 GUI.get_element('server`s_ip').text)))
     GUI.add_element(
         MedievalButton(
             (Config.get_width() // 2, Config.get_height() // 2 + 280),
             'Close', 29, 'close_myultyplayer', Myultyplayer.exit))
Exemplo n.º 3
0
    def create_menu():
        GUI.get_element('game_menu').func = GameGUI.pause_menu_clear

        GUI.add_element(
            Image((Config.get_width() // 2, Config.get_height() // 2),
                  load_image("images/game_menu_gui/menu.png"), 'background'))
        GameGUI.pause_menu_elements.add('background')

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 - 50),
                'Resume', 35, 'resume', GameGUI.pause_menu_clear))
        GameGUI.pause_menu_elements.add('resume')

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 20),
                'Exit in menu', 33, 'exit', GameGUI.exit_in_menu))
        GameGUI.pause_menu_elements.add('exit')

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 90),
                'Exit in desktop', 29, 'exit_in_desktop', MainMenuGUI.exit))
        GameGUI.pause_menu_elements.add('exit_in_desktop')
Exemplo n.º 4
0
    def init():
        MainMenuGUI.remove_buttons()

        GUI.add_element(
            TextBox((Config.get_width() // 2, Config.get_height() // 2,
                     Config.get_height() // 2 + 100, 40),
                    '',
                    default_text='Login',
                    name='user_login'))
        GUI.add_element(
            TextBox((Config.get_width() // 2, Config.get_height() // 2 + 80,
                     Config.get_height() // 2 + 100, 40),
                    '',
                    default_text='Server`s IP address',
                    name='server`s_ip'))

        Myultyplayer.add_buttons()
Exemplo n.º 5
0
    def add_move_buttons():
        x = 230
        y = 280

        GUI.add_element(
            Label(
                (Config.get_width() // 2 - x,
                 Config.get_height() // 2 - y + 75), 32, 'Change control keys',
                pygame.Color('white'), 'fonts/Dot.ttf', 'lbl_change_keys'))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2 - x,
                 Config.get_height() // 2 - y + 75 * 2),
                'Move up: {}'.format(
                    pygame.key.name(SaveManager.get_entry('preferences',
                                                          'up'))), 29,
                'btn_mvup', SettingsGUI.change_button, 'up'))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2 - x,
                 Config.get_height() // 2 - y + 75 * 3),
                'Move down: {}'.format(
                    pygame.key.name(
                        SaveManager.get_entry('preferences', 'down'))), 29,
                'btn_mvdown', SettingsGUI.change_button, 'down'))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2 - x,
                 Config.get_height() // 2 - y + 75 * 4),
                'Move left: {}'.format(
                    pygame.key.name(
                        SaveManager.get_entry('preferences', 'left'))), 29,
                'btn_mvleft', SettingsGUI.change_button, 'left'))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2 - x,
                 Config.get_height() // 2 - y + 75 * 5),
                'Move right: {}'.format(
                    pygame.key.name(
                        SaveManager.get_entry('preferences', 'right'))), 29,
                'btn_mvright', SettingsGUI.change_button, 'right'))
Exemplo n.º 6
0
 def update(self, *args):
     container = self.game_object.get_component(ChatContainer)
     for msg in self.client.received.readlines():
         container.add(': '.join(self.parse(msg)))
     for event in InputManager.get_events():
         if event.type == pygame.KEYDOWN:
             if event.key == pygame.K_RETURN:
                 if not self.on_screen:
                     GUI.add_element(
                         TextBox((Config.get_width() // 8 + 10,
                                  Config.get_height() - 40,
                                  Config.get_width() // 4, 40),
                                 '',
                                 callback=self.client.send,
                                 name='message_textbox'))
                     self.on_screen = True
             elif event.key == pygame.K_ESCAPE:
                 if self.on_screen:
                     GUI.del_element('message_textbox')
                     self.on_screen = False
Exemplo n.º 7
0
    def init():
        clouds_controller = CloudsController('Con', [1, 0])
        CloudsController.generate_clouds(15, clouds_controller)

        GUI.add_element(
            Image((Config.get_width() // 2, Config.get_height() // 2),
                  pygame.transform.scale(
                      load_image('images/main_menu/sky.png'),
                      (Config.get_width(), Config.get_height())), 'sky'))
        GUI.add_element(clouds_controller)

        GUI.add_element(
            Image((Config.get_width() // 2, 75),
                  load_image('images/main_menu/title_bg.png'), 'title'))
        GUI.add_element(
            Label((Config.get_width() // 2, 159), 53, 'Untitled game',
                  Color('white'), 'fonts/Dot.ttf', 'title_text'))

        MainMenuGUI.add_buttons()
Exemplo n.º 8
0
    def add_buttons():
        GUI.add_element(
            MedievalButton((Config.get_width() // 2, Config.get_height() // 2),
                           'Start game', 35, 'start_game',
                           MainMenuGUI.start_game))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 75),
                'Multiplayer', 35, 'myultyplayer', Myultyplayer.init))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 150),
                'Settings', 35, 'settings', MainMenuGUI.load_settings))

        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 225),
                'Exit', 35, 'exit', MainMenuGUI.exit))
Exemplo n.º 9
0
    def add(self, message):
        if len(self.container) >= 5:
            GUI.del_element(self.container[0][0])
            self.container.pop(0)

        for i in range(5):
            name = 'message' + str(i)
            try:
                if name not in list(zip(*self.container))[0]:
                    break
            except IndexError:
                break

        self.container.append(
            (name,
             GUI.add_element(
                 Label((200, Config.get_height() - 80), 32, message,
                       pygame.Color('black'), 'fonts/Dot.ttf', name))))

        for name, label in self.container:
            label.pos[1] -= 50
Exemplo n.º 10
0
    def init():
        GUI.add_element(
            Image((Config.get_width() // 2, Config.get_height() // 2 + 40),
                  load_image('images/bg.png'), 'bg_img'))

        SettingsGUI.add_move_buttons()
        SettingsGUI.add_resolutions_buttons()

        GUI.add_element(
            MedievalCheckbox(
                'toggle_fullscreen', (Config.get_width() // 2 + 230,
                                      Config.get_height() // 2 + 230),
                'Toggle Fullscreen', 29,
                SaveManager.get_entry('preferences', 'fullscreen'),
                SettingsGUI.toggle_fullscreen))
        GUI.add_element(
            MedievalButton(
                (Config.get_width() // 2, Config.get_height() // 2 + 280),
                'Close', 29, 'close_settings', SettingsGUI.exit))
Exemplo n.º 11
0
 def init():
     GUI.add_element(
         MedievalButton((Config.get_width() // 2, Config.get_height() - 35),
                        'Menu', 35, 'game_menu', GameGUI.create_menu))
Exemplo n.º 12
0
    def add_resolutions_buttons():
        x = 230
        y = 280

        GUI.add_element(
            Label((Config.get_width() // 2 + x,
                   Config.get_height() // 2 - y + 75), 32,
                  'Set display resolution', pygame.Color('white'),
                  'fonts/Dot.ttf', 'lbl_set_resolution'))

        GUI.add_element(
            MedievalButton((Config.get_width() // 2 + x,
                            Config.get_height() // 2 - y + 75 * 2),
                           '1920x1080', 29, 'btn_res1080p',
                           SettingsGUI.set_resolution, 1920, 1080))

        GUI.add_element(
            MedievalButton((Config.get_width() // 2 + x,
                            Config.get_height() // 2 - y + 75 * 3), '1440x900',
                           29, 'btn_res_wxga+', SettingsGUI.set_resolution,
                           1440, 900))

        GUI.add_element(
            MedievalButton((Config.get_width() // 2 + x,
                            Config.get_height() // 2 - y + 75 * 4), '1366x768',
                           29, 'btn_res_wxga', SettingsGUI.set_resolution,
                           1366, 768))

        GUI.add_element(
            MedievalButton((Config.get_width() // 2 + x,
                            Config.get_height() // 2 - y + 75 * 5), '1280x720',
                           29, 'btn_res_720p', SettingsGUI.set_resolution,
                           1280, 720))

        GUI.add_element(
            MedievalButton((Config.get_width() // 2 + x,
                            Config.get_height() // 2 - y + 75 * 6), '1024x768',
                           29, 'btn_res_xga', SettingsGUI.set_resolution, 1024,
                           768))