X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2FCAVE.mpsrc;h=df0d606ea05dda1b5cd380d4d7de9ccf4e9e909e;hp=0d305849e358ef1108de30fb24a68376cf90e8e9;hb=cdde360c83aced72709a7f654280d4041a65490d;hpb=9115be0a19d5716f33a2e2cba76f3447ce0f4c2f diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index 0d30584..df0d606 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -10,7 +10,6 @@ uses memory, worldgen, canvas, - items, safeload, mobs, console, @@ -28,7 +27,12 @@ uses chest, inv, items_store, - video; + video, + Blocks, + BlocksLogic, + Items, + ItemsLogic, + Tools; const version_map = 9; @@ -116,7 +120,7 @@ procedure ClearTextures; float := no; compas := no; for ix := 0 to 7 do - clock[ix] := no; + Vars.clock[ix] := no; for ix := 0 to maxBlockTex do begin @@ -187,7 +191,7 @@ procedure loadtexture(path:string); compas:=ld_tex('compass.png',path,'gui/'); im:=ld_tex('clock.png',path,'gui/'); for ix:=0 to 7 do - clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + Vars.clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); if load_back_tex then begin im:=ld_tex('back.png',path,''); @@ -684,7 +688,7 @@ procedure drawdeadlogo; fillrect(0,0,getWidth,getHeight); dead:=loadimage('/dl'); drawimage(dead,(getWidth/2)-(getimagewidth(dead)/2),(getHeight/2)-(getimageheight(dead)/2)); - drawfonttext(#119+#119+#119+#46+#100+#101+#97+#100+#115+#111+#102+#116+#119+#97+#114+#101+#46+#114+#117,getWidth/2-80,(getHeight/2)+(getimageheight(dead)/2)); + drawfonttext('www.deadsoftware.ru',getWidth/2-80,(getHeight/2)+(getimageheight(dead)/2)); drawfonttext('Loading...',(getWidth/2)-(40),getHeight-8); drawVideo; delay(500); @@ -1572,17 +1576,17 @@ procedure menu_about; setclip(0,32,getWidth,(getHeight/16-4)*16); drw_txt('Developers:',cur,0,1); - drw_txt(#68+#101+#97+#68+#68+#111+#111+#77+#69+#82+' - Programmer',cur,1,0);//dead - drw_txt(#102+#114+#101+#100+#45+#98+#111+#121+' - Programmer',cur,2,0);//fred-boy - drw_txt(#65+#110+#100+#114+#101+#121+#53+#57+' - Programmer',cur,3,0);//andrey59 - drw_txt(#89+#117+#82+#97+#78+#110+#78+#122+#90+#90+' - Artist',cur,4,0);//yura - drw_txt(#83+#97+#115+#104+#97+#71+' - Artist and idea generator',cur,5,0);//sasha - drw_txt(#66+#97+#74+#108+#101+#72+#84+#105+#72+' - Artist and tester',cur,6,0);//valentin - drw_txt(#65+#103+#114+#101+#115+#115+#111+#82+' - Tester',cur,7,0);//agressor - drw_txt(#118+#111+#108+#121+#97+#95+#110+#97+#115+#116+#97+#110+#101+' - Tester',cur,8,0);//volya - drw_txt(#97+#98+#97+#100+#111+#110+' - Tester',cur,9,0);//abadon - drw_txt(#77+#111+#110+#111+#103+#114+#111+#109+' - Tester',cur,10,0);//monogrom - drw_txt(#75+#97+#108+#116+#101+#114+' - Tester',cur,11,0);//kalter + drw_txt('DeaDDooMER - Programmer',cur,1,0); + drw_txt('fred-boy - Programmer',cur,2,0); + drw_txt('Andrey59 - Programmer',cur,3,0); + drw_txt('YuRaNnNzZZ - Artist',cur,4,0); + drw_txt('SashaG - Artist and idea generator',cur,5,0); + drw_txt('BaJleHTiH - Artist and tester',cur,6,0); + drw_txt('AgressoR - Tester',cur,7,0); + drw_txt('volya - Tester',cur,8,0); + drw_txt('abadon - Tester',cur,9,0); + drw_txt('Monogrom - Tester',cur,10,0); + drw_txt('Kalter - Tester',cur,11,0); drw_txt('Thanks:',cur,12,1); drw_txt('Piligrim and 0vZ - Lib_jsr75i',cur,13,0); @@ -1592,8 +1596,8 @@ procedure menu_about; drw_txt('aleshka - Lib_jpeg',cur,17,0); drw_txt('Roman_V - Lib_safeload',cur,18,0); - drw_txt('Site: '+#104+#116+#116+#112+#58+#47+#47+#100+#101+#97+#100+#115+#111+#102+#116+#119+#97+#114+#101+#46+#114+#117,cur,21,0); - drw_txt(#68+#101+#97+#68+#83+#111+#102+#116+#87+#97+#114+#101+' 2012-'+getyear(getcurrenttime),cur,22,0); + drw_txt('Site: www.deadsoftware.ru',cur,21,0); + drw_txt('DeaDSoftWare 2012-2014',cur,22,0); drw_txt('Hello! :D',cur,100,1); @@ -1712,11 +1716,10 @@ function setBlock(invcur, x, y:integer):boolean; item:=inv.getItem(invcur); sum:=inv.getSum(invcur); block:=getMap(x, y); - sblock:=getItemInfo(item); + sblock := Items.GetData(item); - if getItemType(item)=ITEM_TYPE_BLOCK then - if inv.isNull(invcur)=false then - if getBlockSet(block)=true then + if (Items.GetType(item) = Items.block) and (Inv.IsNull(invcur) = false) then + if Blocks.IsOverlapped(block) then // if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then begin if set_block_code(sblock, x, y)=false then @@ -1961,20 +1964,13 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if ifosad then if (getBackMap(ix)>=iy) and (osadki=true) and getBlockTrans(getmap(ix,iy)) then - begin - if getBiomMap(ix)=0 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=2 then drawimage(osad[1,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=3 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - end; - if drw_back then - if getBlockTrans(getmap(ix,iy)) then - draw_back(ix,iy); - - if getBlockFore(getmap(ix,iy))=false then - draw_block(ix,iy); + if ifosad and osadki and (getBackMap(ix) >= iy) and Blocks.IsTransporent(getmap(ix, iy)) then begin + if getBiomMap(ix) = 0 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 2 then drawimage(osad[1, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 3 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + end; + if drw_back and Blocks.IsTransporent(getmap(ix, iy)) then draw_back(ix, iy); + if Blocks.IsForeground(getmap(ix,iy)) = false then BlocksLogic.Draw(ix, iy, camx, camy); end; {===================[drop]===================} Drop.Draw(camx, camy); @@ -1988,8 +1984,7 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if getBlockFore(getmap(ix, iy)) then - draw_block(ix, iy); + if Blocks.IsForeground(getmap(ix, iy)) then BlocksLogic.Draw(ix, iy, camx, camy); setcolor(0, 0, 0); if light_type = 1 then @@ -2036,7 +2031,7 @@ procedure draw; drawimage(gui[1],tmp_ax,0); for ix:=0 to 8 do begin - drawItem(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); + ItemsLogic.Draw(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); end; drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0); @@ -2164,82 +2159,72 @@ procedure resetToolProgerss; toolind:=0; end; -procedure usetools(invcur, x, y:integer); - var - item, sum, block:integer; - begin - block:=getmap(x, y); - item:=inv.getItem(invcur); - sum:=inv.getSum(invcur); - - if gamemode=1 then - destroy_block_cr(block, x, y); - else - if (block>0) then - begin - if (getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) then - toolus:=toolus+getToolSpeed(item); - else - toolus:=toolus+1; - - if toolus>=getBlockHP(block) then - begin - if ((getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then - begin - setMap(0, x, y); - destroy_block_1(block, x, y); - setMapInfo(0, x, y); - end; - else - begin - setMap(0, x, y); - destroy_block_0(block, x, y); - setMapInfo(0, x, y); - end; - - if getItemType(item)=ITEM_TYPE_TOOL then - begin - inv.setSum(inv.getSum(invcur)-1, invcur); - inv.fixNull(invcur); - end; - - toolus:=0; - toolind:=0; - end; - end; + procedure usetools(invcur, x, y : integer); + var + item, sum, block, tool : integer; + begin + block := GetMap(x, y); + item := Inv.GetItem(invcur); + sum := Inv.GetSum(invcur); + tool := Items.GetData(item); + + if gamemode = 1 then begin + destroy_block_cr(block, x, y); + end else if block <> 0 then begin + if (Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = Tools.GetType(tool)) then begin + toolus := toolus + Tools.GetSpeed(tool); + end else begin + toolus := toolus + 1; + end; - if (toolus>0) and (toolus<=getBlockHP(block)) then - toolind:=((toolus*100) div getBlockHP(block)) div 10; - end; + if toolus >= Blocks.GetResistant(block) then begin + Debug('usetools: tool = ' + tool); + if ((Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = Tools.GetType(tool)) and (Tools.GetLevel(tool) >= Blocks.GetLevel(block))) or (Blocks.GetLevel(block) <= 0) then begin + SetMap(0, x, y); + destroy_block_1(block, x, y); + SetMapInfo(0, x, y); + end else begin + SetMap(0, x, y); + destroy_block_0(block, x, y); + SetMapInfo(0, x, y); + end; -function rt_useweap:boolean; - var - x, y, w, h, i, damg:integer; - item:integer; - begin - x:=player.getX; - y:=player.getY; - w:=player.getW; - h:=player.getH; - item:=inv.getItem(invslot); + if Items.GetType(item) = Items.tool then begin + Inv.SetSum(Inv.GetSum(invcur) - 1, invcur); + Inv.FixNull(invcur); + end; - if getItemType(item)=1 then - damg:=getToolDamg(item); - else - damg:=1; + toolus:=0; + toolind:=0; + end; + end; - if posi=0 then - i:=Mobs.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); - else - i:=Mobs.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3); + if (toolus > 0) and (toolus <= Blocks.GetResistant(block)) then begin + toolind := ((toolus * 100) div Blocks.GetResistant(block)) div 10; + end; + end; - if i<>-1 then - begin - inv.setSum(inv.getSum(invslot)-1, invslot); - inv.fixNull(invslot); - rt_useweap:=true; - end; - end; + function rt_useweap:boolean; + var + item : integer; + x, y, w, h, i, damg : integer; + begin + x := Player.GetX; + y := Player.GetY; + w := Player.GetW; + h := Player.GetH; + item := Inv.GetItem(invslot); + if Items.GetType(item) = Items.tool then damg := Tools.GetDamage(item) else damg := 1; + + if posi=0 then i := Mobs.FindAndHit(damg, x - TILE_SIZE, y, TILE_SIZE + (w / 2), h, -2, -3); + else i := Mobs.FindAndHit(damg, x + (w / 2), y, TILE_SIZE + (w / 2), h, 2, -3); + + if i >= 0 then begin + Inv.SetSum(Inv.GetSum(invslot) - 1, invslot); + Inv.FixNull(invslot); + rt_useweap := true; + end; + end; procedure rt_usetools; var @@ -2725,7 +2710,7 @@ procedure calc_sun(ix,m:integer); begin setmaplight(ss,ix,iy); if ss=0 then break; - ss:=ss-getBlockTr(getmap(ix,iy)); + ss := ss - Blocks.GetLightAbsorbtion(getmap(ix, iy)); if ss<0 then ss:=0; end; for iy:=iy+1 to 127 do @@ -2852,9 +2837,10 @@ procedure game; if clock_stage<>game_time div 75000 then begin clock_stage:=clock_stage+1; if clock_stage>7 then clock_stage:=0; end; - if x<0 then x:=0; - if x+8>4094 then x:=4086; - if getBlockColl(getmap(x div 16, y div 16))>0 then hp:=hp-1; + if x < 0 then x := 0; + else if x + 8 > 4094 then x := 4086; + if Blocks.IsSolid(getmap(x div 16, y div 16)) then hp := hp - 1; + if random(4096)=random(4096) then begin osadki:=not osadki; end; osadki_ani:=osadki_ani+1; if osadki_ani>7 then osadki_ani:=0; @@ -2893,9 +2879,11 @@ procedure game; for ix:=minx to maxx do for iy:=miny to maxy do begin - if light_type=0 then setmaplight(15,ix,iy); - else - if light_type>0 then if getBlockLi(getmap(ix,iy))>0 then calc_light(getBlockLi(getmap(ix,iy)),ix,iy); + if light_type = 0 then begin + SetMapLight(15, ix, iy); + end else if (light_type > 0) and (Blocks.GetLightEmission(getmap(ix, iy)) > 0) then begin + calc_light(Blocks.GetLightEmission(GetMap(ix, iy)), ix, iy); + end; end; minx:=(camx/16)-((getwidth/2)/16); @@ -3014,6 +3002,7 @@ begin hp_time:=getrelativetimems; air_time:=getrelativetimems; portal_time:=getrelativetimems; + repeat proc_fps; keyhandler;