Amélioraton (j’espère) du script “floppy_birb” par zecake (https://my.numworks.com/python/zecake/floppy_birb)
from math import* from kandinsky import fill_rect as F,get_pixel as G,draw_string as ds,color as C from ion import keydown as kd from random import* from time import* colb=(150,200,250) bird=([0]*19,[0]*7+[1]*6+[0]*6, [0]*5+[1,1,2,2,2,1,6,6,1]+[0]*5, [0]*4+[1]+[2]*4+[1,6,6,6,6,1]+[0]*4, [0,0]+[1]*4+[2,2,2,1,6,6,6,1,6,1,0,0,0], [0,1]+[5]*4+[1,2,2,1,6,6,6,1,6,1,0,0,0], [0,1]+[5]*5+[1,2,2,1,6,6,6,6,1,0,0,0], [0,1,2,5,5,5,2,1,2,2,2]+[0]*6+[0,0], [0,0,1,2,2,2,1,2,2,2,1]+[4]*6+[1,0], [0]*3+[1]*3+[3]*3+[1,4]+[0]*6+[0,0], [0]*3+[1]+[3]*6+[1]+[4]*5+[1,0,0], [0]*4+[1,1]+[3]*5+[1]*5+[0]*3, [0]*6+[1]*5+[0]*8,[0]*19) cols=((150,200,250),(10,)*3,(249,241,36),(249,194,44),(253,104,75),(250,252,233),(253,255,250)) altCols=((150,200,250),(10,)*3)+("r",)*5 def draw(y,last_y,px,py,score,deltad,rt,lrt,move=1): cb=colb;rt=radians(rt);lrt=radians(lrt) if last_y<y:F(11,last_y-18,38,y-last_y,cb) elif last_y>y:F(11,y+15,38,last_y-y+5,cb) for idx in range(5): cx=ceil(px[idx]);cy=py[idx];ccf=ceil(68*config[2]/100);ccy=cy-ccf-15; F(cx+32,cy+15,deltad,222-cy,cb);F(cx+32,ccy,deltad,-222,cb); # F(cx+1,cy+15,29,222-cy,'g');F(cx+1,ccy,29,-222,'g'); # F(cx-1,cy+15,2,222-cy,"k");F(cx-1,ccy,2,-222,"k");F(cx+30,cy+15,2,222-cy,"k");F(cx+30,ccy,2,-222,"k"); F(cx+1,cy+15,29,222-cy,'g');F(cx+1,ccy,29,-222,'g'); F(cx-1,cy+15,2,222-cy,"k");F(cx-1,ccy,2,-222,"k") F(cx+36,cy,deltad,15,cb);F(cx+36,cy-ccf,deltad,-15,cb); # F(cx-5,cy+13,40,2,"k");F(cx-5,cy,40,2,"k");F(cx-6,cy,2,15,"k");F(cx+35,cy,2,15,"k");F(cx-5,cy-ccf-2,40,2,"k");F(cx-5,ccy,40,2,"k");F(cx-6,ccy,2,15,"k");F(cx+35,ccy,2,15,"k"); F(cx-5,cy+13,40,2,"k");F(cx-5,cy,40,2,"k");F(cx-6,cy,2,15,"k");F(cx-5,cy-ccf-2,40,2,"k");F(cx-5,ccy,40,2,"k");F(cx-6,ccy,2,15,"k") F(cx-4,cy-ccf-2,39,-11,'g');F(cx-4,cy+2,39,11,'g') srt,crt=sin(rt)*2,cos(rt)*2;pal,altPal=cols,altCols;l=bird for ys in range(14): for xs in range(19): p_x=30+floor((xs-9.5)*srt)+floor((ys-7)*crt);p_y=y+floor((ys-7)*srt)-floor((xs-9.5)*crt);cur_pix=G(p_x,p_y) if cur_pix==(82,195,0)or cur_pix==(0,0,0):break F(p_x,p_y,2,2,move and pal[l[ys][xs]]or altPal[l[ys][xs]]) if not(G(155,20)==C(82,195,0)or G(165+len(str(score))*10,20)==C(82,195,0)):ds(str(score),155,20,"w",colb) def menu(sel,config): ds("Floppy Birb",100,30,"w",colb) if sel==2:ds(">Start [OK] ",70,60,"w",colb);ds("Config ",70,80,"w",colb) elif sel==1:ds("Start ",70,60,"w",colb);ds(">Config [>] ",70,80,"w",colb) elif sel>=3:ds("Gravity : "+str(config[0])+"% ",20,80,"w",colb);ds("Jump force : "+str(config[1])+"% ",20,100,"w",colb);ds("Spaced pipes : "+str(config[2])+"% ",20,120,"w",colb);ds("Speed : "+str(config[3])+"% ",20,140,"w",colb);ds("Config",120,50,"w",colb);ds("[<] Back",10,10,"w",colb);ds(">",10,80+20*(sel-3),"w",colb) config=[90,100,115,135] def main(): M=monotonic;F(0,0,320,222,colb);y=120.0;vy=.0;r=90;px,py=[100.0,200.0,300.0,400.0,500.0],[randrange(100,200)for i in range(5)];last_y=y;last_r=90;sel=2;move=1;end=cnt=hasScored=score=0 while kd(4)+kd(52):0 while 1-kd(4)-kd(52): if kd(2)and sel==2:sel=1 while sel!=2: K=-1 if kd(1)and sel==1:sel=2;F(0,0,320,222,colb);K=1 elif kd(3)and sel==1:sel=3;F(0,0,320,222,colb);K=3 elif kd(0)and sel>=3:F(0,0,320,222,colb);sel=1;K=0 elif sel-2<len(config)and kd(2)and sel>=3:sel+=1;F(10,40,8,200,colb);K=2 elif kd(1): sel-=1;K=1 if sel>3:F(10,40,8,200,colb) else:F(0,0,320,222,colb) elif kd(45)and sel>=3:config[sel-3]+=5;sleep(.15) elif kd(46)and sel>=3:config[sel-3]-=5;sleep(.15) menu(sel,config) while kd(K):0 menu(sel,config) while kd(4)+kd(52):F(0,0,320,222,colb) mt=M();draw(ceil(y),ceil(last_y),px,py,score,2,r,last_r);delta=M()-mt;g=config[0];cfg0,cfg1,cfg2,cfg3=(i/100 for i in config);cfg3*=60 while 1-end: mt=M() if kd(4)+kd(52):cnt+=1 if cnt==1 and move:vy=(-9*cfg1);r=30 if 1-kd(4)-kd(52):cnt=0 for i in range(5): if move:px[i]=px[i]-(delta*cfg3) if px[i]<-40:px[i]=480;py[i]=randrange(100,200) if px[i]<=45 and px[i]>=-17: if not hasScored:score+=1;hasScored=0 if y+13>py[i]or y-13<py[i]-ceil(68*cfg2):move=0 if px[i]<-17:hasScored=0 draw(ceil(y),ceil(last_y),px,py,score,ceil(1+delta*cfg3),r,last_r,move);last_r,last_y=r,y;y+=vy*delta*30 if vy<10:vy+=cfg0*delta*45 if r<179:r+=delta*150 if y>=215:end=1 if y<=-10: if cfg0==0:cfg0=1 else:cfg0=abs(cfg0) delta=M()-mt ds("Score : %s"%score,108,80,"k","w");ds("Press OK to go back",60,100,"k","w");ds("to main menu",90,120,"k","w") while kd(4)+kd(52):0 while 1-kd(4)-kd(52):0 return g try: while 1:config[0]=main() except KeyboardInterrupt:0