mamaflykemonv2.py

Created by maelg0000

Created on April 01, 2026

3.14 KB


from激 kandinsky import fill_rect, draw_string, color
from time import sleep
from ion import keydown, KEY_OK, KEY_ZERO, KEY_UP, KEY_DOWN

# Constantes
SW, SH = 320, 222
OFF = 10
C_WHITE, C_BLACK = color(255, 255, 255), color(0, 0, 0)
ANIM_SPD = 0.08

# Variables de boite
W, H = SW - OFF * 2, 60
W_YN, H_YN = SW // 4, 60

def env():
    fill_rect(0, 0, SW, SH, color(0, 160, 255))

def draw_spike(x, y, t="down"):
    if t == "down":
        for i in range(5):
            fill_rect(x + i, y + i * 2, 10 - i * 2, 2, C_BLACK)
    elif t == "r":
        for i in range(6):
            fill_rect(x + i * 2, y + i, 2, 10 - i * 2, C_BLACK)

def draw_box(t="dialogue"):
    # Coordonnées selon le type
    bx, by, bw, bh = (OFF, SH - H - OFF, W, H) if t == "dialogue" else (SW - OFF - W_YN, SH - OFF * 2 - H - H_YN, W_YN, H_YN)
    
    # Dessin bordure dégradée (4 étapes)
    for i in range(4):
        c = i * 80
        fill_rect(bx + i * 2, by + i * 2, bw - i * 4, bh - i * 4, color(c, c, c))
    fill_rect(bx + 8, by + 8, bw - 16, bh - 16, C_WHITE)

def draw_yn_arrow(state):
    num = 23 if state == "down" else 0
    # Effacer zone flèche
    fill_rect(238, 90, 22, 40, C_WHITE)
    draw_spike(SW - OFF - W_YN + 15, SH - OFF * 2 - H - H_YN + 13 + num, "r")

def draw_next_arrow(y_off=0):
    fill_rect(SW - OFF * 4 + 3, SH - OFF * 3 - 6 + y_off, 10, 16, C_WHITE)
    draw_spike(SW - OFF * 4 + 3, SH - OFF * 3 - 3 + y_off)

def wait_next():
    levels = [0, 1, 2, 3, 2, 1]
    while True:
        for i in levels:
            draw_next_arrow(i)
            sleep(0.1)
            if keydown(KEY_OK) or keydown(KEY_ZERO): return

def animatext(user="", text="", next_step=False):
    draw_box("dialogue")
    full_txt = (user + ": " + text) if user else text
    
    if len(full_txt) > 56:
        draw_string("Trop long !", 0, 0)
        return

    # Découpage auto à 28 caractères
    t1, t2 = full_txt, ""
    if len(full_txt) > 28:
        cut = full_txt[:28].rfind(" ")
        cut = 28 if cut == -1 else cut
        t1, t2 = full_txt[:cut], full_txt[cut:].strip()

    # Animation texte
    for i in range(len(t1) + 1):
        draw_string(t1[:i], OFF * 2, SH - H + 5)
        sleep(ANIM_SPD)
    if t2:
        for i in range(len(t2) + 1):
            draw_string(t2[:i], OFF * 2, SH - H + 22)
            sleep(ANIM_SPD)
    
    if next_step: draw_next_arrow()

def ask(txtup="OUI", txtdown="NON"):
    draw_box("yn")
    pos = "up"
    draw_yn_arrow(pos)
    base_y = SH - OFF * 2 - H - H_YN + 11
    draw_string(txtup, SW - OFF - W_YN + 30, base_y + 23)
    draw_string(txtdown, SW - OFF - W_YN + 30, base_y)
    
    while not (keydown(KEY_OK) or keydown(KEY_ZERO)):
        if keydown(KEY_DOWN) and pos == "up":
            pos = "down"
            draw_yn_arrow(pos)
        elif keydown(KEY_UP) and pos == "down":
            pos = "up"
            draw_yn_arrow(pos)
        sleep(0.05)
    env()
    return pos

# --- Script ---
env()
animatext("Mamafly", "67", True)
wait_next()
animatext("", "Je suis un sigma.")
wait_next()
animatext("", "Es-tu un sigma ?")
if ask() == "down":
    animatext("", "Gg, c'est bien mec.")
else:
    animatext("", "Je te deteste.")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.