Logo Pastebin.fr
Pastebin

Retrouvez, créez et partagez vos snippets en temps réel.

p

from graphics_nsi import*

P1 = Point(0,0)

def main():
    init_graphic(1170, 780, "Jeu")

    score = 0
    rates = 0

    while True:
        # Variables pour le gardien
        gx = 500
        sens = 1
        tir = False

        affiche_auto_off()

        # Boucle d'animation (Tant qu'on ne tire pas)
        while tir == False:
            load_image("cages_football.jpg", P1)

            gx = gx + 15 * sens
            if gx > 800:
                sens = -1
            if gx < 350:
                sens = 1

            # On place le gardien (Y=215 pour être dans tes cages)
            load_image("gardien.png", Point(gx, 215))
            
            aff_pol("Score : " + str(score) + " | Ratés : " + str(rates), 30, Point(20, 20), red)

            affiche_all()
            attendre(30)

            if is_mouse_pressed_left():
                P = get_mouse()
                tir = True

        # Résultat une fois cliqué
        affiche_auto_on()
        load_image("cages_football.jpg", P1)
        load_image("gardien.png", Point(gx, 215))
        draw_fill_circle(P, 15, white)

        # 1. On vérifie si on touche le gardien (taille image approx 100x150)
        arret = False
        if P.x > gx and P.x < gx + 100 and P.y > 215 and P.y < 365:
            arret = True

        # 2. On vérifie si on est dans les cages (Tes coordonnées)
        but = False
        if P.x > 316 and P.x < 852 and P.y > 212 and P.y < 384:
            but = True

        # 3. Verdict (L'ordre est important : Arrêt > But > Raté)
        if arret == True:
            aff_pol("ARRÊT GARDIEN", 60, Point(350, 300), orange)
            rates = rates + 1
        elif but == True:
            aff_pol("GOAL", 80, Point(450, 300), white)
            score = score + 1
        else:
            aff_pol("RATÉ", 80, Point(450, 300), red)
            rates = rates + 1
            
        attendre(1000)

    wait_escape()
    return 0

main()

Créé il y a 2 semaines.

Rechercher un Pastebin

Aucun paste trouvé.