from ion import * from kandinsky import * from time import * from random import * x=160 y=50 sy=-3 d=20 bg=(220,220,255) st=2 xp=145 yp=170 xt,yt=-40,0 xl=[] yl=[] c=[(bg),(190,190,230),(150,150,210),(110,110,195),(60,60,180),(40,40,180),(10,10,180),(0,0,180)] bgl=[(255,220,220),(220,220,255),(220,255,220),(255,255,220),(255,220,255),(220,255,255),(255,255,255),(220,220,220)] score=0 v=0 def player(a,b,c):fill_rect(int(a),int(b),d,d,color(0,0,180)) fill_rect(0,0,320,222,color(bg)) while True: xl.append(x) yl.append(y) if len(xl)>8:xl.pop(0) if len(yl)>8:yl.pop(0) for i in range(len(xl)):fill_rect(int(xl[i]),int(yl[i]),d,d,color(c[i])) y=y+sy if sy<0:sy=sy*0.90 if sy>0:sy=sy*1.1 if abs(sy)<0.1:sy=-1*sy+1 if y+d>170 and y+d<320 and x+d>xp and x<xp+d: sy=sy*-1+1 fill_rect(xp,yp,d,10,color(bg)) xt,yt=xp,yp while True: xp=randint(5,285) if abs(x-xp)<130:break score,v=score+1,0 elif y>500-d:break yt=yt+1 fill_rect(xt,yt-1,d,1,color(bg)) fill_rect(xt,yt,d,10,"green") fill_rect(xp,yp,d,10,"green") fill_rect(0,218,320,5,"red") if keydown(KEY_LEFT) and x>0:x=x-st if keydown(KEY_RIGHT) and x<320-d:x=x+st player(x,y,sy) draw_string(str(score),150,20,"black",color(bg)) if score%10==0 and score>0 and v==0: bg=bgl[randint(0,len(bgl)-1)] c=[(bg),(190,190,230),(150,150,210),(110,110,195),(60,60,180),(40,40,180),(10,10,180),(0,0,180)] fill_rect(0,0,320,222,color(bg)) v=1 sleep((-2*10**-4)*score+0.012) for i in range(75): draw_string("*** Par AUBIN ***",i,100,"black",color(bg)) sleep(0.005)