X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2FCAVE.mpsrc;h=df0d606ea05dda1b5cd380d4d7de9ccf4e9e909e;hp=623e6a4d509ddfd1ff5a337cce55a91ca9ee68de;hb=cdde360c83aced72709a7f654280d4041a65490d;hpb=ea6f3cf3a62e2368ee1ccba66d46563cab834511 diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index 623e6a4..df0d606 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -6,14 +6,12 @@ uses drop, invui, vars, - particles_store, randoms, memory, worldgen, canvas, - items, safeload, - mob, + mobs, console, effects, particles, @@ -29,11 +27,15 @@ uses chest, inv, items_store, - video; + video, + Blocks, + BlocksLogic, + Items, + ItemsLogic, + Tools; const - version='BETA 9'; - version_map=8; + version_map = 9; var keymode,updx,updy:integer; @@ -54,7 +56,7 @@ var moon_phase:integer; toolus,toolind:integer; osadki_ani:integer; - sd,sav_fl:string; + sav_fl:string; global_light:integer; world_typ:integer; float:image; @@ -108,68 +110,59 @@ procedure maxfps; delay(del); end; -procedure cleartextures; - var - no:image; - ix,iy,iz:integer; - begin - bg[0]:=no; - bg[1]:=no; - float:=no; - compas:=no; - for ix:=0 to 7 do clock[ix]:=no; - - {for ix:=0 to maxBlockTex do - begin - tex[ix]:=no; - tex8[ix]:=no; - end; - for ix:=0 to maxItemTex do - begin - item[ix]:=no; - item8[ix]:=no; - end;} - for ix:=0 to 8 do back[ix]:=no; - - player.freeSkin; - - for ix:=0 to 34 do - gui[ix]:=no; - - for ix:=0 to 9 do tue[ix]:=no; - - for ix:=0 to 7 do osad[0,ix]:=no; - for ix:=0 to 7 do osad[1,ix]:=no; - - for ix:=0 to 15 do light[ix]:=no; +procedure ClearTextures; + var + no : image; + ix, iy, iz : integer; + begin + bg[0] := no; + bg[1] := no; + float := no; + compas := no; + for ix := 0 to 7 do + Vars.clock[ix] := no; + + for ix := 0 to maxBlockTex do + begin + tex[ix] := no; + tex8[ix] := no; + end; + for ix := 0 to maxItemTex do + begin + item[ix] := no; + item8[ix] := no; + end; - for ix:=0 to 7 do - begin - pr_1[ix]:=no; - pr_2[ix]:=no; - pr_3[ix]:=no; - pr_4[ix]:=no; - pr_5[ix]:=no; - end; - bubble:=no; + for ix := 0 to 8 do + back[ix]:=no; - for ix:=0 to 15 do - pr_boom[ix]:=no; + player.freeSkin; - mob.freeSkin; + for ix := 0 to 34 do + gui[ix] := no; + for ix := 0 to 9 do + tue[ix] := no; + for ix := 0 to 7 do + osad[0, ix] := no; + for ix := 0 to 7 do + osad[1, ix] := no; - sky:=no; + for ix := 0 to 15 do + light[ix] := no; - sun:=no; - moon:=no; + Particles.FreeTextures; + Mobs.FreeTextures; - sign_im:=no; + sky := no; + sun := no; + moon := no; + sign_im := no; - for ix:=0 to CONST_MAX_CURS do - LoadCurImg(no, ix); + for ix := 0 to CONST_MAX_CURS do + LoadCurImg(no, ix); - //resetVirtualKeyboard(-1); - end; + //resetVirtualKeyboard(-1); + end; procedure create_msg(s:string); var @@ -198,15 +191,17 @@ 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,''); for ix:=0 to 8 do back[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); end; - player.loadSkin('char_ani.png', path); - mob.loadSkin(path); + console.exec('textures.cfg', 'AUTO'); + + Player.LoadSkin('char_ani.png', path); + Mobs.LoadTextures(path); im:=ld_tex('gui.png',path,'gui/'); gui[0]:=rotate_image_from_image(im,0,0,16,16,0); @@ -255,22 +250,7 @@ procedure loadtexture(path:string); for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0); end; - if load_particles_tex then - begin - im:=ld_tex('particles.png',path,'terrain/'); - for ix:=0 to 7 do - begin - pr_1[ix]:=rotate_image_from_image(im,8*ix,0,8,8,0); - pr_2[ix]:=rotate_image_from_image(im,8*ix,8,8,8,0); - pr_3[ix]:=rotate_image_from_image(im,8*ix,16,8,8,0); - pr_4[ix]:=rotate_image_from_image(im,8*ix,24,8,8,0); - pr_5[ix]:=rotate_image_from_image(im,8*ix,32,8,8,0); - end; - bubble:=rotate_image_from_image(im,0,40,8,8,0); - im:=ld_tex('explosion.png',path,'terrain/'); - for ix:=0 to 15 do - pr_boom[ix]:=rotate_image_from_image(im,32*ix,0,32,32,0); - end; + Particles.LoadTextures(path); im:=ld_tex('partition.png',path,'gui/'); gui[18]:=rotate_image_from_image(im,0,0,84,42,0); @@ -335,30 +315,12 @@ procedure cleargame; //anim_del2:=0; - inv.resetData; - - chest.resetData; - - {for ix:=0 to 15 do - begin - b_furnace[ix]:=false; - for iy:=0 to 4 do - begin - furnace[ix,iy].item_i:=0; - furnace[ix,iy].sum_i:=0; - furnace_gg[ix].f_gor:=15; - furnace_gg[ix].fire_time:=0; - furnace_gg[ix].f_got:=0; - furnace_gg[ix].got_time:=0; - end; - end;} - - drop.resetData; - - mob.resetData; - - //gb_up_pa:=0; - reset_particles(max_particles+1); + Inv.ResetData; + Chest.ResetData; + Furnace.ResetData; + Drop.ResetData; + Mobs.ResetData; + Particles.ResetData; for ix:=0 to 255 do begin @@ -525,41 +487,19 @@ procedure saveworld(path:string); write_byte(getBackMap(ix)); write_byte(getBiomMap(ix)); end; - drw_load_line('Chests',55); - //Chests - chest.saveData; - drw_load_line('Furnaces',60); - //Furnaces - /* for ix:=0 to 15 do - begin - writebool(b_furnace[ix]); - writeint(furnace_gg[ix].f_gor); - writeint(furnace_gg[ix].f_got); - for iy:=0 to 4 do - begin - write_byte(furnace[ix,iy].item_i); - writeint(furnace[ix,iy].sum_i); - end; - end;*/ - drw_load_line('Mobs',70); - //Mobs - mob.saveData; - drw_load_line('Drop',80); - //Drop - drop.saveData; - drw_load_line('Particles',85); - //Particles - writeint(max_particles); - write_byte(gb_up_pa); - for ix:=0 to max_particles do - begin - write_byte(get_particle_type(ix)); - write_byte(get_particle_ani(ix)); - writeint(get_particle_x(ix)); - writeint(get_particle_y(ix)); - end; - drw_load_line('Other',90); - //Other + + drw_load_line('Chests', 55); + Chest.SaveData; + drw_load_line('Furnaces', 60); + Furnace.SaveData; + drw_load_line('Mobs', 70); + Mobs.SaveData; + drw_load_line('Drop', 80); + Drop.SaveData; + drw_load_line('Particles', 85); + Particles.SaveData; + + drw_load_line('Other', 90); write_byte(updx); write_byte(updy); writebool(osadki); @@ -667,42 +607,17 @@ function loadworld(path:string):boolean; setBackMap(read_byte, ix); setBiomMap(read_byte, ix); end; - drw_load_line('Chests',55); - //Chests - chest.loadData; - drw_load_line('Furnaces',60); - //Furnaces - /* for ix:=0 to 15 do - begin - b_furnace[ix]:=readbool; - furnace_gg[ix].f_gor:=readint; - furnace_gg[ix].f_got:=readint; - for iy:=0 to 4 do - begin - furnace[ix,iy].item_i:=read_byte; - furnace[ix,iy].sum_i:=readint; - end; - end;*/ - drw_load_line('Mobs',70); - //Mobs - mob.loadData; - drw_load_line('Drop',80); - //Drop - drop.loadData; - drw_load_line('Particles',85); - //Particles - max_particles:=readint; - reset_particles(max_particles+1); - gb_up_pa:=read_byte; - for ix:=0 to max_particles do - begin - set_particle_type(ix,read_byte); - set_particle_ani(ix,read_byte); - set_particle_x(ix,readint); - set_particle_y(ix,readint); - end; - drw_load_line('Other',90); - //Other + drw_load_line('Chests', 55); + Chest.LoadData; + drw_load_line('Furnaces', 60); + Furnace.LoadData; + Mobs.LoadData; + drw_load_line('Drop', 80); + Drop.LoadData; + drw_load_line('Particles', 85); + Particles.LoadData; + + drw_load_line('Other',90); updx:=read_byte; updy:=read_byte; osadki:=readbool; @@ -773,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); @@ -1072,7 +987,7 @@ procedure start_uu; rs:=openRecordStore('SD'); sd:=readRecordStoreEntry(rs,1); closeRecordStore(rs); - console.exec('autoexec.cfg', 'AUTO', true); + console.exec('autoexec.cfg', 'AUTO'); if sd='' then begin init_touch; @@ -1428,6 +1343,7 @@ procedure menu_tex; if m_cur=0 then begin if cur_name>0 then begin + debug("Select TexturePack @ /" + sd + "/cavecraft/texturepacks/" + names[cur_name]); tex_pack:=names[cur_name]; LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); @@ -1435,9 +1351,13 @@ procedure menu_tex; rs:=openRecordStore('TX'); t:=addRecordStoreEntry(rs,tex_pack); closeRecordStore(rs); + + LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); end; else begin + debug("Cancel Select TecturePack"); tex_pack:=''; loadtexture('/'); deleteRecordStore('TX'); @@ -1511,7 +1431,7 @@ var end; else if m_cur=-1 then begin - s_particles:=not s_particles; + Particles.enabled := not Particles.enabled; end; else if m_cur=0 then begin @@ -1565,7 +1485,7 @@ var drw_btn('Light:'+light_type,-3,m_cur,0,1); drw_btn('Weather:'+ifosad,-2,m_cur,0,1); - drw_btn('Particles:'+s_particles,-1,m_cur,0,1); + drw_btn('Particles:' + Particles.enabled, -1, m_cur, 0, 1); drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1); drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1); drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1); @@ -1656,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); @@ -1676,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); @@ -1796,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 @@ -2045,46 +1964,50 @@ 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); + Drop.Draw(camx, camy); {===================[particles]===================} - if s_particles then draw_particle; + Particles.Draw(camx, camy); {===================[player]===================} - if hp>0 then - begin - player.draw(camx, camy); - end; - + Player.Draw(camx, camy); {===================[mobs]===================} - mob.draw(camx, camy); + Mobs.Draw(camx, camy); {===================[draw_blocks]===================} for ix:=minx to maxx do for iy:=miny to maxy do - begin - if getBlockFore(getmap(ix,iy))=true then - draw_block(ix,iy); + begin + if Blocks.IsForeground(getmap(ix, iy)) then BlocksLogic.Draw(ix, iy, camx, camy); - setcolor(0,0,0); - if (light_type=1) then begin if getmaplight(ix,iy)=0 then fillrect((ix*16)-camx,(iy*16)-camy,16,16); end; - else - if light_type=2 then begin if getmaplight(ix,iy)<15 then begin if (ix*16-camx0-16) and (iy*16-camy0-16) then drawimage(light[getmaplight(ix,iy)],(ix*16)-camx,(iy*16)-camy); end; end; - end; - if (toolus>0) and (toolind<10) and (getmap(curx,cury)>0) then begin if toolind>9 then toolind:=9; drawimage(tue[toolind],curx*16-camx,cury*16-camy); end; + setcolor(0, 0, 0); + if light_type = 1 then + begin + if getmaplight(ix,iy) = 0 then + fillrect((ix * 16) - camx, (iy * 16) - camy, 16, 16); + end; + else if light_type = 2 then + begin + if getmaplight(ix, iy) < 15 then + drawimage(light[getmaplight(ix, iy)], (ix * 16) - camx, (iy * 16) - camy); + end; + end; + + // debug + // drawimage(light[getmaplight(player.getX div 16, player.getY div 16)], 0, 0); + + if (toolus > 0) and (toolind < 10) and (getmap(curx,cury) > 0) then + begin + if toolind > 9 then + toolind:=9; + drawimage(tue[toolind], curx * 16 - camx, cury * 16 - camy); + end; {===================[gui]===================} if drawgui then begin @@ -2108,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); @@ -2236,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:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); - else - i:=mob.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 @@ -2510,6 +2423,8 @@ procedure plr_is_dead; y:=last_sleep_y*16; end; end; + player.setX(x); + player.setY(y); posi:=0; curx:=0; cury:=0; @@ -2736,9 +2651,9 @@ procedure phyhandler; var i:integer; begin - player.calcPhysics; - mob.updatePhy; - drop.calcPhy; + Player.CalcPhysics; + Mobs.UpdatePhy; + Drop.CalcPhy; end; procedure light_fillrect(l,x,y,r:integer); @@ -2795,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 @@ -2906,6 +2821,9 @@ procedure game; game_time:=game_time+(600000 div (fps_t*1000)); +// Ускорение игрового времени в 10 раз +// game_time := game_time + (600000 div (fps_t*100)); + if (game_time>600000) or (game_time<0) then begin game_time:=0; @@ -2914,19 +2832,20 @@ procedure game; load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase); end; - tim:=10000*getimagewidth(sky)/600000*game_time/10000; - global_light:=effects.get(sky,tim,1,1) {and $F}; + tim := 10000 * getimagewidth(sky) / 600000 * game_time / 10000; + global_light := effects.get(sky, tim, 1, 1) div 16; 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; - if random(20)=random(20) then create_particle(6,x,y); + if Random(20) = Random(20) then Particles.Create(Particles.bubble, x, y); if gamemode=1 then begin hp:=666; hunger:=666; end; @@ -2937,9 +2856,8 @@ procedure game; //if s_spawn_mob then if random(4096)=1547 then megaspawn; - mob.update; - - if particle_upd then update_particle; + Mobs.Update; + Particles.Update; if light_type>0 then begin @@ -2961,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); @@ -3055,12 +2975,34 @@ procedure qt_start; menu; end; +procedure draw_debug; + var + i : Integer; + begin + //drawfonttext('X:'+(x div 16-128),0,0); + //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8); + drawfonttext('CURX:'+(curx-128),0,16); + drawfonttext('CURY:'+cury,0,24); + drawfonttext('UPDX:'+updx,0,32); + drawfonttext('UPDY:'+updy,0,40); + drawfonttext('FPS:'+fps,0,56); + drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64); + drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72); + drawfonttext('SEED:'+seed,0,88); + drawfonttext('Game time:'+game_time,0,96); + drawfonttext('Global light:' + global_light, 0, 104); + + for i := 0 to 15 do + drawImage(light[i], getWidth - 16, 16 * i); + end; + begin qt_start; hung_time:=getrelativetimems; hp_time:=getrelativetimems; air_time:=getrelativetimems; portal_time:=getrelativetimems; + repeat proc_fps; keyhandler; @@ -3069,20 +3011,8 @@ begin draw; drawfonttext(version,getWidth-(length(version)*8),getHeight-8); if getrelativetimems-msg_time[4]>500 then begin free_ram:=memory.get_freememory; if free_ram<0 then free_ram:=-free_ram; msg_time[4]:=getrelativetimems; end; - if deb=true then - begin - //drawfonttext('X:'+(x div 16-128),0,0); - //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8); - drawfonttext('CURX:'+(curx-128),0,16); - drawfonttext('CURY:'+cury,0,24); - drawfonttext('UPDX:'+updx,0,32); - drawfonttext('UPDY:'+updy,0,40); - drawfonttext('FPS:'+fps,0,56); - drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64); - drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72); - drawfonttext('SEED:'+seed,0,88); - drawfonttext('Game time:'+game_time,0,96); - end; + if deb = true then + draw_debug; drawVideo; maxfps;