from mc1 import* poseable="$!#%&'()+<=bm[" farmlandignore="*.,/01" def allblocksticks(game,dt): ... def AffChunk(g): setskycolor(g);setactualchunk(g);f(0,0,320,180,g.skycolor) for x in range(16): for y in range(9):afftex(x*20,y*20,g.actualchunk[x+y*16],game=g) class Game(): def __init__(s): s.itemgeror=[] s.blocksavor={} s.leftuping=0 s.rightuping=0 s.center=0 s.waterheight=60 s.mobgeror=[] s.tools="?@ABDEFGIJKLNOPQSTUV" s.mapgenerator="" s.ispickacc="#459" s.cookable={"5":"-"} s.fuels={"'",1.5} s.foodeurs={("3",5,6)} s.stackdata={"@":1} s.blocksbreakstime={"$":0.9,"!":0.75,"#":7.5,"%":0.75,"&":0.6,"'":3,"(":3,")":3.75,"+":0.9,",":-1,"-":-1,".":0.1,"/":0.1,"0":0.1,"1":0.1,"2":-1,"3":-1,"4":15,"5":15,"9":15,":":4,";":4,"<":4,"=":4} s.traversable="m*.,/01bcl" s.invcaseposition=[] for x in range(6): s.invcaseposition.append((50+26*x,195)) for x in range(6): s.invcaseposition.append((50+26*x,126)) for x in range(6): s.invcaseposition.append((50+26*x,100)) s.invcaseposition.append((100,40)) s.invcaseposition.append((126,40)) s.invcaseposition.append((100,66)) s.invcaseposition.append((126,66)) s.invcaseposition.append((180,53)) for y in range(3): for x in range(3):s.invcaseposition.append((74+x*26,14+y*26)) s.invcaseposition.append((180,40)) s.invcaseposition.append((100,0)) s.invcaseposition.append((100,40)) s.invcaseposition.append((180,40)) s.invcaseposition.append((10,113)) s.ticky=0 s.tickmul=9 s.player=Player(s) hotbarprint(s.player) s.chunklist={} s.actualchunk=None s.actualchunkticker=[0 for x in range(144)] s.gametime=150 s.skycolor=color(0,255,255) s.mobgeror.append(mob(s,posx=50,posy=100,typ=1,dim=1)) s.genportal=[] AffChunk(s) s.dt=0 while 1: #debug(len(s.chunklist)) s.Timerinit=monotonic() s.player.update(s.dt,s) s.ticky+=1 if s.ticky==9:s.ticky=0 if s.player.inInv==0: for mobs in s.mobgeror:mobs.update(s) for ite in s.itemgeror:ite.update(s) updatefoodsprite(s.player) updatelifesprite(s.player) s.dt=(monotonic()-s.Timerinit) if s.dt!=0:draw_string(str(1/s.dt),200,0) s.gametime+=s.dt if s.gametime>300:s.gametime-=300 def setskycolor(s): tep=abs(s.gametime-150)*1.6 if s.player.dimension==0:s.skycolor=color(0,255-tep,255-tep) if s.player.dimension==1:s.skycolor=color(217,23,19) def BlockSelectorUpdate(player): if player.inInv: return posx=int(player.Px/20) posy=int(player.Py/20) onrefresh=False temp={42:(-1,1,7),43:(0,1,6),44:(1,1,5),36:(-1,0,0),38:(1,0,4),30:(-1,-1,1),31:(0,-1,2),32:(1,-1,3)} for ele in temp.keys(): if keydown(ele): player.BlX=posx+temp[ele][0] player.BlY=posy+temp[ele][1] player.Bloselectn=temp[ele][2] onrefresh=True break if onrefresh: if player.oldBlX!=player.BlX or player.oldBlY!=player.BlY:BlocKSelectRefresh(player) elif posx!=player.lsblx or posy!=player.lsbly: player.BlX=posx+player.Blolistpos[player.Bloselectn][0] player.BlY=posy-player.Blolistpos[player.Bloselectn][1] BlocKSelectRefresh(player) def Affminicraft(player): temp=player.parent.invcaseposition for x in range(5):refreshcase(player.parent,18+x) bx=temp[22][0]-25 by=temp[22][1]+10 f(bx,by,15,6,"gray") for x in range(6):f(bx+20-x,by+x+4,1,-2*(x+1),"gray") def openinterface(s): AffTotalInv(s) if s.inInv==1:Affminicraft(s) if s.inInv==2:AffBigCraft(s) if s.inInv==3:AffFurnace(s) def AffTotalInv(player): if player.inInv: f(0,0,320,180,"red") temp=player.parent.invcaseposition for x in range(6,18):refreshcase(player.parent,x) refreshcase(player.parent,36) else: player.invcase=0 player.oldinvcase=0 AffChunk(player.parent) class Player(): def __init__(s,par): s.onrightclick=False s.rsrightclick=True s.parent=par s.mov=0 s.dimension=0 s.olddimension=0 s.destimer=0 s.blocktodestime=-1 s.breakoldtex=-1 s.Bloselectn=0 s.Blolistpos=((-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)) s.lsblx=-5 s.lsbly=-5 s.BlX=1 s.BlY=0 s.oldBlX=-1 s.oldBlY=0 s.rsenter=False s.inInv=0 s.inventory=["*"for x in range(38)] s.invnumbers=[0 for x in range(38)] s.invdata=[0 for x in range(38)] s.inventory[0]="?" s.inventory[1]="@" s.inventory[2]="A" s.inventory[3]="B" s.inventory[4]=")" s.inventory[5]="m" for ad in range(38): if s.inventory[ad]!="*": s.invnumbers[ad]=2 if s.inventory[ad] in par.tools: s.invdata[ad]=100 s.invcase=0 s.oldinvcase=0 s.oldfood=0 s.oldlife=0 s.saturation=0 s.life=6 s.food=20 f(0,180,320,45,color(188,188,188)) s.Chx=0 s.Chy=8 s.oldChx=s.Chx s.oldChy=s.Chy s.Px=130 s.Py=40 s.lPx=130 s.lPy=40 s.speedy=0 s.chunkload=False s.speedx=0 s.speedmax=115 s.jumpforce=4 s.keyindex=list(range(24,30)) s.keyindex+=list(range(18,24)) s.keyindex+=list(range(12,18)) s.keyindex=tuple(s.keyindex) s.prerangedihuit=set(range(18)) s.collx=10 s.colly=20 s.onground=True s.onmoveitem=False s.rsmoveitem=True s.lastmaxheight=400 s.spawnx=5 s.spawny=59 def checkInputs(s): if s.inInv==0: if keydown(50): s.inInv=1 openinterface(s) else: if keydown(49): for ele in list(range(18,22))+list(range(23,32)): addinventory(s,s.inventory[ele],s.invnumbers[ele]) useitem(s,ele,s.invnumbers[ele]) hotbarrefresh(s) s.inInv=0 s.oldinvcase=1 if s.invcase<6: s.oldinvcase=s.invcase s.invcase=0 AffChunk(s.parent) BlocKSelectRefresh(s) s.onrightclick=False hotbarrefresh(s) interfaceupdate(s) def update(s,dt,parent): s.checkInputs() if s.inInv: return if int((s.Py+20)/20)<9 : temp= getblock(int((s.Px+5)/20),int((s.Py+10)/20),parent) if temp=="b": s.lastmaxheight=s.Py if temp=="m": s.dimension=1 if s.dimension==0 else 0 parent.genportal.append((s.dimension,int(s.Px/20)-1,int(s.Py/20)-1,s.Chx,s.Chy)) AffChunk(parent) if temp=="l": s.dimension=2 if s.dimension==0 else 0 AffChunk(parent) if s.life<20 and s.food>14: s.saturation+=dt if s.saturation>2: changelife(s,1) changefood(s,-1) s.saturation=0 if s.life==0: s.Chx=s.spawnx//14 s.Px=20*(s.spawnx-abs(s.Chx*14)) s.Chy=s.spawny//7 s.Py=20*(s.spawny-abs(s.Chy*7)) s.lPx=s.Px s.lPy=s.Py s.life=20 s.saturation=20 s.food=0 s.dimension=0 AffChunk(s.parent) return if s.rsrightclick and not keydown(KEY_ANS): s.rsrightclick=False if not s.rsrightclick and keydown(KEY_ANS): s.onrightclick=True s.rsrightclick=True allblocksticks(parent,dt) s.mov=0 BlockSelectorUpdate(s) if keydown(KEY_LEFT): s.mov=2 s.speedx=-s.speedmax if keydown(KEY_RIGHT): s.mov=1 s.speedx=s.speedmax if keydown(KEY_UP) and s.onground:#refaire, risque de double saut s.onground=False s.speedy=s.jumpforce s.torefresh=True if s.onrightclick==True: changelife(s,-1) s.onrightclick=False for ele in parent.foodeurs: if ele[0]==s.inventory[s.invcase]: useitem(s,s.invcase,1) refreshcase(parent,s.invcase) s.food+=ele[1] if s.food>20: s.food=20 return if s.inventory[s.invcase] in poseable: test=int(s.Py/20)-s.Blolistpos[s.Bloselectn][1] havepos=0 if test<9: havepos=updatebloc(parent,int(s.Px/20)+s.Blolistpos[s.Bloselectn][0],test,s.inventory[s.invcase],False) if havepos: useitem(s,s.invcase,1) refreshcase(s.parent,s.invcase) b="black" f(s.BlX*20,s.BlY*20,20,1,b) f(s.BlX*20,s.BlY*20+19,20,1,b) f(s.BlX*20,s.BlY*20,1,20,b) f(s.BlX*20+19,s.BlY*20,1,20,b) else: blx=int(s.Px/20)+s.Blolistpos[s.Bloselectn][0] bly=int(s.Py/20)-s.Blolistpos[s.Bloselectn][1] hoverblock=getblock(blx,bly,s.parent) temp=s.parent.invcaseposition if hoverblock=="+" and s.inventory[s.invcase]=="-": if 0<= int(s.Py/20)-1-s.Blolistpos[s.Bloselectn][1]: if getblock(int(s.Px/20)+s.Blolistpos[s.Bloselectn][0],int(s.Py/20)-s.Blolistpos[s.Bloselectn][1]-1,s.parent)=="*": useitem(s,s.invcase,1) refreshcase(s.parent,s.invcase) updatebloc(s.parent,int(s.Px/20)+s.Blolistpos[s.Bloselectn][0],int(s.Py/20)-1-s.Blolistpos[s.Bloselectn][1],".",True) if hoverblock==")": s.inInv=2 openinterface(s) if hoverblock in {"<","="}: s.inInv=3 openinterface(s) if hoverblock=="k": if s.inventory[s.invcase]=="}": bx=-1 if getblock(blx+2,bly,s.parent)==getblock(blx+2,bly,s.parent)=="k": bx=1 updatebloc(parent,blx+bx,bly,"l",True) useitem(s,s.invcase,1) refreshcase(s.parent,s.invcase) if hoverblock=="*": if s.inventory[s.invcase]=="]": if getblock(blx+1,bly,s.parent)==getblock(blx-1,bly,s.parent)=="[": updatebloc(parent,blx,bly,"m",False) if keydown(KEY_EXE): curx=int(s.Px/20)+s.Blolistpos[s.Bloselectn][0] cury=int(s.Py/20)-s.Blolistpos[s.Bloselectn][1] if cury<9: tempbl=getblock(curx,cury,s.parent) if tempbl in parent.blocksbreakstime.keys(): s.blocktodestime=getdestime(parent,tempbl,s.invcase) breaktexture(0,curx,cury) else: s.blocktodestime=2000 if tempbl in parent.traversable: for mobso in parent.mobgeror: if s.Chx==mobso.Chx and s.Chy==mobso.Chy: mobx=int(mobso.Px/20) moby=int(mobso.Py/20) if curx==mobx and cury==moby: mobso.life-=1 else: s.blocktodestime=2000 s.destimer+=dt*(1+100*keydown(KEY_DIVISION)) rat=s.destimer//(s.blocktodestime/5) if rat!=s.breakoldtex: s.breakoldtex=rat if cury<9: breaktexture(int(rat),curx,cury) if s.blocktodestime<s.destimer: s.breakoldtex=-1 s.blocktodestime=-1 tempo=updatebloc(parent,int(s.Px/20)+s.Blolistpos[s.Bloselectn][0],int(s.Py/20)-s.Blolistpos[s.Bloselectn][1],"*",True) if tempo!="*": if s.inventory[s.invcase]in s.parent.tools: s.invdata[s.invcase]-=durato(s.parent,s.invcase) if s.invdata[s.invcase]<=0: s.inventory[s.invcase]="*" refreshcase(s.parent,s.invcase) refreshcase(s.parent,s.invcase) tempo=list(tempo) gen=blocksdrops() for x in range(3): tempdrop=next(gen) if tempdrop[0]==tempo[0]: tempo=getdrop(tempdrop[1]) break for ele in tempo: places=addinventory(s,ele,1) if places!="Nope": for alo in places: if alo<6: refreshcase(s.parent,alo) f(s.BlX*20,s.BlY*20,20,1,"black") f(s.BlX*20,s.BlY*20+19,20,1,"black") f(s.BlX*20,s.BlY*20,1,20,"black") f(s.BlX*20+19,s.BlY*20,1,20,"black") s.destimer=0 if s.Px>300: s.Px=20 s.Chx+=1 s.chunkload=1 if s.Px<20: s.Px=290 s.Chx-=1 s.chunkload=1 if s.Py<20: s.Py=140 s.Chy+=1 s.chunkload=1 s.lastmaxheight+=180 if s.Py>160: s.Py=20 s.Chy-=1 s.chunkload=1 s.lastmaxheight-=180 if s.inInv==0: refresh(s,zombie=False) if s.chunkload: AffChunk(s.parent) s.chunkload=0 physicupdate(s,dt,parent) Game()