fromsnake_kart_8_assets_1import*classgamegeror:def__init__(self):self.gamemode=2self.menuin=0self.refresh=Trueself.deltatime=0self.deltainit=0self.nbofplayers=1self.butselect=0self.coolclick=-1self.tempslimite=60self.nombredebots=3self.aipower=2self.timerrelaunch=0self.nbjperteam=1self.typofteam=0self.scoreteam1=0self.scoreteam2=0self.oldscore1=-1self.oldscore2=-1definitmap(Game):Game.gamescene=[]Game.timer=-5Game.classement=[]Game.timerrelaunch=-5Game.scoreteam1=0Game.scoreteam2=0Game.oldscore1=-1Game.oldscore2=-1ifGame.gamemode==1orGame.gamemode==2:fill_rect(0,0,320,20,"black")fill_rect(0,20,320,210,"gray")cp=0foraddinrange(Game.nbofplayers):Game.gamescene.append(Kart(idi=cp,ai=False,Game=Game))cp+=1foraddinrange(Game.nombredebots):Game.gamescene.append(Kart(idi=cp,ai=True,Game=Game))cp+=1ifGame.gamemode==2:ifGame.nbjperteam==1:iflen(Game.gamescene)>2:Game.gamescene=[Game.gamescene[0],Game.gamescene[1]]team1=(0,1)ifGame.typofteam==1:team1=(0,2)ifGame.typofteam==2:team1=(0,3)havsetteam=[0,0]Game.balle=Ballsnick()snakeresetor(Game.gamescene,Game.nbjperteam,team1,havsetteam)defgameupdate(Game):Game.timer+=Game.deltatimeGame.timerrelaunch+=Game.deltatimeifGame.gamemode==1:ifGame.timer>=0:draw_string(str(round(Game.timer,3)),270,0,"yellow","black")elifGame.timer>=-3.5:nb=abs(floor(Game.timer))ifnb>3:nb=3draw_string(str(nb),270,0,"orange","black")else:ifGame.timerrelaunch>=0:var=(Game.timer>Game.tempslimite)and(Game.scoreteam1==Game.scoreteam2)draw_string(str(floor(Game.timer)),160,0,"red"ifvarelse"yellow","black")elifGame.timerrelaunch>=-3.5:nb=abs(floor(Game.timerrelaunch))ifnb>3:nb=3fill_rect(160,0,30,15,"black")draw_string(str(nb),160,0,"orange","black")ifGame.gamemode==1:ifGame.timer>Game.tempslimite:Game.classement=[]Game.menuin=3Game.col=getscreenper()Game.sommecol=getsommecol(Game.col,Game.nbjperteam)ifGame.nbjperteam==2:Game.classement=Game.sommecolifGame.nbjperteam==1:temp=Game.sommecol.copy()forxinrange(Game.nbofplayers+Game.nombredebots):Game.classement.append(Game.sommecol.index(max(Game.sommecol)))Game.sommecol[Game.sommecol.index(max(Game.sommecol))]=-1Game.sommecol=tempelifGame.gamemode==2:ifGame.timer>Game.tempslimite:ifGame.scoreteam1!=Game.scoreteam2:Game.menuin=0team1=(0,1)ifGame.typofteam==1:team1=(0,2)ifGame.typofteam==2:team1=(0,3)havsetteam=[0,0]Game.scoreteam1+=Game.balle.x>315Game.scoreteam2+=Game.balle.x<5ifGame.balle.x>315orGame.balle.x<5:Game.balle.reset()Game.timerrelaunch=-5snakeresetor(Game.gamescene,Game.nbjperteam,team1,havsetteam)ifGame.oldscore1!=Game.scoreteam1:Game.oldscore1=Game.scoreteam1draw_string(str(Game.scoreteam1),80,0,(255,0,0),"black")ifGame.oldscore2!=Game.scoreteam2:Game.oldscore2=Game.scoreteam2draw_string(str(Game.scoreteam2),240,0,(0,255,255),"black")Game.balle.update(Game)foreleinGame.gamescene:ele.update(Game)ele.affich(Game)defpodiumupdate(Game):ifkeydown(KEY_SHIFT):Game.menuin=0refreshmenu(Game)classKart:def__init__(self,idi,ai,Game):self.idi=idiself.isia=aiself.x=0self.y=0self.dir=0ifGame.gamemode==1:setselfterritoire(self)ifGame.gamemode==2:self.x=10self.y=100ifself.idi==0:self.gox=randint(10,315)self.goy=randint(30,215)elifself.idi==1:self.gox=randint(10,315)self.goy=randint(30,215)elifself.idi==2:self.gox=randint(10,315)self.goy=randint(30,215)elifself.idi==3:self.gox=randint(10,315)self.goy=randint(30,215)infoforallset(self)defaffich(self,Game):ifGame.gamemode==1orGame.gamemode==2:ifGame.nbjperteam==1:ifGame.gamemode==2:ifself.idi==0:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,(255,0,0))else:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,(0,255,255))else:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,self.tcolor)else:colorteam1=(255,0,0)colorteam2=(0,255,255)ifGame.typofteam==0:ifself.idiin(0,1):fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam1)else:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam2)ifGame.typofteam==1:ifself.idiin(0,2):fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam1)else:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam2)ifGame.typofteam==2:ifself.idiin(0,3):fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam1)else:fill_rect(int(self.oldx-5),int(self.oldy-5),11,11,colorteam2)predirval=0.01745329251994329*self.dirprecosval=cos(predirval)presinval=sin(predirval)stx=0sty=0forxin(0,1,2,3,4,5,6,7,8,9):stx+=precosvalsty+=presinvalset_pixel(int(self.x+stx),int(self.y+sty),self.color)self.oldx=self.xself.oldy=self.yself.olddir=self.dirdefupdate(self,Game):ifnotGame.timerrelaunch>0:returnifself.iseliminated:returnself.cango-=Game.deltatime*(self.cango>-1)ifGame.timer<0:ifself.isia:returnifkeydown(self.keyso[1]):self.chargingstartval+=Game.deltatimeelse:self.chargingstartval=0returnstartinfo(self)ifGame.gamemode==2:speedgeror(self,Game.deltatime)else:ifself.cango<=0andnotself.isia:speedgeror(self,Game.deltatime)predirval=0.01745329251994329*self.dirprecosval=cos(predirval)presinval=sin(predirval)ifself.isia:self.speed=randrange(50+10*Game.aipower,70+10*Game.aipower)self.x+=precosval*self.speed*Game.deltatimeself.y+=presinval*self.speed*Game.deltatimesetx=0sety=0forxtein(-1,0,1,2,3,4,5,6,7,8,9,10):setx+=precosvalsety+=presinvalifself.x+setx>320:self.x=320-setxself.speed=0ifself.y+sety>220:self.y=220-setyself.speed=0ifself.x+setx<0:self.x=-setxself.speed=0ifself.y+sety<20:self.y=20-setyself.speed=0ifself.speed>0andnotkeydown(self.keyso[1]):self.speed-=Game.deltatime*30elifself.speed<0andnotkeydown(self.keyso[0]):self.speed+=Game.deltatime*30ifabs(self.speed)<0.1andnot(keydown(self.keyso[0])orkeydown(self.keyso[0])):self.speed=0ifself.isiaanddistance(self.x,self.y,self.gox,self.goy)<4:self.gox=randint(10,310)self.goy=randint(30,210)self.dir=angle_to_point(self.x,self.y,self.gox,self.goy)ifkeydown(self.keyso[4])andnotself.isiaandself.cango<=0:self.coolres-=Game.deltatimebataillerespawn(self)else:self.coolres=3defrefreshpodium(Game):basepodium()ifGame.nbjperteam==1:fillserps(["green","blue","yellow","pink"],Game.classement)else:color1=(255,0,0)color2=(0,255,255)ifGame.classement[0]>Game.classement[1]:color1,color2=color2,color1fill_rect(120,120,4,40,color1)fill_rect(160,100,4,40,color2)ifGame.gamemode==1:truc=[1,0,2,3]ifGame.nbjperteam==1:forxinrange(Game.nbofplayers+Game.nombredebots):draw_string((str(Game.sommecol[Game.classement[truc[x]]]/640)+"000000")[0:3]+" %",110+x*40,40+truc[x]*20,"black",(0,200,200))else:ifGame.classement[0]<Game.classement[1]:draw_string((str(Game.classement[0]/640)+"000000")[0:3]+" %",110,60,"black",(0,200,200))draw_string((str(Game.classement[1]/640)+"000000")[0:3]+" %",150,40,"black",(0,200,200))else:draw_string((str(Game.classement[1]/640)+"000000")[0:3]+" %",110,60,"black",(0,200,200))draw_string((str(Game.classement[0]/640)+"000000")[0:3]+" %",150,40,"black",(0,200,200))draw_string("Shift pour aller au menu",20,20,"orange",(0,200,200))defaideupdate(Game):ifkeydown(KEY_SHIFT):Game.refresh=TrueGame.menuin=0defrefreshmenu(Game):valc=18blueback=(40,60,250)fill_rect(0,0,320,320,blueback)draw_string("Snake Kart 8",50,0,(255,100,10),blueback)draw_string("Aide",50,valc,"orange"ifGame.butselect==0else"red",blueback)draw_string("Jouer",50,valc*2,"orange"ifGame.butselect==1else"red",blueback)draw_string("Mode de jeu :"+("guerre","snickball")[Game.gamemode-1],50,valc*3,"orange"ifGame.butselect==2else"red",blueback)draw_string("Bots QI : "+str(("nul","facile","normal","dur","extreme","impossible")[Game.aipower]),50,valc*4,"orange"ifGame.butselect==3else"red",blueback)draw_string("Nombres de joueurs : "+str(Game.nbofplayers),50,valc*5,"orange"ifGame.butselect==4else"red",blueback)draw_string("Temps limite : "+str(Game.tempslimite),50,valc*6,"orange"ifGame.butselect==5else"red",blueback)draw_string("Nombre de bots : "+str(Game.nombredebots),50,valc*7,"orange"ifGame.butselect==6else"red",blueback)draw_string("Joueurs par equipe : "+str(Game.nbjperteam),50,valc*8,"orange"ifGame.butselect==7else"red",blueback)ifGame.nbjperteam==2:draw_string("Type d'equipe:"+str(("J1-J2:J3-J4","J1-J3:J2-J4","J1-J4:J2-J3")[Game.typofteam]),50,valc*9,"orange"ifGame.butselect==8else"red",blueback)defmenuupdate(Game):ifmonotonic()-Game.coolclick>0.2:ifkeydown(KEY_DOWN):ifGame.nbjperteam==2:ifGame.butselect==8:Game.butselect=0else:Game.butselect+=1else:ifGame.butselect==7:Game.butselect=0else:Game.butselect+=1Game.refresh=TrueGame.coolclick=monotonic()ifkeydown(KEY_UP):Game.refresh=TrueGame.coolclick=monotonic()ifGame.nbjperteam==2:ifGame.butselect==0:Game.butselect=8else:Game.butselect-=1else:ifGame.butselect==0:Game.butselect=7else:Game.butselect-=1ifGame.butselect==0:ifkeydown(KEY_OK):Game.menuin=1#info
Game.refresh=TrueifGame.butselect==1:ifkeydown(KEY_OK):Game.menuin=2#play
Game.refresh=Trueinitmap(Game)ifGame.butselect==2:ifkeydown(KEY_RIGHT):ifGame.gamemode!=2:Game.gamemode+=1Game.refresh=TrueGame.coolclick=monotonic()ifkeydown(KEY_LEFT):ifGame.gamemode!=0:Game.gamemode-=1Game.refresh=TrueGame.coolclick=monotonic()ifTrue:ifGame.butselect==3:Game.aipower,Game.refresh,Game.coolclick=changeaipower(Game.aipower,Game.refresh,Game.coolclick)ifGame.butselect==4:Game.nombredebots,Game.nbofplayers,Game.refresh,Game.coolclick=getnbofbotchnage(Game.nombredebots,Game.nbofplayers,Game.refresh,Game.coolclick)ifGame.butselect==5:Game.tempslimite,Game.refresh,Game.coolclick=changetimeval(Game.tempslimite,Game.coolclick,Game.refresh)ifGame.butselect==6:Game.nombredebots,Game.nbofplayers,Game.refresh,Game.coolclick=getnbofplayerchnage(Game.nombredebots,Game.nbofplayers,Game.refresh,Game.coolclick)ifGame.butselect==7:ifkeydown(KEY_RIGHT)orkeydown(KEY_LEFT):ifGame.nbjperteam==1:Game.nbjperteam=2if (Game.nombredebots+Game.nbofplayers)==3:ifGame.nombredebots==4:Game.nbofplayers+=1else:Game.nombredebots+=1else:Game.nbjperteam=1Game.refresh=TrueGame.coolclick=monotonic()ifGame.butselect==8:ifkeydown(KEY_RIGHT):ifGame.typofteam==2:Game.typofteam=0else:Game.typofteam+=1Game.refresh=TrueGame.coolclick=monotonic()ifkeydown(KEY_LEFT):ifGame.typofteam==0:Game.typofteam=2else:Game.typofteam-=1Game.refresh=TrueGame.coolclick=monotonic()ifGame.nbjperteam==2:if (Game.nombredebots+Game.nbofplayers)==2:Game.nbjperteam=1elif (Game.nombredebots+Game.nbofplayers)==3:Game.nbjperteam=1defgameloop(Game):whileTrue:Game.deltainit=monotonic()ifGame.menuin==0:ifGame.refresh:Game.refresh=Falserefreshmenu(Game)menuupdate(Game)ifGame.menuin==1:ifGame.refresh:Game.refresh=Falserefreshaide(Game)aideupdate(Game)ifGame.menuin==2:gameupdate(Game)ifGame.menuin==3:ifGame.refresh:refreshpodium(Game)podiumupdate(Game)Game.refresh=FalseGame.deltatime=monotonic()-Game.deltainitifGame.deltatime!=0:draw_string(str(1/Game.deltatime),240,20)launcherwindow()gameloop(gamegeror())
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.