frommathimport*fromrandomimport*fromkandinskyimport*fromionimport*fromtimeimport*defdraw_string_letters(text,x,y,c1=(0,0,0),c2=(255,255,255),dec=0):forlintext:draw_string(l,x+dec,y,c1,c2)dec+=10sleep(0.05)defcarotte(x,y):fill_rect(x-8,y,16,4,(0,200,0))fill_rect(x-2,y-4,4,4,(0,200,0))fill_rect(x-6,y+4,12,8,(255,150,0))fill_rect(x-4,y+12,8,6,(255,150,0))fill_rect(x-2,y+18,4,2,(255,150,0))defcarotte_or(x,y):fill_rect(x-8,y,16,4,(0,200,0))fill_rect(x-2,y-4,4,4,(0,200,0))fill_rect(x-6,y+4,12,8,(255,220,0))fill_rect(x-4,y+12,8,6,(255,220,0))fill_rect(x-2,y+18,4,2,(255,220,0))defcarotte_pourrie(x,y):fill_rect(x-8,y,16,4,(80,100,0))fill_rect(x-2,y-4,4,4,(80,100,0))fill_rect(x-6,y+4,12,8,(20,10,40))fill_rect(x-4,y+12,8,6,(20,10,40))fill_rect(x-2,y+18,4,2,(20,10,40))deflapin1(x,y):fill_rect(x-12,y,8,20,(240,200,150))fill_rect(x+4,y,8,20,(240,200,150))fill_rect(x-10,y+2,4,18,(250,150,150))fill_rect(x+6,y+2,4,18,(250,150,150))fill_rect(x-16,y+20,32,28,(240,200,150))fill_rect(x-12,y+24,8,8,(240,)*3)fill_rect(x+4,y+24,8,8,(240,)*3)fill_rect(x-10,y+26,4,4,(30,)*3)fill_rect(x+6,y+26,4,4,(30,)*3)fill_rect(x-14,y+34,28,12,(250,150,150))fill_rect(x-5,y+34,4,4,(240,)*3)fill_rect(x+1,y+34,4,4,(240,)*3)deflapin1_2(x,y):fill_rect(x-24,y,16,20,(240,200,150))fill_rect(x+8,y,16,20,(240,200,150))fill_rect(x-20,y+2,8,18,(250,150,150))fill_rect(x+12,y+2,8,18,(250,150,150))fill_rect(x-32,y+20,64,28,(240,200,150))fill_rect(x-24,y+24,16,8,(240,)*3)fill_rect(x+8,y+24,16,8,(240,)*3)fill_rect(x-20,y+26,8,4,(30,)*3)fill_rect(x+12,y+26,8,4,(30,)*3)fill_rect(x-28,y+34,56,12,(250,150,150))fill_rect(x-10,y+34,8,4,(240,)*3)fill_rect(x+2,y+34,8,4,(240,)*3)deflapin2(x,y):fill_rect(x-12,y,8,20,(240,200,150))fill_rect(x+4,y,8,20,(240,200,150))fill_rect(x-10,y+2,4,18,(250,150,150))fill_rect(x+6,y+2,4,18,(250,150,150))fill_rect(x-16,y+20,32,28,(240,200,150))fill_rect(x-12,y+24,8,8,(240,)*3)fill_rect(x+4,y+24,8,8,(240,)*3)fill_rect(x-11,y+25,6,6,(30,)*3)fill_rect(x+5,y+25,6,6,(30,)*3)fill_rect(x-7,y+38,14,2,(250,150,150))fill_rect(x-5,y+38,4,4,(240,)*3)fill_rect(x+1,y+38,4,4,(240,)*3)deflapin2_2(x,y):fill_rect(x-24,y,16,20,(240,200,150))fill_rect(x+8,y,16,20,(240,200,150))fill_rect(x-20,y+2,8,18,(250,150,150))fill_rect(x+12,y+2,8,18,(250,150,150))fill_rect(x-32,y+20,64,28,(240,200,150))fill_rect(x-24,y+24,16,8,(240,)*3)fill_rect(x+8,y+24,16,8,(240,)*3)fill_rect(x-22,y+25,12,6,(30,)*3)fill_rect(x+10,y+25,12,6,(30,)*3)fill_rect(x-14,y+38,28,2,(250,150,150))fill_rect(x-10,y+38,8,4,(240,)*3)fill_rect(x+2,y+38,8,4,(240,)*3)deflapin3(x,y):fill_rect(x-12,y+10,8,10,(240,200,150))fill_rect(x+4,y+10,8,10,(240,200,150))fill_rect(x-10,y+12,4,8,(250,150,150))fill_rect(x+6,y+12,4,8,(250,150,150))fill_rect(x-16,y+20,32,28,(240,200,150))fill_rect(x-12,y+24,8,4,(240,)*3)fill_rect(x+4,y+24,8,4,(240,)*3)fill_rect(x-10,y+25,4,2,(30,)*3)fill_rect(x+6,y+25,4,2,(30,)*3)fill_rect(x-14,y+29,28,18,(250,150,150))fill_rect(x-5,y+29,4,4,(240,)*3)fill_rect(x+1,y+29,4,4,(240,)*3)deflapin3_2(x,y):fill_rect(x-24,y+10,16,10,(240,200,150))fill_rect(x+8,y+10,16,10,(240,200,150))fill_rect(x-20,y+12,8,8,(250,150,150))fill_rect(x+12,y+12,8,8,(250,150,150))fill_rect(x-32,y+20,64,28,(240,200,150))fill_rect(x-24,y+24,16,4,(240,)*3)fill_rect(x+8,y+24,16,4,(240,)*3)fill_rect(x-20,y+25,8,2,(30,)*3)fill_rect(x+12,y+25,8,2,(30,)*3)fill_rect(x-28,y+29,56,18,(250,150,150))fill_rect(x-10,y+29,8,4,(240,)*3)fill_rect(x+2,y+29,8,4,(240,)*3)deflapin4(x,y):fill_rect(x-11,y,8,6,(240,200,150))fill_rect(x+5,y,8,6,(240,200,150))fill_rect(x-9,y+2,4,4,(250,150,150))fill_rect(x+7,y+2,4,4,(250,150,150))fill_rect(x-12,y+6,8,7,(240,200,150))fill_rect(x+4,y+6,8,7,(240,200,150))fill_rect(x-10,y+6,4,7,(250,150,150))fill_rect(x+6,y+6,4,7,(250,150,150))fill_rect(x-11,y+13,8,7,(240,200,150))fill_rect(x+5,y+13,8,7,(240,200,150))fill_rect(x-9,y+13,4,7,(250,150,150))fill_rect(x+7,y+13,4,7,(250,150,150))fill_rect(x-16,y+20,32,28,(240,200,150))fill_rect(x-9,y+25,2,6,(30,)*3)fill_rect(x+7,y+25,2,6,(30,)*3)fill_rect(x-11,y+27,6,2,(30,)*3)fill_rect(x+5,y+27,6,2,(30,)*3)fill_rect(x-14,y+37,4,4,(250,150,150))fill_rect(x-10,y+38,4,4,(250,150,150))fill_rect(x-6,y+37,4,4,(250,150,150))fill_rect(x-2,y+38,4,4,(250,150,150))fill_rect(x+2,y+37,4,4,(250,150,150))fill_rect(x+6,y+38,4,4,(250,150,150))fill_rect(x+10,y+37,4,4,(250,150,150))deflapin4_2(x,y):fill_rect(x-22,y,16,6,(240,200,150))fill_rect(x+10,y,16,6,(240,200,150))fill_rect(x-18,y+2,8,4,(250,150,150))fill_rect(x+14,y+2,8,4,(250,150,150))fill_rect(x-24,y+6,16,7,(240,200,150))fill_rect(x+8,y+6,16,7,(240,200,150))fill_rect(x-20,y+6,8,7,(250,150,150))fill_rect(x+12,y+6,8,7,(250,150,150))fill_rect(x-22,y+13,16,7,(240,200,150))fill_rect(x+10,y+13,16,7,(240,200,150))fill_rect(x-18,y+13,8,7,(250,150,150))fill_rect(x+14,y+13,8,7,(250,150,150))fill_rect(x-32,y+20,64,28,(240,200,150))fill_rect(x-18,y+25,4,6,(30,)*3)fill_rect(x+14,y+25,4,6,(30,)*3)fill_rect(x-22,y+27,12,2,(30,)*3)fill_rect(x+10,y+27,12,2,(30,)*3)fill_rect(x-28,y+37,8,4,(250,150,150))fill_rect(x-20,y+38,8,4,(250,150,150))fill_rect(x-12,y+37,8,4,(250,150,150))fill_rect(x-4,y+38,8,4,(250,150,150))fill_rect(x+4,y+37,8,4,(250,150,150))fill_rect(x+12,y+38,8,4,(250,150,150))fill_rect(x+20,y+37,8,4,(250,150,150))deflapin(n,x,y,bigger=False):ifnotbigger:ifn==1:lapin1(x,y)elifn==2:lapin2(x,y)elifn==3:lapin3(x,y)elifn==4:lapin4(x,y)elifbigger:ifn==1:lapin1_2(x,y)elifn==2:lapin2_2(x,y)elifn==3:lapin3_2(x,y)elifn==4:lapin4_2(x,y)classCAROTTES:def__init__(self):self.x=randint(2,30)*10self.y=14self.vy=0self.t=randint(0,3)%3defdraw(self,x):ifself.t==0and13<self.y<134:carotte(self.x,self.y)elifself.t==1and13<self.y<134:carotte_or(self.x,self.y)elifself.t==2and13<self.y<134:carotte_pourrie(self.x,self.y)else:self.__init__()defmove(self):self.y+=int(self.vy)self.vy=self.vy*0.99+0.5defposlapin(self,x,bigger=False):ifx-15<self.x<x+15andnotbigger:return3elifbiggerandx-30<self.x<x+30:return3else:return1defback_ground(c1,c2,hungry=False,bg=0):fill_rect(10,10,300,140,(100-trunc(bg/2),200-bg,250-bg))fill_rect(0,162,320,60,(235,130,0))carotte(10,168);draw_string("x"+str(c1),18,168,(255,170,0),(235,130,0))carotte_or(10,198);draw_string("x"+str(c2),18,198,(255,170,0),(235,130,0))draw_string("SCORE",260,168,(255,170,0),(235,130,0));draw_string(""+str(c1+(c2*2)),260,188,(255,170,0),(235,130,0))ifhungry:draw_string("HUNGRY!",125,178,(255,170,0),(235,130,0))defstart():print(">>> RabbitGame\n>>> -Record small:615 by my father\n>>> -Record bigger:393 by me\n>>> scrit by Merle")fill_rect(0,0,320,222,(205,100,0));fill_rect(8,8,304,144,(0,0,0));fill_rect(0,160,320,2,(0,0,0))back_ground(0,0,False)draw_string("Yum it's raining.",85,20,(0,0,0),(100,200,250))draw_string("Chargement ...",95,55,(0,0,0),(100,200,250))draw_string("12/11/2023 Create by Merle",10,130,(0,0,0),(100,200,250))strLoad="loading game"foriinrange(0,10):carotte_pourrie(60+(i*20),80)foriinrange(0,10):carotte(60+(i*20),80)forjinrange(0,10):draw_string("Chargement "+str((i*10)+j)+"%",95,55,(0,0,0),(100,200,250))draw_string(strLoad[((i*10)+j)%len(strLoad)],100+((((i*10)+j)%len(strLoad))*10),105,(0,0,0),(100,200,250))draw_string("",100+(((((i*10)+j)+6)%len(strLoad))*10),105,(0,0,0),(100,200,250))sleep(1/(27-((i*10)+j)%27))defnotice():fill_rect(0,0,320,222,(205,100,0));fill_rect(8,8,304,144,(0,0,0));fill_rect(0,160,320,2,(0,0,0))back_ground(0,0,False)lapin(1,26,102)fill_rect(28,38,204,74,(0,0,0));fill_rect(30,40,200,70,(255,255,255))fill_rect(48,110,8,10,(0,0,0))fill_rect(50,110,6,10,(255,255,255))fill_rect(54,116,2,4,(0,0,0))fill_rect(56,110,2,6,(0,0,0))fill_rect(46,120,8,2,(0,0,0))fill_rect(48,120,4,2,(255,255,255))fill_rect(46,122,6,2,(0,0,0))draw_string_letters(" Hello,",35,45)draw_string_letters("I'm a Rabbit.",35,65)draw_string_letters(" [Ok]",35,85)whilenotkeydown(KEY_OK):passfill_rect(28,38,204,74,(0,0,0));fill_rect(30,40,200,70,(255,255,255))fill_rect(48,110,8,10,(0,0,0))fill_rect(50,110,6,10,(255,255,255))fill_rect(54,116,2,4,(0,0,0))draw_string_letters("Move whith arrows,",35,45)draw_string_letters("and eat carots.",35,65)draw_string_letters(" [Ok]",35,85)whilenotkeydown(KEY_OK):passfill_rect(28,38,204,74,(0,0,0));fill_rect(30,40,200,70,(255,255,255))fill_rect(48,110,8,10,(0,0,0))fill_rect(50,110,6,10,(255,255,255))fill_rect(54,116,2,4,(0,0,0))carotte(40,45)draw_string_letters(":1 point",50,45)carotte_or(40,65)draw_string_letters(":2 points",50,65)draw_string_letters(" [Ok]",35,85)whilenotkeydown(KEY_OK):passfill_rect(28,38,204,74,(0,0,0));fill_rect(30,40,200,70,(255,255,255))fill_rect(48,110,8,10,(0,0,0))fill_rect(50,110,6,10,(255,255,255))fill_rect(54,116,2,4,(0,0,0))draw_string_letters("Don't eat black",35,45)draw_string_letters("carots!",35,65)draw_string_letters("Pause:[Ok] [Ok]",35,85)whilenotkeydown(KEY_OK):passwhilekeydown(KEY_OK):passdefshop(Ca,Ca_or,bigger,bg,Buy):globalcarotte,carotte_orfill_rect(0,0,320,222,(205,100,0));fill_rect(8,8,304,144,(0,0,0));fill_rect(0,160,320,2,(0,0,0))t,L=monotonic(),0whilenotkeydown(KEY_DOWN):back_ground(Ca,Ca_or,False)draw_string("SHOP",140,20,(0,0,0),(100,200,250))draw_string("[OK] to buy",90,40,(0,0,0),(100,200,250))draw_string("[DOWN] to back",90,60,(0,0,0),(100,200,250))draw_string("< >",110,95,(0,0,0),(100,200,250))ifkeydown(KEY_OK)andL==0andnotBuyandCa_or>=50:Ca_or-=50;bigger=True;Buy=Trueelifkeydown(KEY_RIGHT)orkeydown(KEY_LEFT):L=(L+1)%2ifL==0:if1<monotonic()-t<2andnotBuy:draw_string("Big Rabbit",110,130,(0,0,0),(100,200,250))elifmonotonic()-t>2andnotBuy:t=monotonic()elifnotBuy:draw_string("Cost:50",110,130,(0,0,0),(100,200,250));carotte_or(195,130)elifBuy:draw_string("Big Rabbit",110,130,(0,0,0),(100,200,250))elifL==1:draw_string("Small Rabbit",100,130,(0,0,0),(100,200,255))ifL==0:lapin(1,160,80,True)elifL==1:lapin(1,160,80,False)ifBuyandL==0:bigger=TrueelifL==1:bigger=Falsesleep(0.1)returnCa,Ca_or,bigger,bg,Buydefgame(M,Ca=0,Ca_or=0,bigger=False,bg=0,Buy=False):try:fill_rect(0,0,320,222,(205,100,0));fill_rect(8,8,304,144,(0,0,0));fill_rect(0,160,320,2,(0,0,0))Carottes=[CAROTTES()]Mode=[["Easy","Normal","Hard","Speed","Glissades Easy","Glissades Normal","Glissades Hard","Glissades Speed",],[[5,0.4],[10,0.5],[15,0.6],[25,0.5],[5,0.8],[10,0.85],[15,0.9],[25,0.85]]]t=monotonic()whilenotkeydown(KEY_OK):ifmonotonic()-t>5:Carottes+=[CAROTTES()];t=monotonic()back_ground(Ca,Ca_or,False)draw_string("MENU",140,20,(0,0,0),(100,200,250))draw_string("[OK] to play",90,40,(0,0,0),(100,200,250))draw_string("[UP] to shop",90,60,(0,0,0),(100,200,250))draw_string("Modes:"+Mode[0][M%len(Mode[0])],90,80,(0,0,0),(100,200,250))draw_string("[EXE] Tutorial",90,100,(0,0,0),(100,200,250))forcarotteinCarottes:carotte.draw(0);carotte.move()ifkeydown(KEY_EXE):notice()elifkeydown(KEY_UP):Ca,Ca_or,bigger,bg,Buy=shop(Ca,Ca_or,bigger,bg,Buy)elifkeydown(KEY_LEFT):M-=1elifkeydown(KEY_RIGHT):M+=1sleep(1/Mode[1][M%len(Mode[0])][0])whilekeydown(KEY_OK):passd=Mode[1][M%len(Mode[0])]fill_rect(0,0,320,222,(205,100,0));fill_rect(8,8,304,144,(0,0,0));fill_rect(0,160,320,2,(0,0,0))carottes,carottes_or,Carottes=0,0,[CAROTTES()]x,vx,pos,miam,hungry,Hungry=160,0,1,False,monotonic(),Falsefps,t,redraw,game_over,spawn,glissade=d[0],monotonic(),True,False,1,d[1]whilenotgame_over:ifmonotonic()-t>spawn:t,spawn,fps=monotonic(),spawn+5,fps+1Carottes+=[CAROTTES()]ifspawn>56:ifbg==0:b=5elifbg==200:b=-5bg+=belifspawn>36:ifbg==0:b=0elifbg==200:b=-5bg+=belifspawn>16:ifbg==0:b=5elifbg==200:b=0bg+=belse:bg=0ifmonotonic()-hungry>7:Hungry=Trueifmonotonic()-hungry>10:Hungry=True;game_over=Trueifkeydown(KEY_EXE):game_over=Trueifkeydown(KEY_OK):whilekeydown(KEY_OK):passwhilenotkeydown(KEY_OK):draw_string("PAUSE",135,70,(0,0,0),(100,200,250))whilekeydown(KEY_OK):passhungry,t=monotonic(),monotonic()ifkeydown(KEY_LEFT):vx=-10;redraw=Trueelifkeydown(KEY_RIGHT):vx=10;redraw=Truex+=int(vx)vx=vx*glissadeifabs(vx)<1:vx=0else:redraw=TrueforcarotteinCarottes:carotte.move()ifcarotte.poslapin(x,bigger)==3:miam=Trueifcarotte.y>126:ifcarotte.t==2:game_over=Trueelifcarotte.t==0:carottes+=1elifcarotte.t==1:carottes_or+=1Hungry,hungry=False,monotonic()carotte.__init__()ifmiam:pos,miam=3,Falseelifpos==1:pos=2else:pos=1ifnotbigger:ifx<26:x=26;vx=0elifx>294:x=294;vx=0ifbigger:ifx<42:x=42;vx=0elifx>278:x=278;vx=0back_ground(carottes,carottes_or,Hungry,bg)lapin(pos,x,102,bigger)forcarotteinCarottes:carotte.draw(x)sleep(1/fps)Ca+=carottesCa_or+=carottes_orwhilenotkeydown(KEY_EXE):back_ground(carottes,carottes_or,Hungry)draw_string("GAME OVER",115,30,(0,0,0),(100,200,250))draw_string("[BACK] to retry",85,50,(0,0,0),(100,200,250))draw_string("[EXE] to quit",95,70,(0,0,0),(100,200,250))lapin(4,x,102,bigger)forcarotteinCarottes:carotte.draw(x);carotte.move()sleep(1/fps)exceptKeyboardInterrupt:game(M,Ca,Ca_or,bigger,bg,Buy)start()game(1)
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.