# foot.py

Created by eta45

Created on April 19, 2021

3.7 KB

Tir au but.

```from math import *
from random import *
from ion import *
from time import *
print("Bienvenu dans foot v3.2!\nDirige la balle ou le bassin du goal\navec les fleches et appuie sur OK\nquand tu es sur la bonne position.\nBon courage et attention au vent!")
solo=int(input("Jeu a 1 ou 2? "))

def goal(joueur):
from kandinsky import *
fill_rect(0,0,320,218,color(20,200,10))
from turtle import *
goto(0,0)
if solo==1 and joueur==2:a,b=randint(-140,140),randint(-80,85)
else:
from kandinsky import *
draw_string("balle",140,105)
if solo==2 and joueur==1:draw_string("joueur 1",128,130)
if solo==2 and joueur==2:draw_string("joueur 2",128,130)
sleep(1)
fill_rect(128,100,80,40,color(20,200,10))
from turtle import *
penup(),color("black"),showturtle()
arret=False
while not arret:
if keydown(KEY_OK):
hideturtle()
a,b=position()
arret=True
a,b=a+randint(-20,20),b+randint(-18,18)
from turtle import *
speed(300),pensize(30),penup(),goto(0,0)
if solo==1 and joueur==1:
if a<=-10:
v=randint(1,10)
if v>4:n=randint(-140,0)
else:n=randint(0,110)
m=randint(-83,38)
if a>-10:
if a<10:
z=randint(1,3)
if z>1:n,m=randint(-20,20),randint(-80,35)
else:n,m=randint(-60,60),randint(-80,35)
if a>=10:
v=randint(1,10)
if v>4:n=randint(0,140)
else:
n=randint(-110,0)
m=randint(-80,35)
else:
from kandinsky import *
draw_string("goal",140,110)
if solo==2 and joueur==1:draw_string("joueur 2",128,130)
if solo==2 and joueur==2:draw_string("joueur 1",128,130)
sleep(1)
fill_rect(128,100,80,40,color(20,200,10))
from turtle import *
color("black"),penup(),showturtle()
arret=False
while not arret:
if keydown(KEY_OK):
hideturtle()
n,m=position()
arret=True
from turtle import *
if joueur==1:color("red")
else:color("blue")
if a<=-10:left(randint(90,180))
if a>-10:
if a<10:left(randint(75,105))
if a>=10:left(randint(1,90))
forward(90),backward(30),left(90),forward(45),backward(90),penup(),goto(n,m),pendown(),color("black"),left(60),forward(60),backward(60),left(60),forward(60),penup(),color("white"),goto(a,b),pendown(),pensize(32),forward(1),penup()
sleep(1)
if a>150 or a<-150 or b>99:draw_string("la balle est dehors",50,200)

def comptage():
if w<x:print("2 gagne ",x," a ",w)
if w>x:print("1 gagne ",w," a ",x)
if w==x:print("egalite (",w,"-",x,")")

l=int(input("nombre de tour:"))
w,x=0,0
for i in range(l):
u=0
goal(1)
t=int(input("gagne:1 ,perdu:2 ,doute 3:"))
if t==1:w+=1
if t==3:
t=randint(1,2)
print(t)
if t==1:w+=1
if solo==1:goal(2)
else:goal(1)
u=int(input("gagne:1 ,perdu:2 ,doute 3:"))
if u==1:x+=1
if u==3:
u=randint(1,2)
print(u)
if u==1:x+=1
comptage()
stop=False
if w==x:
while not stop:
goal(1)
n=int(input("gagne: 1 perdu: 2 doute: 3:"))
if n==3:n=randint(1,2)
if solo==1:goal(2)
else:goal(1)
o=int(input("gagne 1 perdu: 2 doute: 3:"))
if o==3:
o=randint(1,2)
if o>n:
print("1 gagne!")
t+=1
stop=True
if o<n:
t+=1
print("2 gagne!")
stop=True```