X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2FCAVE.mpsrc;h=0d305849e358ef1108de30fb24a68376cf90e8e9;hp=6de766ba1a2b5bb5536d231afc86dd059fc144ec;hb=9115be0a19d5716f33a2e2cba76f3447ce0f4c2f;hpb=13a872abec65a21544bfa928624c6bf3975fd50f diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index 6de766b..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, @@ -32,8 +31,7 @@ uses video; const - version = 'BETA 9'; - version_map = 9; + version_map = 9; var keymode,updx,updy:integer; @@ -54,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; @@ -108,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 @@ -205,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); @@ -255,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); @@ -335,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 @@ -513,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); @@ -645,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; @@ -1039,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; @@ -1395,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+'/'); @@ -1402,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'); @@ -1478,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 @@ -1532,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); @@ -2028,30 +1977,42 @@ 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 - begin - if getBlockFore(getmap(ix,iy))=true then - draw_block(ix,iy); + begin + if getBlockFore(getmap(ix, iy)) then + draw_block(ix, iy); - 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 @@ -2268,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 @@ -2705,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); @@ -2875,6 +2836,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; @@ -2883,8 +2847,8 @@ 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; @@ -2895,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; @@ -2906,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 @@ -3024,6 +2987,27 @@ 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; @@ -3038,20 +3022,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;