Пример #1
0
def buttonWin_Display(
    button: Button,
    mouse_pos: Vect2d,
) -> None:
    """Affichage du texte de fin"""

    min_size = max(button.size.x, button.size.y)

    font_size = min_size * 50 / 400

    Display.drawRect(Vect2d(0, 0), Display.size, (0, 0, 0, button.alpha))

    if button.alpha < 127:
        button.alpha += 1
    elif button.alpha < 255 and Map.game_finished:
        button.alpha += 1

    score = Map.player_infos.get("score", 0)
    tps = Map.player_infos.get("time", 0)

    Display.drawText(button.text,
                     button.pos + button.size / 2,
                     color=button.color,
                     size=font_size)

    Display.drawText("Score : " + str(score),
                     button.pos + button.size / 2 + Vect2d(0, button.size.y),
                     color=button.color,
                     size=font_size)

    Display.drawText("Temps : " + str(tps) + " secondes",
                     button.pos + button.size / 2 +
                     Vect2d(0, button.size.y * 2),
                     color=button.color,
                     size=font_size)
Пример #2
0
def buttonEnd_Display(button: Button, mouse_pos: Vect2d) -> None:
    """Affichage du texte de fin"""

    min_size = max(button.size.x, button.size.y)

    font_size = min_size * 50 / 400
    # Taille de la police

    Display.drawRect(Vect2d(0, 0), Display.size, (0, 0, 0, button.alpha))
    # Fondu transparent

    if button.alpha < 127:
        # Si le jeu est en cours on a un fondu jusqu'à 50%
        button.alpha += 1
    elif button.alpha < 255 and Map.game_finished:
        # Sinon le fondu se fait jusqu'à 100%
        button.alpha += 1

    Display.drawText(button.text,
                     button.pos + button.size / 2,
                     color=button.color,
                     size=font_size)
Пример #3
0
def buttonStart_Display(button: Button, mouse_pos: Vect2d) -> bool:
    """Affichage du bouton Start

    Args:
        button (Button): bouton start
        mouse_pos (Vect2d): position de la souris
    
    Returns:
        hand_cursor (bool): si la souris doit être affichée comme une main ou un curseur
    """

    if button.isMouseOver(mouse_pos):
        # Arc-en-ciel
        hand_cursor = True
        button.color_sat = (button.color_sat - 3 + 100) % 100
    else:
        # Flash épileptique
        hand_cursor = False
        button.color_sat = 100
        button.color_hue = (button.color_hue + 1) % 360

    button_color = Color.HSVToRGB(button.color_hue, button.color_sat, 100)

    min_size = max(button.size.x, button.size.y)
    # Taille minimale entre la largeur et la hauteur

    font_size = min_size * 50 / 400

    Display.drawRect(button.pos, button.size, color=button_color, fill=True)
    # Rectangle du bouton

    Display.drawText(button.text,
                     button.pos + button.size / 2,
                     color=Color.BLACK,
                     size=font_size)
    # Texte du bouton

    return hand_cursor
Пример #4
0
def buttonEndChoice_Display(button: Button, mouse_pos: Vect2d) -> bool:
    """Affichage du bouton rejouer"""

    min_size = max(button.size.x, button.size.y)

    font_size = min_size * 50 / 400

    if button.isMouseOver(mouse_pos):
        hand_cursor = True
        c = Color.BLACK
        f = True
    else:
        hand_cursor = False
        c = button.color
        f = False

    Display.drawRect(button.pos, button.size, color=button.color, fill=f)

    Display.drawText(button.text,
                     button.pos + button.size / 2,
                     color=c,
                     size=font_size)

    return hand_cursor