Пример #1
0
def get_instruction(title: str, padding=60 // k) -> pygame.Surface:
    title_font = pygame.font.Font("resources/fonts/font.ttf", 120 // k)
    key_text_font = pygame.font.Font("resources/fonts/font.ttf", 60 // k)

    key_paddings = (30 // k, 20 // k)
    title_indent = 20 // k

    arrow_up_text = KeySurface(key_text_font.render("↑", True, (0, 255, 0)),
                               (0, 255, 0), (0, 0, 0), key_paddings)
    arrow_down_text = KeySurface(key_text_font.render("↓", True, (0, 255, 0)),
                                 (0, 255, 0), (0, 0, 0), key_paddings)
    space_text = KeySurface(
        key_text_font.render(data["space"].upper(), True, (0, 255, 0)),
        (0, 255, 0), (0, 0, 0), key_paddings)
    escape_text = KeySurface(key_text_font.render("ESC", True, (0, 255, 0)),
                             (0, 255, 0), (0, 0, 0), key_paddings)

    instructions = [{
        "keys": [arrow_up_text, arrow_down_text],
        "text": data["instructions"]["move_player"]
    }, {
        "keys": [space_text],
        "text": data["instructions"]["pause"]
    }, {
        "keys": [escape_text],
        "text": data["instructions"]["quit"]
    }]

    main_menu_surface = LearningControlsSurface(title, (0, 255, 0),
                                                instructions, padding,
                                                title_indent, key_text_font,
                                                title_font)
    return main_menu_surface
Пример #2
0
def draw_help():
    key_text_font = pygame.font.Font(f"{resources_path}fonts/font.ttf", int(60 // k))

    key_paddings = (30 // k, 20 // k)

    if not edited:
        enter_color = (0, 255, 0)
    else:
        enter_color = (255, 255, 0)

    arrow_left_text = KeySurface(key_text_font.render("←", True, (0, 255, 0)), (0, 255, 0), (0, 0, 0), key_paddings)
    arrow_right_text = KeySurface(key_text_font.render("→", True, (0, 255, 0)), (0, 255, 0), (0, 0, 0), key_paddings)
    arrow_up_text = KeySurface(key_text_font.render("↑", True, (0, 255, 0)), (0, 255, 0), (0, 0, 0), key_paddings)
    arrow_down_text = KeySurface(key_text_font.render("↓", True, (0, 255, 0)), (0, 255, 0), (0, 0, 0), key_paddings)
    enter_text = KeySurface(key_text_font.render("ENTER", True, enter_color), enter_color, (0, 0, 0),
                            key_paddings)
    escape_text = KeySurface(key_text_font.render("ESC", True, (0, 255, 0)), (0, 255, 0), (0, 0, 0), key_paddings)

    help_surface = pygame.Surface((screen_width, 300 / k))
    help_surface.blit(arrow_up_text, (5, 50 / k))
    help_surface.blit(arrow_down_text, (arrow_right_text.get_width() + 5, 50 / k))
    help_surface.blit(key_text_font.render(data["instructions"]["select"], True, (0, 255, 0)),
                      (arrow_right_text.get_width() * 2 + 50 / k, 70 / k))

    help_surface.blit(arrow_left_text, (5, 150 / k))
    help_surface.blit(arrow_right_text, (arrow_right_text.get_width() + 5, 150 / k))
    help_surface.blit(key_text_font.render(data["instructions"]["edit"], True, (0, 255, 0)),
                      (arrow_right_text.get_width() * 2 + 50 / k, 180 / k))

    help_surface.blit(enter_text, (arrow_right_text.get_width() * 2 + 550 / k, 50 / k))
    help_surface.blit(key_text_font.render(data["instructions"]["apply"], True, (0, 255, 0)),
                      (arrow_right_text.get_width() * 2 + enter_text.get_width() + 600 / k, 70 / k))

    help_surface.blit(escape_text, (arrow_right_text.get_width() * 2 + 550 / k, 150 / k))
    help_surface.blit(key_text_font.render(data["instructions"]["quit"], True, (0, 255, 0)),
                      (arrow_right_text.get_width() * 2 + escape_text.get_width() + 600 / k, 180 / k))

    window.blit(help_surface, (100 / k, screen_height - 300 / k))

    border = pygame.Rect(0, screen_height - 300 / k, screen_width, 300 / k)
    pygame.draw.rect(window, (0, 255, 0), border, 5, border_radius=5)