X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2FCAVE.mpsrc;h=0d305849e358ef1108de30fb24a68376cf90e8e9;hp=e23b86557999db0064020d785f14b54745bd2a30;hb=9115be0a19d5716f33a2e2cba76f3447ce0f4c2f;hpb=3564ef6fb4685bbecd05d027d91a9f7d81385b07 diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index e23b865..0d30584 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -6,14 +6,13 @@ uses drop, invui, vars, - particles_store, randoms, memory, worldgen, canvas, items, safeload, - mob, + mobs, console, effects, particles, @@ -53,7 +52,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; @@ -107,68 +106,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 + 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 @@ -204,8 +194,10 @@ procedure loadtexture(path:string); 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); @@ -254,22 +246,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); @@ -334,18 +311,12 @@ procedure cleargame; //anim_del2:=0; - inv.resetData; - - chest.resetData; - - furnace.resetData; - - 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 @@ -512,31 +483,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 - furnace.saveData; - 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); @@ -644,31 +603,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 - furnace.loadData; - //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; @@ -1038,7 +983,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; @@ -1394,6 +1339,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+'/'); @@ -1401,9 +1347,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'); @@ -1477,7 +1427,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 @@ -1531,7 +1481,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); @@ -2027,17 +1977,13 @@ procedure draw; draw_block(ix,iy); 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 @@ -2283,9 +2229,9 @@ function rt_useweap:boolean; damg:=1; if posi=0 then - i:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); + i:=Mobs.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); + i:=Mobs.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3); if i<>-1 then begin @@ -2720,9 +2666,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); @@ -2913,7 +2859,7 @@ procedure game; 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; @@ -2924,9 +2870,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