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5,5,5,5,3,3,3,5,5,3,3,5,5,5,5,5,0,0,0,5,3,3,5,5,5,3,3,5,5,0,0,0,0,0,0,0,5,5,5,0,0,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]defdraw_1(list,x,y,t):x1=x;y1=yforiinlist:ifi!=0:fill_rect(x1,y1,t,t,colors[i])x1+=tifx1>x+(16*t)-t:y1+=t;x1-=16*tdefdraw_2(list,x,y,t):x+=(16*t)-tx1=x;y1=yforiinlist:ifi!=0:fill_rect(x1,y1,t,t,colors[i])x1-=tifx1<x-(16*t)+t:y1+=t;x1+=(16*t)classplateform:def__init__(self):self.type="truc"self.posx=0self.posy=0self.long=1self.larg=1defgoto(self,x,y):self.posx=x;self.posy=ydefbuisson(self):self.type="buisson"defcaissepiece(self):self.type="caissepiece"defcaisse(self):self.type="caisse"defherbe(self):self.type="herbe"defboite(self):self.type="boite"defdraw(self,t):ifself.type=="buisson":fill_rect(self.posx+(5*t),self.posy,11*t,1*t,colors[1])fill_rect(self.posx+(3*t),self.posy+(1*t),2*t,1*t,colors[1])fill_rect(self.posx+(2*t),self.posy+(2*t),1*t,1*t,colors[1])fill_rect(self.posx+(1*t),self.posy+(3*t),1*t,2*t,colors[1])fill_rect(self.posx,self.posy+(5*t),1*t,11*t,colors[1])fill_rect(self.posx+(5*t),self.posy+(1*t),11*t,1*t,colors[6])fill_rect(self.posx+(3*t),self.posy+(2*t),3*t,1*t,colors[6])fill_rect(self.posx+(3*t),self.posy+(3*t),1*t,1*t,colors[6])fill_rect(self.posx+(2*t),self.posy+(3*t),1*t,3*t,colors[6])fill_rect(self.posx+(1*t),self.posy+(5*t),1*t,11*t,colors[6])fill_rect(self.posx+(6*t),self.posy+(2*t),10*t,1*t,colors[7])fill_rect(self.posx+(4*t),self.posy+(3*t),12*t,1*t,colors[6])fill_rect(self.posx+(3*t),self.posy+(4*t),13*t,1*t,colors[7])fill_rect(self.posx+(3*t),self.posy+(5*t),13*t,1*t,colors[6])foriinrange(6,16,2):fill_rect(self.posx+(2*t),self.posy+(i*t),14*t,1*t,colors[7])fill_rect(self.posx+(2*t),self.posy+((i+1)*t),14*t,1*t,colors[6])j=0forjinrange(16*t,((self.long-1)*(16*t)),16*t):fill_rect(self.posx+j,self.posy,16*t,1*t,colors[1])fill_rect(self.posx+j,self.posy+(1*t),16*t,1*t,colors[6])foriinrange(2,16,2):fill_rect(self.posx+j,self.posy+(i*t),16*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+((i+1)*t),16*t,1*t,colors[6])j+=16*tfill_rect(self.posx+j,self.posy,11*t,1*t,colors[1])fill_rect(self.posx+j+(9*t),self.posy+(1*t),4*t,1*t,colors[1])fill_rect(self.posx+j+(11*t),self.posy+(2*t),3*t,1*t,colors[1])fill_rect(self.posx+j+(12*t),self.posy+(3*t),3*t,2*t,colors[1])fill_rect(self.posx+j+(13*t),self.posy+(5*t),3*t,11*t,colors[1])fill_rect(self.posx+j,self.posy+(1*t),9*t,1*t,colors[6])fill_rect(self.posx+j+(8*t),self.posy+(2*t),3*t,1*t,colors[6])fill_rect(self.posx+j+(10*t),self.posy+(3*t),1*t,1*t,colors[6])fill_rect(self.posx+j+(11*t),self.posy+(3*t),1*t,3*t,colors[6])fill_rect(self.posx+j+(12*t),self.posy+(5*t),1*t,11*t,colors[6])fill_rect(self.posx+j,self.posy+(2*t),8*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+(3*t),10*t,1*t,colors[6])fill_rect(self.posx+j,self.posy+(4*t),11*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+(5*t),11*t,1*t,colors[6])foriinrange(6,16,2):fill_rect(self.posx+j,self.posy+(i*t),12*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+((i+1)*t),12*t,1*t,colors[6])forkinrange(16*t,self.larg*(16*t),16*t):j=0fill_rect(self.posx+j,self.posy+k,1*t,16*t,colors[1])fill_rect(self.posx+j+(1*t),self.posy+k,1*t,16*t,colors[6])foriinrange(0,16,2):fill_rect(self.posx+j+(2*t),self.posy+k+(i*t),14*t,1*t,colors[7])fill_rect(self.posx+j+(2*t),self.posy+k+((i+1)*t),14*t,1*t,colors[6])forjinrange(16*t,(16*t)+((self.long-2)*(16*t)),16*t):foriinrange(0,16,2):fill_rect(self.posx+j,self.posy+k+(i*t),16*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+k+((i+1)*t),16*t,1*t,colors[6])j+=16*tfill_rect(self.posx+j+(13*t),self.posy+k,3*t,16*t,colors[1])fill_rect(self.posx+j+(12*t),self.posy+k,1*t,16*t,colors[6])foriinrange(0,16,2):fill_rect(self.posx+j,self.posy+k+(i*t),12*t,1*t,colors[7])fill_rect(self.posx+j,self.posy+k+((i+1)*t),12*t,1*t,colors[6])ifself.type=="caissepiece":fill_rect(self.posx,self.posy,1*t,16*t,colors[1])fill_rect(self.posx,self.posy,16*t,1*t,colors[1])fill_rect(self.posx+(16*t),self.posy+(16*t),-1*t,-16*t,colors[1])fill_rect(self.posx+(16*t),self.posy+(16*t),-16*t,-1*t,colors[1])fill_rect(self.posx+t,self.posy+t,3*t,4*t,colors[8])fill_rect(self.posx+(t*4),self.posy+t,t,4*t,colors[1])fill_rect(self.posx+(t*12),self.posy+t,3*t,4*t,colors[8])fill_rect(self.posx+(t*11),self.posy+t,t,4*t,colors[1])fill_rect(self.posx+(t*4),self.posy+t,t,4*t,colors[1])fill_rect(self.posx+(t*8),self.posy+(t*6),t*1,4*t,colors[1])fill_rect(self.posx+t,self.posy+(t*5),14*t,t,colors[1])fill_rect(self.posx+t,self.posy+(t*6),7*t,4*t,colors[8])fill_rect(self.posx+(t*9),self.posy+(t*6),6*t,4*t,colors[8])fill_rect(self.posx+t,self.posy+(t*10),14*t,t,colors[1])fill_rect(self.posx+(t*4),self.posy+(t*11),t,4*t,colors[1])fill_rect(self.posx+(t*12),self.posy+(t*11),3*t,4*t,colors[8])fill_rect(self.posx+(t*11),self.posy+(t*11),t,4*t,colors[1])fill_rect(self.posx+(t*5),self.posy+t,6*t,4*t,colors[8])fill_rect(self.posx+(t*5),self.posy+(t*11),6*t,4*t,colors[8])fill_rect(self.posx+t,self.posy+(t*11),3*t,4*t,colors[8])ifself.type=="caisse":fill_rect(self.posx,self.posy+t,1*t,14*t,colors[1])fill_rect(self.posx+t,self.posy,14*t,1*t,colors[1])fill_rect(self.posx+(16*t),self.posy+(15*t),-1*t,-14*t,colors[1])fill_rect(self.posx+(15*t),self.posy+(16*t),-14*t,-1*t,colors[1])fill_rect(self.posx+t,self.posy+t,14*t,14*t,colors[9])fill_rect(self.posx+(t*2),self.posy+(t*2),t,t,colors[1])fill_rect(self.posx+(t*2),self.posy+(t*13),t,t,colors[1])fill_rect(self.posx+(13*t),self.posy+(2*t),t,t,colors[1])fill_rect(self.posx+(13*t),self.posy+(13*t),t,t,colors[1])fill_rect(self.posx+(5*t),self.posy+(3*t),t*2,t*3,colors[1])fill_rect(self.posx+(6*t),self.posy+(2*t),t*4,t*2,colors[1])fill_rect(self.posx+(9*t),self.posy+(3*t),t*2,t*4,colors[1])fill_rect(self.posx+(8*t),self.posy+(6*t),t*2,t*2,colors[1])fill_rect(self.posx+(7*t),self.posy+(7*t),t*2,t*4,colors[1])fill_rect(self.posx+(7*t),self.posy+(12*t),t*2,t*2,colors[1])ifself.type=="herbe":fill_rect(self.posx,self.posy,self.larg*(16*t),self.long*(16*t),colors[6])fill_rect(self.posx,self.posy,self.larg*(16*t),t,colors[7])ifself.type=="boite":fill_rect(self.posx,self.posy+t,1*t,14*t,colors[1])fill_rect(self.posx+t,self.posy,14*t,1*t,colors[1])fill_rect(self.posx+(16*t),self.posy+(15*t),-1*t,-14*t,colors[1])fill_rect(self.posx+(15*t),self.posy+(16*t),-14*t,-1*t,colors[1])fill_rect(self.posx+t,self.posy+t,14*t,14*t,colors[9])defdeplace(self,v):self.posx+=vclassfeu:def__init__(self):self.x=0self.y=0self.vx=0self.vy=0defdraw(self):fill_rect(self.x,self.y+2,8,4,(255,180,0))fill_rect(self.x+2,self.y,4,8,(255,180,0))classmario:def__init__(self):self.x=0self.y=0self.vx=0self.vy=0self.move=-1self.orient=0self.bonus="no"self.start=(0,0)defdraw(self):ifself.orient==0:ifself.move==-1:draw_1(mario1,self.x,self.y,2)elifself.move==1:draw_1(mario2,self.x,self.y,2)elifself.orient==1:ifself.move==-1:draw_2(mario1,self.x,self.y,2)elifself.move==1:draw_2(mario2,self.x,self.y,2)defdeplace(self,list,f,n):self.x+=trunc(self.vx)self.y+=trunc(self.vy)self.vy=2+self.vy*0.99self.vx=self.vx*0.9ifabs(self.vx)<1:self.vx=0a=0foriinf:iff[a]!=0:f[a].x+=trunc(f[a].vx)f[a].y+=trunc(f[a].vy)f[a].vy=2+f[a].vyf[a].vx=f[a].vxiff[a].x>320orf[a].x<0orf[a].y>222:f[a]=0a+=1a=0foriinlist:iflist[a].type=="buisson"andlist[a].posx-16<self.x<list[a].posx+(list[a].long*32)-16andlist[a].posy-64<self.y<list[a].posy-32:self.vy=0self.y=list[a].posy-60iflist[a].type=="caisse"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy-64<self.y<list[a].posy-32:self.vy=0self.y=list[a].posy-60eliflist[a].type=="caisse"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy+16<self.y<list[a].posy+32:list[a].boite()colors[3]=(255,180,0);colors[5]=(255,0,0);self.bonus="yes"self.vy=0.01eliflist[a].type=="caisse"andlist[a].posx-32<self.x<list[a].posxandlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx-32self.vx=0eliflist[a].type=="caisse"andlist[a].posx<self.x<list[a].posx+32andlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx+32self.vx=0iflist[a].type=="boite"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy-64<self.y<list[a].posy-32:self.vy=0self.y=list[a].posy-60eliflist[a].type=="boite"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy+16<self.y<list[a].posy+32:self.vy=0.01self.y=list[a].posy+32eliflist[a].type=="boite"andlist[a].posx-32<self.x<list[a].posxandlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx-32self.vx=0eliflist[a].type=="boite"andlist[a].posx<self.x<list[a].posx+32andlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx+32self.vx=0iflist[a].type=="caissepiece"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy-64<self.y<list[a].posy-32:self.vy=0self.y=list[a].posy-60eliflist[a].type=="caissepiece"andlist[a].posx-16<self.x<list[a].posx+16andlist[a].posy+16<self.y<list[a].posy+32:self.y=list[a].posy+32self.vy=0.01list[a].posx=1000list[a].posy=1000eliflist[a].type=="caissepiece"andlist[a].posx-32<self.x<list[a].posxandlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx-32self.vx=0eliflist[a].type=="caissepiece"andlist[a].posx<self.x<list[a].posx+32andlist[a].posy-58<self.y<list[a].posy+32:self.x=list[a].posx+32self.vx=0a+=1ifself.y>150:self.vy=0ifkeydown(KEY_OK)andself.vy==0:self.vy=-16elifkeydown(KEY_LEFT):self.vx=-10;self.orient=1;self.move-=self.move*2elifkeydown(KEY_RIGHT):self.vx=10;self.orient=0;self.move-=self.move*2elifself.vy==0:self.move=-1;self.vx=0ifself.vy!=0:self.move=1ifkeydown(KEY_BACKSPACE)andself.bonus=="yes"andn==1:b=0a=0foriinf:ifi==0:f[a]=feu()f[a].x=self.x+16f[a].y=self.y+32f[a].vy=0ifself.orient==1:f[a].vx=-15elifself.orient==0:f[a].vx=15b=1breaka+=1ifb==0:n=0foriinf:n+=1f+=[feu()]f[n].x=self.x+16f[n].y=self.y+32f[n].vy=0ifself.orient==1:f[n].vx=-15elifself.orient==0:f[n].vx=15f=[]p=[]foriinrange(0,10):p+=[plateform()]p[0].buisson()p[0].posx=0p[0].posy=96p[0].long=3p[0].larg=4p[1].caissepiece()p[1].posx=200p[1].posy=96p[2].caissepiece()p[2].posx=200p[2].posy=128p[3].caisse()p[3].posx=232p[3].posy=0p[4].caissepiece()p[4].posx=232p[4].posy=128p[5].caissepiece()p[5].posx=264p[5].posy=128p[6].caissepiece()p[6].posx=296p[6].posy=96p[7].caissepiece()p[7].posx=296p[7].posy=128#p[8].caissepiece()
#p[8].posx=296
#p[8].posy=64
m=mario()n=1whileTrue:fill_rect(0,0,320,222,(0,200,255))foriinp:i.draw(2)foriinf:ifi!=0:i.draw()m.draw()m.deplace(p,f,n)#if m.x>280:
# for i in p:i.deplace(trunc(-m.vx))
# m.x=280
# m.x-=trunc(m.vx)
n+=1ifn>=4:n=1sleep(0.0)
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.