from mc5 import* def changelife(p,v):p.life=max(min(p.life+v,20),0) def changefood(p,v):p.food=max(min(p.food+v,20),0) def distance2(a,b,c,d):return (a-c)**2+(b-d)**2 def getstackvalue(game,typ): r=64 return r def debug(t=""):f(200,190,120,20,"gray");draw_string(str(t),200,190,"black","gray") def getblocticks(t): tep=0 if t=="$": tep=[0,0,-1] return tep def blocksdrops(): yield("!",(((50,"!"),(50,"$")),)) yield("1",(((100,"#")))) yield("#",(((100,"u"),),)) def generatechunk(Chx,Chy,game): if game.player.dimension==1: temp="*"*70+"~"*28 for ele in game.genportal: if ele[0]==1: if ele[3]==Chx and ele[4]==Chy: bas=temp[0:ele[1]+ele[2]*14-1]+"[m["+temp[ele[1]+ele[2]*14+1:-1] temp=bas return temp elif game.player.dimension==2: return "*"*70+")"*28 HeightList=[] if game.mapgenerator=="": tpch=[] mapeheightstart=randint(58,58) tpch.append(mapeheightstart) for x in range(13): tpch.append(terraingetter(tpch[-1])) game.leftuping=-1#chunk non généré gauche game.rightuping=0#chunk non généré droite HeightList=tpch else: if Chx==game.leftuping:#need new chunk at left fro=game.mapgenerator[0] heightstart=ord(fro) tpch=[heightstart,] for x in range(13): tpch.append(terraingetter(tpch[-1])) HeightList=tpch elif Chx==game.rightuping:#need new chunk at left fro=game.mapgenerator[-1] heightstart=ord(fro) tpch=[heightstart,] for x in range(13): tpch.append(terraingetter(tpch[-1])) HeightList=tpch else: HeightList=[57 for x in range(14)] tempchunk=["*" for x in range(98)] upy=Chy*7#bas du chunk for sg in range(14): if HeightList[sg]>upy+14:#super au dessus for dep in range(7): tempchunk[sg+dep*14]=chr(randint(52,59)) elif upy+14>=HeightList[sg]>upy+7:#chunk au dessus dif=HeightList[sg]-upy-7 for add in range(1,4): if add-dif>=0: tempchunk[sg+(add-dif)*14]="!" for add in range(4,14): if 7>add-dif>=0: tempchunk[sg+(add-dif)*14]="#" elif upy+7>=HeightList[sg]>upy:#chunk de base dif=HeightList[sg]-upy tempchunk[sg+(7-dif)*14]="$" for add in range(1,4): if 7-dif+add<7: tempchunk[sg+(7-dif+add)*14]="!" for add in range(4,8): if 7-dif+add<7: tempchunk[sg+(7-dif+add)*14]="#" if Chy==-1: tp=[">"for xe in range(14)] tempchunk=tp+tempchunk[14:98] if Chx==game.rightuping: for ele in HeightList: game.mapgenerator+=chr(ele) game.rightuping+=1 if Chx==game.leftuping: temp="" for ele in HeightList: temp+=chr(ele) game.mapgenerator=temp+game.mapgenerator game.leftuping-=1 game.center+=1 ret="" for ele in tempchunk: ret+=ele if Chx==0 and Chy==6: bas=ret[0:61]+"k*k"+ret[63:-1] ret=bas if Chx==0 and Chy==8: bas=ret[0:62]+"m"+ret[62:-1] ret=bas return ret def terraingetter(y): r=randint(5,95);d=0 if r<5:d=-2 if r>95:d=2 if 75<=r<=95:d=1 if 5<=r<=25:d=-1 return y+d def getdestime(g,basdes,invcase): p=g.player ret=g.blocksbreakstime[basdes] if p.inventory[invcase] in g.tools: ind=g.tools.index(p.inventory[invcase]) if ind<4: if basdes in g.ispickacc: ret/=2 ret-=(ret/3.5)*ind return ret def durato(g,invcase):return e**(-(g.tools.index(g.player.inventory[invcase])%4)-3)*100 def drawnumber(x,y,n): for l in ("034562","56","05142","05162","3516","03162","031624","056","0123456","012356")[int(n)]:t=[int(e) for e in "0041034106410014031430143314"[int(l)*4:int(l)*4+4]];f(x+t[0],y+t[1],t[2],t[3],"yellow") def breaktexture(n,x,y): b="black";x*=20;y*=20 if n==0:f(x+7,y+6,1,3,b);f(x+8,y+8,1,2,b);f(x+9,y+9,1,2,b);f(x+10,y+9,1,4,b);f(x+11,y+8,1,2,b) if n==1:se(x+8,y+6,b);se(x+13,y+9,b);f(x+9,y+5,1,2,b);f(x+12,y+8,1,2,b);f(x+9,y+12,1,3,b);f(x+8,y+14,1,2,b) if n==2:(x+6,y+3,2,1,b);f(x+7,y+4,3,1,b);f(x+3,y+9,2,1,b);f(x+12,y+7,2,1,b);f(x+13,y+6,2,1,b);f(x+4,y+8,3,1,b);se(x+14,y+5,b);se(x+13,y+10,b);f(x+13,y+11,3,1,b);f(x+15,y+12,1,2,b) if n==3:f(x+7,y,1,2,b);f(x+6,y+1,1,2,b);f(x,y+6,2,1,b);f(x+1,y+7,2,1,b);f(x+2,y+8,2,1,b);f(x+15,y+5,2,1,b);f(x+16,y+6,4,1,b);f(x+9,y+15,1,4,b);f(x+10,y+18,1,2,b);f(x+16,y+13,3,1,b);f(x+18,y+14,2,1,b);se(x+16,y+12,b) if n==4:f(x+3,y,1,5,b);f(x+1,y+5,2,1,b);se(x+2,y+4,b);f(x+3,y+10,1,3,b);f(x+2,y+12,1,6,b);se(x+3,y+17,b);f(x+14,y,1,4,b);f(x+15,y+3,1,2,b);f(x+10,y+15,2,1,b);f(x+11,y+16,6,1,b);f(x+16,y+17,2,1,b);se(x+10,y+14,b)