7 et 0 pour le joueur bleu, ) et EXE pour le rouge. Envoyez le ballon dans le but adverse. Ok pour recentrer le ballon s’il est coincé
from math import * from kandinsky import * from numpy import * from ion import * fill_rect(0,0,320,222,(0,150,0)) m=[[0,0,320,0],[0,0,0,222],[320,0,320,222],[320,222,0,222]] def to(x,y,l): if abs(x-160)>160-l/2: return 1,0 if abs(y-111)>111-l/2: return 1,1 #for i in m: # lx=list(sort(array([i[0],i[2]]))) #if lx[0]+1<=x+l and lx[1]+1>=x: # ly=list(sort(array([i[1],i[3]]))) #if ly[0]+l/2<=y+l and ly[1]+l/2>=y: # a=1 #if i[0]==i[2]: # a=0 #return 1,a return 0,0 def mur(): fill_rect(0,80,7,60,(0,0,255)) fill_rect(313,80,7,60,(255,0,0)) for i in m: fill_rect(i[0]-2,i[1]-2,i[2]-i[0]+4,i[3]-i[1]+4,(255,255,255)) def recta(x,y,d,c): sx,sy=x+10*sin(d-pi/2)+5*sin(d-pi),y+10*cos(d-pi/2)+5*cos(d-pi) for i in range(5): w,z=floor(sx+2*i*sin(d)),floor(sy+2*i*cos(d)) fill_rect(round(w),round(z),2,2,c) fill_rect(round(w-20*sin(d-pi/2)),round(z-20*cos(d-pi/2)),2,2,c) w,z=sx+4*i*sin(d+pi/2),sy+4*i*cos(d+pi/2) fill_rect(round(w),round(z),2,2,c) fill_rect(round(w+10*sin(d)),round(z+10*cos(d)),2,2,c) def dist(dx,dy): return sqrt(dx**2+dy**2) mur() def init(): return [120,120,200,120],[160,110,0,0],[0,0,0,0] s=[0,0] d,d2=0,0 p,b,e=init() for x in range(0): for y in range(222): t,u=to(x,y,15) if t==1: fill_rect(x,y,1,1,(255,0,0)) while True: mur() recta(p[0],p[1],d,(0,150,0)) a=0 if keydown(KEY_SEVEN): a=2 elif keydown(KEY_ZERO): a=-1 if a==0: d+=pi/30 e[0]=0.8*(a*sin(d)+e[0]) e[1]=0.8*(a*cos(d)+e[1]) c=0 t,u=to(p[0]+e[0],p[1],15) if t==0: if dist(p[0]+e[0]-p[2],p[1]-p[3])>20: if dist(p[0]+e[0]-b[0],p[1]-b[1])<20: c=1 b[2]+=0.5*e[0] b[3]+=0.5*e[1] else: p[0]=round(p[0]+e[0]) t,u=to(p[0],p[1]+e[1],15) if t==0: if dist(p[0]-p[2],p[1]+e[1]-p[3])>20: if dist(p[0]-b[0],p[1]+e[1]-b[1])<20: if c==0: b[2]+=0.5*e[0] b[3]+=0.5*e[1] else: p[1]=round(p[1]+e[1]) recta(p[0],p[1],d,(0,0,150)) recta(p[2],p[3],d2,(0,150,0)) a=0 if keydown(KEY_RIGHTPARENTHESIS): a=2 elif keydown(KEY_EXE): a=-1 if a==0: d2+=pi/30 e[2]=0.8*(a*sin(d2)+e[2]) e[3]=0.8*(a*cos(d2)+e[3]) c=0 t,u=to(p[2]+e[2],p[3],15) if t==0 and dist(p[2]+e[2]-p[0],p[3]-p[1])>20: if dist(p[2]+e[2]-b[0],p[3]-b[1])<20: c=1 b[2]+=0.5*e[2] b[3]+=0.5*e[3] else: p[2]=round(p[2]+e[2]) t,u=to(p[2],p[3]+e[3],10) if t==0 and dist(p[2]-p[0],p[3]+e[3]-p[1])>20: if dist(p[2]-b[0],p[3]+e[3]-b[1])<20: if c==0: b[2]+=0.5*e[2] b[3]+=0.5*e[3] else: p[3]=round(p[3]+e[3]) recta(p[2],p[3],d2,(150,0,0)) fill_rect(b[0]+5,b[1]+5,10,10,(0,150,0)) b[2]*=0.95 b[3]*=0.95 t,u=to(b[0]+b[2],b[1],15) if t==0 and dist(b[0]+b[2]-p[2],b[1]-p[3])>20 and dist(b[0]+b[2]-p[0],b[1]-p[1])>20: b[0]=round(b[0]+b[2]) else: b[2]*=-0.9 t,u=to(b[0],b[1]+b[3],15) if t==0 and dist(b[1]+b[3]-p[3],b[0]-p[2])>20 and dist(b[0]-p[0],b[1]+b[3]-p[1])>20: b[1]=round(b[1]+b[3]) else: b[3]*=-0.9 fill_rect(b[0]+5,b[1]+5,10,10,(255,255,255)) if (b[0]>295 or b[0]<10) and abs(b[1]-111)<30: if b[0]>100: s[0]+=1 else: s[1]+=1 fill_rect(0,0,320,240,(0,150,0)) p,b,e=init() if keydown(KEY_OK): p,b,e=init() fill_rect(0,0,320,222,(0,150,0)) draw_string(str(s[0]),15,15,(255,255,255),(0,150,0)) draw_string(str(s[1]),300,15,(255,255,255),(0,150,0))