Пример #1
0
def show_hero(window, fullscreen, hero_name: str):
    """
    :param hero_name: what hero should be shown
    :return:
    """
    create_window_of_the_same_size(window, fullscreen)
    length = pygame.display.get_surface().get_width()
    width = pygame.display.get_surface().get_height()
    if os.name == "nt":
        background_image_of_unit = pygame.image.load(
            str(os.path.abspath(__file__)).split("Game")[0] +
            "textures/заготовка.png")
    else:
        background_image_of_unit = pygame.image.load("textures/заготовка.png")
    window.blit(background_image_of_unit, [0, 0])
    draw_button(window, (128, 0, 0),
                (length - 200, width - width // 10, 170, 100), "Return")
    if os.name == "nt":
        background_image_of_unit_face = pygame.image.load(
            str(os.path.abspath(__file__)).split("Game")[0] + hero_name +
            ".png")
    else:
        background_image_of_unit_face = pygame.image.load("textures/" +
                                                          hero_name + ".png")
    window.blit(background_image_of_unit_face, [40, 60])
    pygame.display.update()
    return [(length - 200, width - width // 10, 170, 100)]
Пример #2
0
def choose_units_to_kill(window, fullscreen, units):
    window = create_window_of_Field(window, fullscreen, "Field")
    length = pygame.display.get_surface().get_width()
    width = pygame.display.get_surface().get_height()
    draw_button(window, (255, 215, 0), (100, 510, 600, 80),
                "      Choose units", 85, 107, 47, 80)
    pygame.display.update()
    if len(units) > 4:
        buttons = draw_some_buttons(window, 4, [
            units[0].base.name, units[1].base.name, units[2].base.name,
            units[3].base.name
        ], (0, 0, 100, 200), 255, 215, 0, 85, 107, 47, 20)  # отступ между ними
        names = []
        for i in units[4:]:
            names += [i.base.name]
        names += ["End"]
        buttons += draw_some_buttons(window, len(names), names,
                                     (700, 0, 100, 150), 255, 215, 0, 85, 107,
                                     47, 20)  # отступ между ними
    else:
        names = []
        for i in units:
            names += [i.base.name]
        buttons = draw_some_buttons(window, len(names), names,
                                    (0, 0, 100, 200), 255, 215, 0, 85, 107, 47,
                                    20)  # отступ между ними

        buttons += draw_some_buttons(window, 1, ["End"], (700, 0, 100, 150),
                                     255, 215, 0, 85, 107, 47,
                                     20)  # отступ между ними
    pygame.display.update()
    return buttons
Пример #3
0
def draw_some_buttons(window,
                      count: int,
                      names: list,
                      paper_size: tuple,
                      color1=128,
                      color2=0,
                      color3=0,
                      text_1=218,
                      text_2=165,
                      text_3=32,
                      size=35):
    """
    :param window: window on what to put
    :param count: Count of buttons that should be drawn
    :param names: list of names of buttons
    :param paper_size: size of menu
    :return: coordinats of all buttons
    """
    answer = []
    for number in range(count):
        draw_button(
            window, (color1, color2, color3),
            (paper_size[0] + 20, paper_size[1] + 20 + 10 * number + number *
             (paper_size[3] - 40 - 10 *
              (count - 1)) // count, paper_size[2] - 40,
             (paper_size[3] - 40 - 10 * (count - 1)) // count), names[number],
            text_1, text_2, text_3, size)
        answer += [(paper_size[0] + 20, paper_size[1] + 20 + 10 * number +
                    number * (paper_size[3] - 40 - 10 * (count - 1)) // count,
                    paper_size[2] - 40,
                    (paper_size[3] - 40 - 10 * (count - 1)) // count)]
    return answer
Пример #4
0
def draw_commans(window, fullscreen):
    window = create_window_of_Field(window, fullscreen, "Field")
    length = pygame.display.get_surface().get_width()
    width = pygame.display.get_surface().get_height()
    draw_button(window, (255, 215, 0),
                (100, 510, 600, 80), "      What do you want to do?", 85, 107, 47, 80)
    pygame.display.update()
    buttons = draw_some_buttons(window, 7,
                                    ["move", "attack", "move_attack", "Wait", "Defend", "Exit", "range_attack"],
                                    (0, 0, 100, 350), 255, 215, 0, 85, 107, 47, 20)
    return buttons
Пример #5
0
def chose_with_whom_play(window, fullscreen, name1, name2):
    window = create_window_of_Field(window, fullscreen, "Field")
    length = pygame.display.get_surface().get_width()
    width = pygame.display.get_surface().get_height()
    draw_button(window, (255, 215, 0),
                (100, 510, 600, 80), "        Choose hero", 85, 107, 47, 80)
    pygame.display.update()
    buttons = draw_button2(window, (255, 215, 0), (2, 2, 90, 30), name1, 85,
                           107, 47, 25)
    buttons += draw_button2(window, (255, 215, 0), (710, 2, 90, 30), name2, 85,
                            107, 47, 25)
    pygame.display.update()
    return buttons
Пример #6
0
def show_unit(window, fullscreen, opened_catalog, array_of_Orden,
              array_of_Necro, array_of_Mage, array_of_Forest, array_of_Inferno,
              array_of_Shadows, catalogs, arrays_list, creatures_types,
              unit_name: str):
    """
    :param catalogs:
    :param arrays_list:
    :param creatures_types:
    :param array_of_Forest:
    :param opened_catalog:
    :param array_of_Orden:
    :param array_of_Shadows:
    :param fullscreen:
    :param window:
    :param unit_name: what unit should be shown
    :return: return button

    shows information about units
    """
    types = creatures_types[arrays_list[catalogs.index(opened_catalog)].index(
        unit_name)]
    creature = types

    create_window_of_the_same_size(window, fullscreen)
    length = pygame.display.get_surface().get_width()
    width = pygame.display.get_surface().get_height()
    if os.name == "nt":
        background_image_of_unit = pygame.image.load(
            str(os.path.abspath(__file__)).split("Game")[0] +
            "textures/заготовка.png")
    else:
        background_image_of_unit = pygame.image.load("textures/заготовка.png")
    window.blit(background_image_of_unit, [0, 0])
    draw_button(window, (128, 0, 0),
                (length - 200, width - width // 10, 170, 100), "Return")
    if os.name == "nt":
        background_image_of_unit_face = pygame.image.load(
            str(os.path.abspath(__file__)).split("Game")[0] + unit_name +
            ".png")
    else:
        background_image_of_unit_face = pygame.image.load("textures/" +
                                                          unit_name + ".png")
    window.blit(background_image_of_unit_face, [40, 60])
    font = pygame.font.Font(None, 20)
    text_to_print = (str(creature.__doc__).split("\n"))
    for number in range(len(text_to_print)):
        text = font.render(text_to_print[number], True, [0, 0, 0])
        window.blit(text, [40, 290 + number * 20])
    pygame.display.update()
    return [(length - 200, width - width // 10, 170, 100)]
Пример #7
0
def draw_button2(window,
                 colour: tuple,
                 coordinates: tuple,
                 names: str = "",
                 text_1=218,
                 text_2=165,
                 text_3=32,
                 size=35):

    answer = []
    draw_button(window, colour, coordinates, names, text_1, text_2, text_3,
                size)
    answer += [(coordinates[0], coordinates[1], coordinates[2], coordinates[3])
               ]
    return answer
Пример #8
0
def draw_some_buttons(window, count: int, names: list, paper_size: tuple):
    answer = []
    for number in range(count):
        draw_button(window, (128, 0, 0),
                    (paper_size[0] + 20,
                     paper_size[1] + 20 + 10 * number + number *
                     (paper_size[3] - 40 - 10 * (count - 1)) // count,
                     paper_size[2] - 40,
                     (paper_size[3] - 40 - 10 * (count - 1)) // count),
                    names[number])
        answer += [(paper_size[0] + 20,
                    paper_size[1] + 20 + 10 * number + number *
                    (paper_size[3] - 40 - 10 * (count - 1)) // count,
                    paper_size[2] - 40,
                    (paper_size[3] - 40 - 10 * (count - 1)) // count)]
    return answer
Пример #9
0
def create_window_choise(window,
                         fullscreen,
                         length: int = 800,
                         width: int = 600,
                         update=True):
    window = create_window_of_Field(window, fullscreen, "Field")
    draw_button(window, (255, 215, 0), (100, 510, 600, 80))
    pygame.display.update()
    buttons = draw_some_buttons(
        window,
        2,
        ["Orden", "Necropolis"],
        (
            100,
            500,
            200,
            # длина надписи
            1 * width // 6),
        255,
        215,
        0,
        85,
        107,
        47,
        28)  # отступ между ними
    buttons += draw_some_buttons(
        window,
        2,
        ["Inferno", "Nature Protection"],
        (
            300,
            500,
            200,  # длина надписи
            1 * width // 6),
        255,
        215,
        0,
        85,
        107,
        47,
        28)  # отступ между ними
    buttons += draw_some_buttons(
        window,
        2,
        ["Shadow League", "Mage"],
        (
            500,
            500,
            200,
            # длина надписи
            1 * width // 6),
        255,
        215,
        0,
        85,
        107,
        47,
        28)  # отступ между ними
    pygame.display.update()
    if update:
        pygame.display.update()
    return window, buttons