40 keymode
,updx
,updy
:integer;
41 seed
,nextseed
:integer;
44 light
:array [0..15] of image
;
45 bg
:array[0..1] of image
;
46 osad
:array [0..1,0..7] of image
;
47 back
:array [0..8] of image
;
48 gui
:array [0..34] of image
;
49 tue
:array [0..9] of image
;
56 toolus
,toolind
:integer;
63 msg
:array [0..4] of string;
64 msg_time
:array[0..4] of integer;
65 last_sleep_x
,last_sleep_y
:integer;
78 if nextseed
=0 then seed
:=getrelativetimems
; else seed
:=nextseed
;
81 if world_typ
=0 then genworld
;
83 if world_typ
=1 then genflat
;
85 player
.setX(get_spawn_x
*16+4);
86 player
.setY(get_spawn_y
*16);
90 procedure drwrect(x
,y
,w
,h
,t
:integer);
95 drawrect(x
+i
,y
+i
,w
-i
*2,h
-i
*2);
100 dt
:=GetRelativeTimeMs
- time
;
101 time
:=GetRelativeTimeMs
;
107 if fps
<s_max_fps
then if del
>0 then del
:=del
-1;
108 if fps
>s_max_fps
then if del
<200 then del
:=del
+1;
112 procedure ClearTextures
;
115 ix
, iy
, iz
: integer;
122 Vars
.clock
[ix
] := no
;
124 for ix
:= 0 to maxBlockTex
do
129 for ix
:= 0 to maxItemTex
do
152 Particles
.FreeTextures
;
160 for ix
:= 0 to CONST_MAX_CURS
do
163 //resetVirtualKeyboard(-1);
166 procedure create_msg(s
:string);
173 msg_time
[i
]:=msg_time
[i
-1];
176 msg_time
[0]:=getrelativetimems
;
180 procedure loadtexture(path
:string);
186 im
:=ld_tex('background.png',path
,'title/');
188 bg
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
189 float
:=ld_tex('float.png',path
,'gui/');
190 compas
:=ld_tex('compass.png',path
,'gui/');
191 im
:=ld_tex('clock.png',path
,'gui/');
193 Vars
.clock
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
194 if load_back_tex
then
196 im
:=ld_tex('back.png',path
,'');
197 for ix
:=0 to 8 do back
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
200 console
.exec('textures.cfg', 'AUTO');
202 Player
.LoadSkin('char_ani.png', path
);
203 Mobs
.LoadTextures(path
);
205 im
:=ld_tex('gui.png',path
,'gui/');
206 gui
[0]:=rotate_image_from_image(im
,0,0,16,16,0);
207 LoadCurImg(gui
[0], CUR_SELECT1
);
208 gui
[1]:=rotate_image_from_image(im
,0,16,168,21,0);
209 gui
[3]:=rotate_image_from_image(im
,16,0,16,16,0);
210 LoadCurImg(gui
[3], CUR_SELECT2
);
211 gui
[6]:=rotate_image_from_image(im
,0,56,120,12,0);
212 gui
[7]:=rotate_image_from_image(im
,0,68,120,12,0);
213 gui
[8]:=rotate_image_from_image(im
,0,80,120,12,0);
214 gui
[13]:=rotate_image_from_image(im
,1,93,9,9,0);//hp
215 gui
[14]:=rotate_image_from_image(im
,12,93,9,9,0);//hp
216 gui
[15]:=rotate_image_from_image(im
,23,93,9,9,0);//hp
217 gui
[17]:=rotate_image_from_image(im
,120,56,18,18,0);
219 gui
[26]:=rotate_image_from_image(im
,89,93,9,9,0);//hunger
220 gui
[27]:=rotate_image_from_image(im
,100,93,9,9,0);//hunger
221 gui
[28]:=rotate_image_from_image(im
,111,93,9,9,0);//hunger
223 gui
[29]:=rotate_image_from_image(im
,67,93,9,9,0);//air
224 gui
[30]:=rotate_image_from_image(im
,78,93,9,9,0);//air
226 gui
[31]:=rotate_image_from_image(im
,122,93,9,9,0);//hp hardcore
227 gui
[32]:=rotate_image_from_image(im
,133,93,9,9,0);//hp hardcore
228 gui
[33]:=rotate_image_from_image(im
,144,93,9,9,0);//hp hardcore
230 gui
[20]:=rotate_image_from_image(im
,121,75,9,13,0);
231 gui
[21]:=rotate_image_from_image(im
,130,75,9,13,0);
232 gui
[22]:=rotate_image_from_image(im
,0,103,120,12,0);
234 if load_minimap_tex
then gui
[16]:=ld_tex('mapbg.png',path
,'gui/');
236 for ix
:=0 to 9 do tue
[ix
]:=rotate_image_from_image(im
,16*ix
,40,16,16,0);
238 if load_weather_tex
then
240 im
:=ld_tex('rain.png',path
,'terrain/');
241 for ix
:=0 to 7 do osad
[0,ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
242 im
:=ld_tex('snow.png',path
,'terrain/');
243 for ix
:=0 to 7 do osad
[1,ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
246 if load_light_tex
then
248 im
:=ld_tex('light.png',path
,'terrain/');
249 for ix
:=0 to 15 do light
[ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
252 Particles
.LoadTextures(path
);
254 im
:=ld_tex('partition.png',path
,'gui/');
255 gui
[18]:=rotate_image_from_image(im
,0,0,84,42,0);
256 gui
[19]:=rotate_image_from_image(im
,0,42,4,4,0);
258 if load_sky_siz
<=0 then
259 sky
:=ld_tex('sky.png',path
,'terrain/');
261 sky
:=resize_image(ld_tex('sky.png',path
,'terrain/'),load_sky_siz
,2);
265 sun
:=ld_tex('sun.png',path
,'terrain/');
266 moon
:=ld_tex('moon_phase_0.png',path
,'terrain/moon_phases/');
270 sun
:=resize_image(ld_tex('sun.png',path
,'terrain/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
271 moon
:=resize_image(ld_tex('moon_phase_0.png',path
,'terrain/moon_phases/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
274 //load_virt_tex(ld_tex('touch.png',path,'gui/'));
332 setmaplight(0,ix
,iy
);
342 for ix
:=0 to CONST_MAX_LAYERS
do
346 procedure drw_load_line(s
:string;percent
:integer);
350 for ix
:=0 to getWidth
/16 do
351 for iy
:=0 to getHeight
/16 do
352 drawimage(bg
[0],ix
*16,iy
*16);
353 drawfonttext(s
,(getWidth
/2)-(length(s
)*8/2),(getHeight
/2)-8);
354 setcolor(128,128,128);
355 fillrect(getwidth
/2-50,getheight
/2+6,100,3);
356 setcolor(128,255,128);
357 fillrect(getwidth
/2-50,getheight
/2+6,percent
,3);
358 drawfonttext(integertostring(percent
)+'%',getwidth
/2-(length(integertostring(percent
)+'%')*8)/2,getheight
/2+12);
362 function getFlatMap(i
:integer):integer;
368 getFlatMap
:=getmap(ix
,iy
);
371 procedure setFlatMap(n
, i
:integer);
380 function getFlatMapInfo(i
:integer):integer;
386 getFlatMapInfo
:=getmapinfo(ix
,iy
);
389 procedure setFlatMapInfo(n
, i
:integer);
398 procedure SaveMapRLE
;
406 if (id
<>getFlatMap(i
+s
)) or (i
+s
>32767) then
416 procedure SaveMapInfoRLE
;
422 id
:=getFlatMapInfo(i
);
424 if (id
<>getFlatMapInfo(i
+s
)) or (i
+s
>32767) then
434 procedure LoadMapRLE
;
449 procedure LoadMapInfoRLE
;
458 setFlatMapInfo(id
, i
+j
);
464 procedure saveworld(path
:string);
469 if pl_world
=0 then world_name
:='world.sav';
471 if pl_world
=1 then world_name
:='nether.sav';
472 if file_exists(path
)<>1 then if create_folder(path
)=1 then debug('Folder created!');
473 if file_exists(path
+world_name
)>0 then delete_file(path
+world_name
);
474 if file_exists(path
+world_name
)<>1 then file_create(path
+world_name
);
475 if open_file(path
+world_name
)=1 then
477 writeint(player
.getX
);
478 writeint(player
.getY
);
482 drw_load_line('Background',50);
483 //Background and biomes
486 write_byte(getBackMap(ix
));
487 write_byte(getBiomMap(ix
));
490 drw_load_line('Chests', 55);
492 drw_load_line('Furnaces', 60);
494 drw_load_line('Mobs', 70);
496 drw_load_line('Drop', 80);
498 drw_load_line('Particles', 85);
501 drw_load_line('Other', 90);
505 write_byte(osadki_ani
);
506 write_byte(global_light
);
509 write_byte(clock_stage
);
512 writebool(b_sign
[ix
]);
513 writestr(t_sign
[ix
]);
516 drw_load_line('Ready',100);
517 if close_file(path
+world_name
)=1 then debug('World Saved!');
521 procedure savegame(path
:string);
525 drw_load_line('Basic',0);
526 if file_exists(path
+'player.dat')=1 then delete_file(path
+'player.dat');
527 if file_exists(path
)<>1 then if create_folder(path
)=1 then debug('Folder created!');
528 if file_exists(path
+'player.dat')<>1 then file_create(path
+'player.dat');
529 if open_file(path
+'player.dat')=1 then
532 write_byte(version_map
);
533 write_byte(gamemode
);
536 write_byte(pl_world
);
538 writeint(last_sleep_x
);
539 writeint(last_sleep_y
);
546 write_byte(moon_phase
);
549 if close_file(path
+'player.dat')=1 then debug('Saved!');
550 drw_load_line('Matrix',10);
556 function version_err(ver
:integer):boolean;
560 for ix
:=0 to getWidth
/16 do
561 for iy
:=0 to getHeight
/16 do
563 drawimage(bg
[0],ix
*16,iy
*16);
565 if version_map
=ver
then version_err
:=true; else
566 if version_map
>ver
then
568 drawfonttext('Old save format!',(getWidth
/2)-60,(getHeight
/2)-4);
573 if version_map
<ver
then
575 drawfonttext('New save format!',(getWidth
/2)-60,(getHeight
/2)-4);
583 function loadworld(path
:string):boolean;
588 if pl_world
=0 then world_name
:='world.sav';
590 if pl_world
=1 then world_name
:='nether.sav';
591 if file_exists(path
)=1 then
593 if file_exists(path
+world_name
)=1 then
595 if open_file(path
+world_name
)=1 then
597 player
.setX(readint
);
598 player
.setY(readint
);
602 drw_load_line('Background',50);
603 //Background and biomes
606 setBackMap(read_byte
, ix
);
607 setBiomMap(read_byte
, ix
);
609 drw_load_line('Chests', 55);
611 drw_load_line('Furnaces', 60);
614 drw_load_line('Drop', 80);
616 drw_load_line('Particles', 85);
619 drw_load_line('Other',90);
623 osadki_ani
:=read_byte
;
624 global_light
:=read_byte
;
627 clock_stage
:=read_byte
;
630 b_sign
[ix
]:=readbool
;
633 drw_load_line('Ready',100);
634 ///////////////////////
635 if close_file(path
+world_name
)=1 then begin loadworld
:=true; debug('World loaded!'); end;
636 end; else begin loadworld
:=false; debug('File not opened!'); end;
637 end; else begin loadworld
:=false; debug('File not exists!'); end;
638 end; else begin loadworld
:=false; debug('Folder not exists!'); end;
641 function loadgame(path
:string):boolean;
645 drw_load_line('Basic',0);
646 if file_exists(path
)=1 then
648 if file_exists(path
+'player.dat')=1 then
650 if open_file(path
+'player.dat')=1 then
654 if version_err(ver
)=false then
656 if close_file(path
+'player.dat')=1 then loadgame
:=false;
664 last_sleep_x
:=readint
;
665 last_sleep_y
:=readint
;
672 moon_phase
:=read_byte
;
675 drw_load_line('Matrix',10);
676 if close_file(path
+'player.dat')=1 then loadgame
:=loadworld(path
);
677 end; else loadgame
:=false;
678 end; else loadgame
:=false;
679 end; else loadgame
:=false;
682 procedure drawdeadlogo
;
687 fillrect(0,0,getWidth
,getHeight
);
688 dead
:=loadimage('/dl');
689 drawimage(dead
,(getWidth
/2)-(getimagewidth(dead
)/2),(getHeight
/2)-(getimageheight(dead
)/2));
690 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));
691 drawfonttext('Loading...',(getWidth
/2)-(40),getHeight
-8);
700 for ix
:=0 to getWidth
/16 do
701 for iy
:=0 to getHeight
/16 do
703 drawimage(bg
[0],ix
*16,iy
*16);
705 drawfonttext('Generation World...',(getWidth
/2)-(76),(getHeight
/2)-4);
711 //if s_spawn_mob then begin if pl_world=0 then begin megaspawn; end; else begin netherspawn; end; end;
712 if gamemode
=1 then fly
:=true else fly
:=false;
716 function gettext(text,text_f
:string; max
,typ
:integer;):string;
718 textField_id
:integer;
722 exitCmd
:=createCommand('Ok',CM_OK
,1);
725 textField_id
:=formAddTextField(text,text_f
,max
,typ
);
729 cli
:=getClickedCommand
;
731 gettext
:=formGetText(textField_id
);
735 procedure drw_btn(text:string; cur
,ccur
,h
,ty
:integer);
739 m_x
:=(getWidth
/2)-(120/2);
740 m_y
:=h
+((getHeight
/2))-((getimageheight(gui
[7])-2*cur
)/2)+((getimageheight(gui
[7])+2)*cur
);
743 if ccur
=cur
then drawimage(gui
[22],m_x
+i
*4,m_y
); else drawimage(gui
[6],m_x
+i
*8,m_y
);
747 if ccur
=cur
then drawimage(gui
[8],m_x
+i
*8,m_y
); else drawimage(gui
[7],m_x
+i
*8,m_y
);
749 setclip(0,0,getwidth
,getheight
);
750 m_x
:=(getWidth
/2)-(length(text)*8/2);
751 m_y
:=h
+((getHeight
/2))-((getimageheight(gui
[7])-2*cur
)/2)+((getimageheight(gui
[7])+2)*cur
)+((getimageheight(gui
[7])-8)/2);
752 drawfonttext(text,m_x
,m_y
);
755 procedure drw_txt(str
:string; xx
,n
,t
:integer);
759 m_x
:=(getWidth
/2)-(length(str
)*8/2);
761 if t
=0 then drawfonttext(str
,0,m_y
); else
762 if t
=1 then drawfonttext(str
,m_x
,m_y
);
765 function pos_end(s
:string; c
:char):integer;
769 for i
:=length(s
)-1 downto 0 do
771 if getchar(s
,i
)=c
then
780 function getroot(cancel_b
:boolean):string;
782 m_cur
,max_r
,pars
,ix
,iy
:integer;
785 roots
:array [0..15] of string;
787 im
:=rotate_image_from_image(ld_tex('background.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/'),16,0,16,16,0);
789 if cancel_b
then roots
[0]:='<CANCEL>';
790 if cancel_b
then max_r
:=1; else max_r
:=0;
791 while pos(rr
,'|')<>-1 do
794 roots
[max_r
]:=copy(rr
,0,pars
-1);
795 rr
:=copy(rr
,pars
+1,length(rr
));
801 if clickedKey(KEY_FM_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=max_r
; end;
802 if clickedKey(KEY_FM_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>max_r
then m_cur
:=0; end;
803 if clickedKey(KEY_FM_SELECT
) then
805 if (m_cur
=0) and (cancel_b
) then
812 getroot
:=roots
[m_cur
];
817 for ix
:=0 to getWidth
/16 do
818 for iy
:=0 to getHeight
/16 do
819 drawimage(im
,ix
*16,iy
*16);
822 fillrect(0,m_cur
*8,getWidth
-1,8);
823 for ix
:=0 to max_r
do
825 drawfonttext(roots
[ix
],0,ix
*8);
827 setcolor(255,255,255);
828 drawrect(0,m_cur
*8,getWidth
-1,8);
835 function filemanager(cancel_b
:boolean):string;
837 m_cur
,ix
,iy
,max_r
,pars
:integer;
839 last
,rr
,root
,path
:string;
840 names
:array [0..255] of string;
842 im
:=rotate_image_from_image(ld_tex('background.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/'),16,0,16,16,0);
845 root
:=getroot(cancel_b
);
852 if cancel_b
then names
[2]:='<CANCEL>';
854 if cancel_b
then max_r
:=3; else max_r
:=2;
855 while pos(rr
,'|')<>-1 do
858 names
[max_r
]:=copy(rr
,0,pars
-1);
859 rr
:=copy(rr
,pars
+1,length(rr
));
866 if clickedKey(KEY_FM_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=max_r
; end;
867 if clickedKey(KEY_FM_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>max_r
then m_cur
:=0; end;
868 if clickedKey(KEY_FM_SELECT
) then
873 debug('lol:'+pos_end(path
,'/'));
874 if (path
=root
) or (path
=root
+'/') then
876 root
:=getroot(cancel_b
);
886 path
:=copy(path
,0,pos_end(path
,'/'));
887 if cancel_b
then names
[2]:='<CANCEL>';
889 if cancel_b
then max_r
:=3; else max_r
:=2;
890 while pos(rr
,'|')<>-1 do
893 names
[max_r
]:=copy(rr
,0,pars
-1);
894 rr
:=copy(rr
,pars
+1,length(rr
));
906 if (m_cur
=2) and (cancel_b
) then
913 path
:=path
+'/'+names
[m_cur
];
915 if cancel_b
then names
[2]:='<CANCEL>';
917 if cancel_b
then max_r
:=3; else max_r
:=2;
918 while pos(rr
,'|')<>-1 do
921 names
[max_r
]:=copy(rr
,0,pars
-1);
922 rr
:=copy(rr
,pars
+1,length(rr
));
931 for ix
:=0 to getWidth
/16 do
932 for iy
:=0 to getHeight
/16 do
933 drawimage(im
,ix
*16,iy
*16);
936 fillrect(0,m_cur
*8,getWidth
-1,8);
937 for ix
:=0 to max_r
do
939 drawfonttext(names
[ix
],0,ix
*8);
941 setcolor(255,255,255);
942 drawrect(0,m_cur
*8,getWidth
-1,8);
950 procedure setsd(cancel_b
:boolean);
956 s
:=filemanager(cancel_b
);
960 if file_exists('/'+sd
+'/cavecraft')<>1 then
961 if create_folder('/'+sd
+'/cavecraft')=1 then debug('/cavecraft created!');
963 if file_exists('/'+sd
+'/cavecraft/saves')<>1 then
964 if create_folder('/'+sd
+'/cavecraft/saves')=1 then debug('/saves created!');
966 if file_exists('/'+sd
+'/cavecraft/screenshots')<>1 then
967 if create_folder('/'+sd
+'/cavecraft/screenshots')=1 then debug('/screenshots created!');
969 if file_exists('/'+sd
+'/cavecraft/texturepacks')<>1 then
970 if create_folder('/'+sd
+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');
972 deleteRecordStore('SD');
973 rs
:=openRecordStore('SD');
974 t
:=addRecordStoreEntry(rs
,sd
);
975 closeRecordStore(rs
);
986 rs
:=openRecordStore('SD');
987 sd
:=readRecordStoreEntry(rs
,1);
988 closeRecordStore(rs
);
989 console
.exec('autoexec.cfg', 'AUTO');
997 //load_virt_tex(loadimage('/gui/touch.png'));
1001 if file_exists('/'+sd
+'/cavecraft')<>1 then
1002 if create_folder('/'+sd
+'/cavecraft')=1 then debug('/cavecraft created!');
1004 if file_exists('/'+sd
+'/cavecraft/saves')<>1 then
1005 if create_folder('/'+sd
+'/cavecraft/saves')=1 then debug('/saves created!');
1007 if file_exists('/'+sd
+'/cavecraft/screenshots')<>1 then
1008 if create_folder('/'+sd
+'/cavecraft/screenshots')=1 then debug('/screenshots created!');
1010 if file_exists('/'+sd
+'/cavecraft/texturepacks')<>1 then
1011 if create_folder('/'+sd
+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');
1013 rs
:=openRecordStore('TX');
1014 ss
:=readRecordStoreEntry(rs
,1);
1015 closeRecordStore(rs
);
1020 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1021 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1030 function question(text:string):boolean;
1032 ix
,iy
,m_cur
:integer;
1036 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=1; end;
1037 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>1 then m_cur
:=0; end;
1038 if clickedKey(KEY_MENU_SELECT
) then begin if m_cur
=0 then question
:=true; else question
:=false; exit
; end;
1039 for ix
:=0 to getwidth
/16 do for iy
:=0 to getheight
/16 do drawimage(bg
[0],ix
*16,iy
*16);
1040 drawfonttext(text,getwidth
/2-(length(text)*8)/2,getheight
/2-16);
1041 drw_btn('Yes',0,m_cur
,0,1);
1042 drw_btn('No',1,m_cur
,0,1);
1048 function menu_game_new
:boolean;
1050 m_cur
,tmp_gm
,ix
,iy
,lol
:integer;
1051 tmp_cheats
,tmp_bon_chest
:boolean;
1052 newgametxt
:array[0..4] of string;
1056 newgametxt
[0]:='Survival';
1057 newgametxt
[1]:='Creative';
1058 newgametxt
[2]:='Hardcore';
1059 newgametxt
[3]:='Normal';
1060 newgametxt
[4]:='Flat';
1064 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<-2 then m_cur
:=5; end;
1065 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>5 then m_cur
:=-2; end;
1066 if clickedKey(KEY_MENU_SELECT
) then
1070 name
:=gettext('Name:',name
,10,TF_ANY
);
1074 tmp_gm
:=tmp_gm
+1; if tmp_gm
>2 then tmp_gm
:=0;
1075 if tmp_gm
=0 then tmp_cheats
:=false;
1076 if tmp_gm
=1 then tmp_cheats
:=true;
1077 if tmp_gm
=2 then begin tmp_cheats
:=false; tmp_bon_chest
:=false; end;
1081 nextseed
:=stringtointeger(gettext('Seed:',''+nextseed
,10,TF_NUMERIC
));
1085 world_typ
:=world_typ
+1;
1086 if world_typ
>1 then world_typ
:=0;
1090 if tmp_gm
<2 then tmp_cheats
:= not tmp_cheats
;
1094 if tmp_gm
<2 then tmp_bon_chest
:= not tmp_bon_chest
;
1100 bon_chest
:=tmp_bon_chest
;
1102 while file_exists('/'+sd
+'/cavecraft/saves/'+name
)=1 do
1109 menu_game_new
:=true;
1117 for ix
:=0 to getWidth
/16 do
1118 for iy
:=0 to getHeight
/16 do
1119 drawimage(bg
[0],ix
*16,iy
*16);
1121 drw_btn('Name:'+name
,-2,m_cur
,0,1);
1122 drw_btn('Mode:'+newgametxt
[tmp_gm
],-1,m_cur
,0,1);
1123 drw_btn('Seed:'+nextseed
,0,m_cur
,0,1);
1124 drw_btn('Type:'+newgametxt
[world_typ
+3],1,m_cur
,0,1);
1126 drw_btn('Cheats:'+tmp_cheats
,2,m_cur
,0,1);
1128 drw_btn('Cheats:'+tmp_cheats
,2,m_cur
,0,0);
1130 drw_btn('Chest:'+tmp_bon_chest
,3,m_cur
,0,1);
1132 drw_btn('Chest:'+tmp_bon_chest
,3,m_cur
,0,0);
1133 drw_btn('Create',4,m_cur
,0,1);
1134 drw_btn('Cancel',5,m_cur
,0,1);
1141 procedure deleteworld(path
:string);
1143 if file_exists(path
+'player.dat')=1 then delete_file(path
+'player.dat');
1144 if file_exists(path
+'world.sav')=1 then delete_file(path
+'world.sav');
1145 if file_exists(path
+'nether.sav')=1 then delete_file(path
+'nether.sav');
1146 if file_exists(path
+'pic.png')=1 then delete_file(path
+'pic.png');
1147 if file_exists(path
)=1 then delete_file(path
);
1148 if file_exists(path
)=0 then debug('World deleted!');
1151 function menu_game
:boolean;
1153 ix
,iy
,pars
,max_r
,cur_name
,m_cur
:integer;
1157 names
:array[0..255] of string;
1159 rr
:=get_dirs('/'+sd
+'/cavecraft/saves/');
1160 while pos(rr
,'|')<>-1 do
1163 names
[max_r
]:=copy(rr
,0,pars
-1);
1164 rr
:=copy(rr
,pars
+1,length(rr
));
1165 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[max_r
]+'/player.dat')=1 then max_r
:=max_r
+1;
1168 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1169 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1170 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1172 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1173 mm_t_b
:=true; else mm_t_b
:=false;
1177 if clickedKey(KEY_MENU_UP
) then
1180 if m_cur
<0 then m_cur
:=3;
1182 if clickedKey(KEY_MENU_DOWN
) then
1185 if m_cur
>3 then m_cur
:=0;
1188 if (max_r
>= 0) and clickedKey(KEY_MENU_LEFT
) then
1190 cur_name
:=cur_name
-1;
1191 if cur_name
<0 then cur_name
:=0;
1192 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1193 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1194 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1196 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1198 if (max_r
>= 0) and clickedKey(KEY_MENU_RIGHT
) then
1200 cur_name
:=cur_name
+1;
1201 if cur_name
>max_r
then cur_name
:=max_r
;
1202 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1203 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1204 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1206 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1208 if clickedKey(KEY_MENU_SELECT
) then
1213 if loadgame('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/') then
1215 sav_fl
:=names
[cur_name
];
1222 if menu_game_new
then begin menu_game
:=true; break
; end;
1226 debug('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/');
1228 if question('Are you sure?')=true then deleteworld('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/');
1231 rr
:=get_dirs('/'+sd
+'/cavecraft/saves/');
1232 while pos(rr
,'|')<>-1 do
1235 names
[max_r
]:=copy(rr
,0,pars
-1);
1236 rr
:=copy(rr
,pars
+1,length(rr
));
1240 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1241 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1242 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1250 for ix
:=0 to getWidth
/16 do
1252 drawimage(bg
[1],ix
*16,iy
*16);
1253 for ix
:=0 to getWidth
/16 do
1254 drawimage(bg
[0],ix
*16,0);
1255 for ix
:=0 to getWidth
/16 do
1256 for iy
:=8 to getHeight
/16 do
1257 drawimage(bg
[0],ix
*16,iy
*16);
1262 fillrect(32,24,getWidth
-64,96);
1263 setclip(32,24,getWidth
-64,96);
1264 drawimage(im_game
,(getWidth
/2)-(32),32);
1265 drawfonttext(names
[cur_name
],(getWidth
/2)-(length(names
[cur_name
])*8/2),104);
1266 setclip(0,0,getWidth
,getHeight
);
1267 setcolor(128,128,128);
1268 drawrect(32,24,getWidth
-64,96);
1269 if cur_name
>0 then drawimage(gui
[20],0,58);
1270 if cur_name
<max_r
then drawimage(gui
[21],getWidth
-9,58);
1275 fillrect(32,24,getWidth
-64,96);
1276 setclip(32,24,getWidth
-64,96);
1277 drawfonttext('No saves!',(getWidth
/2)-(length('No saves!')*8/2),104);
1278 setclip(0,0,getWidth
,getHeight
);
1279 setcolor(128,128,128);
1280 drawrect(32,24,getWidth
-64,96);
1283 if mm_t_b
then drw_btn('Play',0,m_cur
,32,1); else drw_btn('Play',0,m_cur
,32,0);
1284 drw_btn('Create new',1,m_cur
,32,1);
1285 if mm_t_b
then drw_btn('Delete',2,m_cur
,32,1); else drw_btn('Delete',2,m_cur
,32,0);
1286 drw_btn('Back',3,m_cur
,32,1);
1287 if not mm_t_b
then cur_name
:=cur_name
+1;
1296 ix
,iy
,pars
,max_r
,cur_name
,m_cur
,t
:integer;
1299 names
:array[0..255] of string;
1302 rr
:=get_dirs('/'+sd
+'/cavecraft/texturepacks/');
1303 names
[0]:='Default';
1305 while pos(rr
,'|')<>-1 do
1308 names
[max_r
]:=copy(rr
,0,pars
-1);
1309 rr
:=copy(rr
,pars
+1,length(rr
));
1313 im_game
:=loadimage('/pack.png');
1317 if clickedKey(KEY_MENU_UP
) then
1320 if m_cur
<0 then m_cur
:=1;
1322 if clickedKey(KEY_MENU_DOWN
) then
1325 if m_cur
>1 then m_cur
:=0;
1328 if clickedKey(KEY_MENU_LEFT
) then
1330 cur_name
:=cur_name
-1;
1331 if cur_name
<0 then cur_name
:=0;
1332 im_game
:=ld_tex('pack.png','/'+sd
+'/cavecraft/texturepacks/'+names
[cur_name
]+'/','');
1334 if clickedKey(KEY_MENU_RIGHT
) then
1336 cur_name
:=cur_name
+1;
1337 if cur_name
>max_r
then cur_name
:=max_r
;
1338 im_game
:=ld_tex('pack.png','/'+sd
+'/cavecraft/texturepacks/'+names
[cur_name
]+'/','');
1340 if clickedKey(KEY_MENU_SELECT
) then
1342 if m_cur
=0 then begin
1345 debug("Select TexturePack @ /" + sd
+ "/cavecraft/texturepacks/" + names
[cur_name
]);
1346 tex_pack
:=names
[cur_name
];
1347 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1348 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1349 deleteRecordStore('TX');
1350 rs
:=openRecordStore('TX');
1351 t
:=addRecordStoreEntry(rs
,tex_pack
);
1352 closeRecordStore(rs
);
1354 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1355 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1359 debug("Cancel Select TecturePack");
1362 deleteRecordStore('TX');
1363 rs
:=openRecordStore('TX');
1364 t
:=addRecordStoreEntry(rs
,'');
1365 closeRecordStore(rs
);
1368 if m_cur
=1 then break
;
1372 for ix
:=0 to getWidth
/16 do
1374 drawimage(bg
[1],ix
*16,iy
*16);
1375 for ix
:=0 to getWidth
/16 do
1376 drawimage(bg
[0],ix
*16,0);
1377 for ix
:=0 to getWidth
/16 do
1378 for iy
:=8 to getHeight
/16 do
1379 drawimage(bg
[0],ix
*16,iy
*16);
1384 fillrect(32,24,getWidth
-64,96);
1385 setclip(32,24,getWidth
-64,96);
1386 drawimage(im_game
,(getWidth
/2)-(32),32);
1387 drawfonttext(names
[cur_name
],(getWidth
/2)-(length(names
[cur_name
])*8/2),104);
1388 setclip(0,0,getWidth
,getHeight
);
1389 setcolor(128,128,128);
1390 drawrect(32,24,getWidth
-64,96);
1391 if cur_name
>0 then drawimage(gui
[20],0,58);
1392 if cur_name
<max_r
then drawimage(gui
[21],getWidth
-9,58);
1395 drw_btn('Done',0,m_cur
,32,1);
1396 drw_btn('Back',1,m_cur
,32,1);
1403 procedure menu_sett
;
1405 ix
,iy
,m_cur
:integer;
1410 if clickedKey(KEY_MENU_UP
) then
1413 if m_cur
<-3 then m_cur
:=5;
1415 if clickedKey(KEY_MENU_DOWN
) then
1418 if m_cur
>5 then m_cur
:=-3;
1420 if clickedKey(KEY_MENU_SELECT
) then
1424 light_type
:=light_type
+1;
1425 if light_type
>2 then light_type
:=0;
1433 Particles
.enabled
:= not Particles
.enabled
;
1437 drawgui
:=not drawgui
;
1441 if question('Are you sure?')=true then
1443 if load_key_tex
=0 then
1447 //load_virt_tex(ld_tex('touch.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'));
1450 if load_key_tex
=1 then
1453 resetVirtualKeyboard(-1);
1459 s_jpeg_quality
:=stringtointeger(gettext('JPEG quality:',''+s_jpeg_quality
,3,TF_NUMERIC
));
1460 if s_jpeg_quality
>100 then s_jpeg_quality
:=100; else
1461 if s_jpeg_quality
<0 then s_jpeg_quality
:=0;
1469 deleteRecordStore('S');
1470 deleteRecordStore('SD');
1471 deleteRecordStore('TX');
1481 for ix
:=0 to getWidth
/16 do
1482 for iy
:=0 to getHeight
/16 do
1483 drawimage(bg
[0],ix
*16,iy
*16);
1485 drw_btn('Light:'+light_type
,-3,m_cur
,0,1);
1486 drw_btn('Weather:'+ifosad
,-2,m_cur
,0,1);
1487 drw_btn('Particles:' + Particles
.enabled
, -1, m_cur
, 0, 1);
1488 drw_btn('Hide GUI:'+not drawgui
,0,m_cur
,0,1);
1489 drw_btn('Touch:'+(load_key_tex
>0),1,m_cur
,0,1);
1490 drw_btn('JPEG:'+s_jpeg_quality
,2,m_cur
,0,1);
1491 drw_btn('Set Root',3,m_cur
,0,1);
1492 drw_btn('Reset',4,m_cur
,0,1);
1493 drw_btn('Back',5,m_cur
,0,1);
1500 procedure menu_help
;
1506 if clickedKey(KEY_MENU_SELECT
) then break
;
1507 if pressedKey(KEY_MENU_UP
) then cur
:=cur
+1;
1508 if pressedKey(KEY_MENU_DOWN
) then cur
:=cur
-1;
1510 for ix
:=0 to getWidth
/16 do
1511 for iy
:=2 to (getHeight
/16)-2 do
1512 drawimage(bg
[1],ix
*16,iy
*16);
1514 for ix
:=0 to getWidth
/16 do
1516 drawimage(bg
[0],ix
*16,iy
*16);
1518 for ix
:=0 to getWidth
/16 do
1519 for iy
:=(getHeight
/16)-2 to getHeight
/16 do
1520 drawimage(bg
[0],ix
*16,iy
*16);
1522 setclip(0,32,getWidth
,(getHeight
/16-4)*16);
1524 drw_txt('Controls:',cur
,0,1);
1525 drw_txt('Left - Move left',cur
,1,0);
1526 drw_txt('Right - Move right',cur
,2,0);
1527 drw_txt('Up - Jump',cur
,3,0);
1528 drw_txt('Down - Put a block under you',cur
,4,0);
1529 drw_txt('1 - Inventory',cur
,5,0);
1530 drw_txt('Duble 1 - Craft',cur
,6,0);
1531 drw_txt('3 - Use block',cur
,7,0);
1532 drw_txt('7 - Debug info',cur
,8,0);
1533 drw_txt('Hold 7 - Console',cur
,9,0);
1534 drw_txt('9 - Pause',cur
,10,0);
1535 drw_txt('*, # - Browse inventory',cur
,11,0);
1536 drw_txt('0 - Edit mode',cur
,12,0);
1538 drw_txt('In inventory/chest:',cur
,14,1);
1539 drw_txt('3 - Enject object',cur
,15,0);
1540 drw_txt('Hold 3 - Enject stack',cur
,16,0);
1541 drw_txt('5 - Move the stack',cur
,17,0);
1542 drw_txt('Hold 5 - Divide stack',cur
,18,0);
1544 setclip(0,0,getWidth
,getHeight
);
1546 drw_btn('Back',0,0,getHeight
-getHeight
/2-16-6,1);
1553 procedure menu_about
;
1559 if clickedKey(KEY_MENU_SELECT
) then break
;
1560 if pressedKey(KEY_MENU_UP
) then cur
:=cur
+1;
1561 if pressedKey(KEY_MENU_DOWN
) then cur
:=cur
-1;
1563 for ix
:=0 to getWidth
/16 do
1564 for iy
:=2 to (getHeight
/16)-2 do
1565 drawimage(bg
[1],ix
*16,iy
*16);
1567 for ix
:=0 to getWidth
/16 do
1569 drawimage(bg
[0],ix
*16,iy
*16);
1571 for ix
:=0 to getWidth
/16 do
1572 for iy
:=(getHeight
/16)-2 to getHeight
/16 do
1573 drawimage(bg
[0],ix
*16,iy
*16);
1575 setclip(0,32,getWidth
,(getHeight
/16-4)*16);
1577 drw_txt('Developers:',cur
,0,1);
1578 drw_txt(#68+#101+#97+#68+#68+#111+#111+#77+#69+#82+' - Programmer',cur
,1,0);//dead
1579 drw_txt(#102+#114+#101+#100+#45+#98+#111+#121+' - Programmer',cur
,2,0);//fred-boy
1580 drw_txt(#65+#110+#100+#114+#101+#121+#53+#57+' - Programmer',cur
,3,0);//andrey59
1581 drw_txt(#89+#117+#82+#97+#78+#110+#78+#122+#90+#90+' - Artist',cur
,4,0);//yura
1582 drw_txt(#83+#97+#115+#104+#97+#71+' - Artist and idea generator',cur
,5,0);//sasha
1583 drw_txt(#66+#97+#74+#108+#101+#72+#84+#105+#72+' - Artist and tester',cur
,6,0);//valentin
1584 drw_txt(#65+#103+#114+#101+#115+#115+#111+#82+' - Tester',cur
,7,0);//agressor
1585 drw_txt(#118+#111+#108+#121+#97+#95+#110+#97+#115+#116+#97+#110+#101+' - Tester',cur
,8,0);//volya
1586 drw_txt(#97+#98+#97+#100+#111+#110+' - Tester',cur
,9,0);//abadon
1587 drw_txt(#77+#111+#110+#111+#103+#114+#111+#109+' - Tester',cur
,10,0);//monogrom
1588 drw_txt(#75+#97+#108+#116+#101+#114+' - Tester',cur
,11,0);//kalter
1590 drw_txt('Thanks:',cur
,12,1);
1591 drw_txt('Piligrim and 0vZ - Lib_jsr75i',cur
,13,0);
1592 drw_txt('Piligrim - Lib_effects',cur
,14,0);
1593 drw_txt('Kurdt - Lib_canvas',cur
,15,0);
1594 drw_txt('ViNT - Lib_png and Lib_bmp',cur
,16,0);
1595 drw_txt('aleshka - Lib_jpeg',cur
,17,0);
1596 drw_txt('Roman_V - Lib_safeload',cur
,18,0);
1598 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);
1599 drw_txt(#68+#101+#97+#68+#83+#111+#102+#116+#87+#97+#114+#101+' 2012-'+getyear(getcurrenttime
),cur
,22,0);
1601 drw_txt('Hello! :D',cur
,100,1);
1603 setclip(0,0,getWidth
,getHeight
);
1605 drw_btn('Back',0,0,getHeight
-getHeight
/2-16-6,1);
1612 function sm_siz
:integer;
1614 sm_siz
:=(getWidth
+getHeight
)/5;
1617 function sm_siz4
:integer;
1622 procedure draw_menu_back
;
1626 for ix
:=0 to getWidth
/16 do
1627 for iy
:=0 to getHeight
/16 do
1628 drawimage(bg
[0],ix
*16,iy
*16);
1633 m_cur
,ix
,iy
,iz
:integer;
1639 spl_y
,spl_del
:integer;
1642 cavelogo
:=ld_tex('cavelogo.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/');
1644 spl_y
:=getimageheight(cavelogo
);
1646 spl_del
:=getrelativetimems
;
1647 res
:=openResource('/title/splashes.txt');
1648 if ResourceAvailable(res
) then
1650 spl_i
:=stringtointeger(readline(res
));
1651 iy
:=random(spl_i
-1)+1;
1652 debug('SPLASH #'+iy
);
1654 splash
:=readline(res
);
1657 time
:=getcurrenttime
;
1658 if (getmonth(time
)=5) and (getday(time
)=7) then splash
:='Happy birthday, DeaDDooMER!';
1659 if ((getmonth(time
)=0) and (getday(time
)<3)) or ((getmonth(time
)=11) and (getday(time
)>29)) then splash
:='Happy New Year!';
1663 if clickedKey(KEY_MENU_UP
) then
1666 if m_cur
<0 then m_cur
:=5;
1668 if clickedKey(KEY_MENU_DOWN
) then
1671 if m_cur
>5 then m_cur
:=0;
1673 if clickedKey(KEY_MENU_SELECT
) then
1675 if m_cur
=0 then begin if menu_game
then break
; end;
1677 if m_cur
=1 then menu_tex
;
1679 if m_cur
=2 then menu_sett
;
1681 if m_cur
=3 then menu_help
;
1683 if m_cur
=4 then menu_about
;
1685 if m_cur
=5 then begin save_settings
; halt
; end;
1690 drawimage(cavelogo
,(getWidth
/2)-(getimagewidth(cavelogo
)/2),0);
1691 setcolor(255,255,0);
1693 DrawFontTextSpec(splash
, (getWidth
/2)-(length(splash
)*FONT_SYM_SIZE
/2), spl_y
, FONT_YELLOW_COLOR
, true);
1695 if spl_y_b
then begin if getrelativetimems
-spl_del
>64 then begin spl_y
:=spl_y
+1; spl_del
:=getrelativetimems
; end; if spl_y
>getimageheight(cavelogo
)+2 then spl_y_b
:=false; end;
1696 if not spl_y_b
then begin if getrelativetimems
-spl_del
>64 then begin spl_y
:=spl_y
-1; spl_del
:=getrelativetimems
; end; if spl_y
<getimageheight(cavelogo
)+1 then spl_y_b
:=true; end;
1697 drawfonttext(version
,0,getHeight
-8);
1699 drw_btn('Singleplayer',0,m_cur
,0,1);
1700 drw_btn('Texture Packs',1,m_cur
,0,1);
1701 drw_btn('Options',2,m_cur
,0,1);
1702 drw_btn('Help',3,m_cur
,0,1);
1703 drw_btn('About',4,m_cur
,0,1);
1704 drw_btn('Quit Game',5,m_cur
,0,1);
1711 function setBlock(invcur
, x
, y
:integer):boolean;
1713 item
, sum
, block
, sblock
:integer;
1715 item
:=inv
.getItem(invcur
);
1716 sum
:=inv
.getSum(invcur
);
1717 block
:=getMap(x
, y
);
1718 sblock
:= Items
.GetData(item
);
1720 if (Items
.GetType(item
) = Items
.block
) and (Inv
.IsNull(invcur
) = false) then
1721 if Blocks
.IsOverlapped(block
) then
1722 // if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then
1724 if set_block_code(sblock
, x
, y
)=false then
1727 setmap(sblock
, x
, y
);
1730 inv
.setSum(inv
.getSum(invcur
)-1, invcur
);
1731 inv
.fixNull(invcur
);
1745 if (getrelativetimems
-fish_time
>5000) and (getmap(fx
,fy
)=50) then
1747 if (random(3)=2) and (getmap(fx
,fy
)=50) then
1749 drop
.create(210,1,x
,y
);
1752 inv
.setSum(inv
.getSum(invslot
)-1, invslot
);
1753 inv
.fixNull(invslot
);
1756 if (getrelativetimems
-fish_time
<5000) and (getmap(fx
,fy
)=50) and (fish
=true) then
1758 if getmap(fx
,fy
-1)=50 then fy
:=fy
-1;
1762 procedure drawminimap
;
1764 ix
,iy
,tmp_gx
,tmp_gy
,minx
,miny
,maxx
,maxy
,loc_camx
,loc_camy
,x
,y
:integer;
1768 if load_minimap_tex
then
1770 tmp_gx
:=(getWidth
/2)-(getimagewidth(gui
[16])/2);
1771 tmp_gy
:=(getHeight
/2)-(getimageheight(gui
[16])/2);
1775 tmp_gx
:=(getWidth
/2)-(64/2);
1776 tmp_gy
:=(getHeight
/2)-(64/2);
1779 loc_camx
:=(x
+4)-(864/2);
1780 loc_camy
:=(y
+4)-(864/2);
1781 if loc_camx
<0 then loc_camx
:=0;
1782 if loc_camx
>4096-864 then loc_camx
:=4096-864;
1783 if loc_camy
<0 then loc_camy
:=0;
1784 if loc_camy
>2048-864 then loc_camy
:=2048-864;
1787 maxx
:=(loc_camx
+864)/16;
1788 maxy
:=(loc_camy
+864)/16;
1789 if minx
<0 then minx
:=0;
1790 if miny
<0 then miny
:=0;
1791 if maxx
>255 then maxx
:=255;
1792 if maxy
>127 then maxy
:=127;
1794 if load_minimap_tex
then
1795 drawimage(gui
[16],tmp_gx
,tmp_gy
);
1798 setcolor(214,190,150);
1799 fillrect(tmp_gx
,tmp_gy
,64,64);
1802 for ix
:=minx
to maxx
do
1803 for iy
:=miny
to maxy
do
1805 if (getmap(ix
,iy
)=1) or (getmap(ix
,iy
)=2) or (getmap(ix
,iy
)=74) then setcolor(121,85,58); else
1806 if (getmap(ix
,iy
)=4) or (getmap(ix
,iy
)=9) or (getmap(ix
,iy
)=11) or (getmap(ix
,iy
)=28) or (getmap(ix
,iy
)=29) or ((getmap(ix
,iy
)>=77) and (getmap(ix
,iy
)<=86)) or ((getmap(ix
,iy
)>=88) and (getmap(ix
,iy
)<=101)) then setcolor(188,152,98); else
1807 if (getmap(ix
,iy
)=50) or (getmap(ix
,iy
)=62) then setcolor(38,92,255); else
1808 if getmap(ix
,iy
)=51 then setcolor(255,0,0); else
1809 if (getmap(ix
,iy
)=61) or (getmap(ix
,iy
)=32) then setcolor(255,255,255); else
1810 setcolor(127,127,127);
1812 if (getmap(ix
,iy
)<>0) then plot(tmp_gx
+4+ix
-minx
,tmp_gy
+4+iy
-miny
);
1817 procedure draw_sign
;
1820 str
:array[0..3] of string;
1821 i
,j
,tmp_gx
,tmp_gy
:integer;
1823 if load_gui_tex
then
1825 tmp_gx
:=(getWidth
/2)-(getimagewidth(sign_im
)/2);
1826 tmp_gy
:=(getHeight
/2)-(getimageheight(sign_im
)/2);
1830 tmp_gx
:=(getWidth
/2)-(120/2);
1831 tmp_gy
:=(getHeight
/2)-(60/2);
1834 tmp
:=t_sign
[getmapinfo(curx
,cury
)];
1835 while pos(tmp
,#13)<>-1 do
1838 str
[j
]:=copy(tmp
,0,i
);
1839 tmp
:=copy(tmp
,i
+1,length(tmp
));
1843 if load_gui_tex
then
1844 drawimage(sign_im
,tmp_gx
,tmp_gy
);
1847 setcolor(159,132,77);
1848 fillrect(tmp_gx
,tmp_gy
,120,60);
1851 drawfonttext(str
[0],tmp_gx
+(120/2)-(length(str
[0])*8/2),tmp_gy
+(60/4/2)+4);
1852 drawfonttext(str
[1],tmp_gx
+(120/2)-(length(str
[1])*8/2),tmp_gy
+(60/4/2)+8+4);
1853 drawfonttext(str
[2],tmp_gx
+(120/2)-(length(str
[2])*8/2),tmp_gy
+(60/4/2)+16+4);
1854 drawfonttext(str
[3],tmp_gx
+(120/2)-(length(str
[3])*8/2),tmp_gy
+(60/4/2)+24+4);
1857 procedure draw_back(ix
,iy
:integer);
1859 if getBiomMap(ix
)=0 then
1861 if (getBackMap(ix
)=iy
) then drawimage(back
[0],(ix
*16)-camx
,(iy
*16)-camy
); else
1862 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1863 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1864 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1865 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1867 if getBiomMap(ix
)=1 then
1869 if (getBackMap(ix
)=iy
) then drawimage(back
[4],(ix
*16)-camx
,(iy
*16)-camy
); else
1870 if (getBackMap(ix
)+1=iy
) then drawimage(back
[4],(ix
*16)-camx
,(iy
*16)-camy
); else
1871 if (getBackMap(ix
)+2=iy
) then drawimage(back
[6],(ix
*16)-camx
,(iy
*16)-camy
); else
1872 if (getBackMap(ix
)+3=iy
) then drawimage(back
[6],(ix
*16)-camx
,(iy
*16)-camy
); else
1873 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1875 if getBiomMap(ix
)=2 then
1877 if (getBackMap(ix
)=iy
) then drawimage(back
[5],(ix
*16)-camx
,(iy
*16)-camy
); else
1878 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1879 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1880 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1881 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1883 if getBiomMap(ix
)=3 then
1885 if (getBackMap(ix
)=iy
) then drawimage(back
[7],(ix
*16)-camx
,(iy
*16)-camy
); else
1886 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1887 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1888 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1889 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1891 if getBiomMap(ix
)=4 then
1893 drawimage(back
[8],(ix
*16)-camx
,(iy
*16)-camy
);
1899 ix
,iy
,iz
,minx
,miny
,maxx
,maxy
,tmp_ax
,tim
,smy
,pa_xo
, x
, y
:integer;
1903 {===================[sky]===================}
1904 tim
:=10000*getimagewidth(sky
)/600000*game_time
/10000;
1905 setcolor(effects
.get(sky
,tim
,0,1),effects
.get(sky
,tim
,0,2),effects
.get(sky
,tim
,0,3));
1906 fillrect(0,0,getWidth
,getHeight
);
1910 setcolor(effects
.get(sky
,tim
,2,1),effects
.get(sky
,tim
,2,2),effects
.get(sky
,tim
,2,3));
1911 smy
:=10000*getWidth
*2/600000*game_time
/10000;
1912 for iz
:=1 to getWidth
do
1914 ix
:=rnd(getWidth
*2)-getWidth
+smy
;
1915 if ix
>getWidth
then ix
:=ix
-getWidth
*2;
1917 if (ix
>-1) and (ix
<getWidth
) then plot(ix
,iy
);
1925 smy
:=10000*(getWidth
+getimagewidth(sun
))/300000*game_time
/10000;
1926 drawimage(sun
,smy
-getimagewidth(sun
),getHeight
/2-getimageheight(sun
)/2);
1930 setcolor(255,213,74);
1931 smy
:=10000*(getWidth
+sm_siz
)/300000*game_time
/10000;
1932 fillrect(smy
-sm_siz
+sm_siz4
,getHeight
/2-sm_siz
/2+sm_siz4
,sm_siz
-sm_siz4
,sm_siz
-sm_siz4
);
1937 smy
:=10000*(getWidth
+getimagewidth(moon
))/300000*(game_time
-300000)/10000;
1938 drawimage(moon
,smy
-getimagewidth(moon
),getHeight
/2-getimageheight(moon
)/2);
1942 setcolor(175,184,204);
1943 smy
:=10000*(getWidth
+sm_siz
)/300000*(game_time
-300000)/10000;
1944 fillrect(smy
-sm_siz
+sm_siz4
,getHeight
/2-sm_siz
/2+sm_siz4
,sm_siz
-sm_siz4
,sm_siz
-sm_siz4
);
1947 {===================[camera]===================}
1948 camx
:=(x
+4)-(getWidth
/2);
1949 camy
:=(y
+4)-(getHeight
/2);
1950 if camx
<0 then camx
:=0;
1951 if camx
>4096-getWidth
then camx
:=4096-getWidth
;
1952 if camy
>2048-getHeight
then camy
:=2048-getHeight
;
1953 {===================[max_draw]===================}
1956 maxx
:=(camx
+getWidth
)/16;
1957 maxy
:=(camy
+getHeight
)/16;
1958 if minx
<0 then minx
:=0;
1959 if miny
<0 then miny
:=0;
1960 if maxx
>255 then maxx
:=255;
1961 if maxy
>127 then maxy
:=127;
1962 {===================[draw_back]===================}
1963 for ix
:=minx
to maxx
do
1964 for iy
:=miny
to maxy
do
1966 if ifosad
and osadki
and (getBackMap(ix
) >= iy
) and Blocks
.IsTransporent(getmap(ix
, iy
)) then begin
1967 if getBiomMap(ix
) = 0 then drawimage(osad
[0, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1968 else if getBiomMap(ix
) = 2 then drawimage(osad
[1, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1969 else if getBiomMap(ix
) = 3 then drawimage(osad
[0, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1971 if drw_back
and Blocks
.IsTransporent(getmap(ix
, iy
)) then draw_back(ix
, iy
);
1972 if Blocks
.IsForeground(getmap(ix
,iy
)) = false then BlocksLogic
.Draw(ix
, iy
, camx
, camy
);
1974 {===================[drop]===================}
1975 Drop
.Draw(camx
, camy
);
1976 {===================[particles]===================}
1977 Particles
.Draw(camx
, camy
);
1978 {===================[player]===================}
1979 Player
.Draw(camx
, camy
);
1980 {===================[mobs]===================}
1981 Mobs
.Draw(camx
, camy
);
1982 {===================[draw_blocks]===================}
1983 for ix
:=minx
to maxx
do
1984 for iy
:=miny
to maxy
do
1986 if Blocks
.IsForeground(getmap(ix
, iy
)) then BlocksLogic
.Draw(ix
, iy
, camx
, camy
);
1989 if light_type
= 1 then
1991 if getmaplight(ix
,iy
) = 0 then
1992 fillrect((ix
* 16) - camx
, (iy
* 16) - camy
, 16, 16);
1994 else if light_type
= 2 then
1996 if getmaplight(ix
, iy
) < 15 then
1997 drawimage(light
[getmaplight(ix
, iy
)], (ix
* 16) - camx
, (iy
* 16) - camy
);
2002 // drawimage(light[getmaplight(player.getX div 16, player.getY div 16)], 0, 0);
2004 if (toolus
> 0) and (toolind
< 10) and (getmap(curx
,cury
) > 0) then
2008 drawimage(tue
[toolind
], curx
* 16 - camx
, cury
* 16 - camy
);
2010 {===================[gui]===================}
2013 tmp_ax
:=(getWidth
/2)-(getImageWidth(gui
[1])/2);
2016 drawimage(gui
[0],curx
*16-camx
,cury
*16-camy
);
2021 DrawPlayerInventory
;
2024 if keymode
=3 then drawcraft
; else
2025 if keymode
=4 then drawchest
; else
2026 if keymode
=5 then draw_sign
; else
2027 if keymode
=6 then drawfurnace
; else
2028 if ifminimap
then drawminimap
;*/
2030 drawimage(gui
[1],tmp_ax
,0);
2033 ItemsLogic
.Draw(inv
.getItem(ix
), inv
.getSum(ix
), (ix
*16)+tmp_ax
+ix
*2+4, 1, true);
2035 drawimage(gui
[17],(invslot
*16)+tmp_ax
+invslot
*2+2,0);
2041 for ix
:=0 to (hp
div 2)-1 do drawimage(gui
[13],ix
*9,getHeight
-9);
2042 if (hp
mod 2)<>0 then begin drawimage(gui
[14],ix
*9,getHeight
-9); ix
:=ix
+1 end;
2043 for ix
:=ix
to 9 do drawimage(gui
[15],ix
*9,getHeight
-9);
2047 for ix
:=0 to (hp
div 2)-1 do drawimage(gui
[31],ix
*9,getHeight
-9);
2048 if (hp
mod 2)<>0 then begin drawimage(gui
[32],ix
*9,getHeight
-9); ix
:=ix
+1 end;
2049 for ix
:=ix
to 9 do drawimage(gui
[33],ix
*9,getHeight
-9);
2052 for ix
:=0 to (hunger
div 2)-1 do drawimage(gui
[26],ix
*9,getHeight
-18);
2053 if (hunger
mod 2)<>0 then begin drawimage(gui
[27],ix
*9,getHeight
-18); ix
:=ix
+1 end;
2054 for ix
:=ix
to 9 do drawimage(gui
[28],ix
*9,getHeight
-18);
2056 if getmap((x
+4)/16,y
/16)=50 then
2058 for ix
:=0 to (air
div 2)-1 do drawimage(gui
[29],ix
*9,getHeight
-27);
2059 if (air
mod 2)<>0 then begin drawimage(gui
[30],ix
*9,getHeight
-27); ix
:=ix
+1 end;
2065 drawfonttext(msg
[ix
],0,getHeight
-20-ix
*9);
2066 if getrelativetimems
-msg_time
[ix
]>5000 then msg
[ix
]:='';
2071 procedure load_moon(path
:string;phase
:integer);
2078 moon
:=ld_tex('moon_phase_'+phase
+'.png',path
,'terrain/moon_phases/');
2082 moon
:=resize_image(ld_tex('moon_phase_'+phase
+'.png',path
,'terrain/moon_phases/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
2090 if game_time
>300000 then
2092 if load_light_tex
then
2098 for iy
:=0 to getheight
/16 do
2099 for ix
:=0 to getwidth
/16 do
2100 drawimage(light
[i
],ix
*16,iy
*16);
2105 moon_phase
:=moon_phase
+1;
2106 if moon_phase
>7 then moon_phase
:=0;
2107 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2110 last_sleep_y
:=cury
-1;
2115 for iy
:=0 to getheight
/16 do
2116 for ix
:=0 to getwidth
/16 do
2117 drawimage(light
[i
],ix
*16,iy
*16);
2127 while i
<=getheight
do
2130 fillrect(0,0,getwidth
,i
);
2135 moon_phase
:=moon_phase
+1;
2136 if moon_phase
>7 then moon_phase
:=0;
2137 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2140 last_sleep_y
:=cury
-1;
2142 while i
<=getheight
do
2146 fillrect(0,i
,getwidth
,getheight
);
2152 end; else create_msg('You can sleep only at night');
2155 procedure resetToolProgerss
;
2161 procedure usetools(invcur
, x
, y
:integer);
2163 item
, sum
, block
:integer;
2165 block
:=getmap(x
, y
);
2166 item
:=inv
.getItem(invcur
);
2167 sum
:=inv
.getSum(invcur
);
2170 destroy_block_cr(block
, x
, y
);
2174 if (Items
.GetType(item
) = Items
.tool
) and (Blocks
.GetTool(block
) = getToolType(item
)) then
2175 toolus
:=toolus
+getToolSpeed(item
);
2179 if toolus
>= Blocks
.GetResistant(block
) then
2181 if ((Items
.GetType(item
) = Items
.tool
) and (Blocks
.GetTool(block
) = getToolType(item
)) and (getToolLvl(item
) >= Blocks
.GetLevel(block
))) or (Blocks
.GetLevel(block
) <= 0) then
2184 destroy_block_1(block
, x
, y
);
2185 setMapInfo(0, x
, y
);
2190 destroy_block_0(block
, x
, y
);
2191 setMapInfo(0, x
, y
);
2194 if Items
.GetType(item
) = Items
.tool
then
2196 inv
.setSum(inv
.getSum(invcur
)-1, invcur
);
2197 inv
.fixNull(invcur
);
2205 if (toolus
> 0) and (toolus
<= Blocks
.GetResistant(block
)) then begin
2206 toolind
:= ((toolus
* 100) div Blocks
.GetResistant(block
)) div 10;
2210 function rt_useweap
:boolean;
2212 x
, y
, w
, h
, i
, damg
:integer;
2219 item
:=inv
.getItem(invslot
);
2221 if Items
.GetType(item
) = Items
.tool
then
2222 damg
:=getToolDamg(item
);
2227 i
:=Mobs
.findAndHit(damg
, x
-TILE_SIZE
, y
, TILE_SIZE
+(w
/2), h
, -2, -3);
2229 i
:=Mobs
.findAndHit(damg
, x
+(w
/2), y
, TILE_SIZE
+(w
/2), h
, 2, -3);
2233 inv
.setSum(inv
.getSum(invslot
)-1, invslot
);
2234 inv
.fixNull(invslot
);
2239 procedure rt_usetools
;
2246 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2248 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2250 if curx
<0 then curx
:=0;
2251 if curx
>255 then curx
:=255;
2252 if cury
<0 then cury
:=0;
2253 if cury
>127 then cury
:=127;
2255 usetools(invslot
, curx
, cury
);
2258 procedure rt_usemob
;
2265 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2267 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2269 if curx
<0 then curx
:=0;
2270 if curx
>255 then curx
:=255;
2271 if cury
<0 then cury
:=0;
2272 if cury
>127 then cury
:=127;
2274 //usemob(curx,cury);
2277 procedure actionUse(invcur
, x
, y
:integer);
2279 if setBlock(invcur
, x
, y
)=false then
2280 if useBlock(invcur
, x
, y
) then
2281 if useItem(invcur
, x
, y
) then
2284 procedure rt_useblock
;
2291 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2293 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2295 if curx
<0 then curx
:=0;
2296 if curx
>255 then curx
:=255;
2297 if cury
<0 then cury
:=0;
2298 if cury
>127 then cury
:=127;
2300 actionUse(invslot
, curx
, cury
);
2303 procedure go_to_nether
;
2307 portal_time
:=getrelativetimems
;
2308 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2310 drw_load_line('Matrix',10);
2311 if loadworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/')=true then
2313 player
.setX(get_spawn_x
*16+4);
2314 player
.setY((get_up(get_spawn_x
)-1)*16);
2327 mob[ix].m_min_vely:=0;
2330 mob[ix].m_fall:=false;
2331 mob[ix].m_jmp:=false;
2332 mob[ix].m_velani:=false;
2341 procedure go_to_world
;
2343 portal_time
:=getrelativetimems
;
2344 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2346 drw_load_line('Matrix',10);
2347 if loadworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/')=true then
2360 procedure plr_is_dead_hardcore
;
2368 if clickedKey(KEY_MENU_SELECT
) then
2370 deleteworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2375 drawfonttext('You died!',getwidth
/2-32,getheight
/2-16);
2377 drw_btn('Delete world',0,0,0,1);
2385 procedure plr_is_dead
;
2397 if clickedKey(KEY_MENU_UP
) then
2400 if m_cur
<0 then m_cur
:=1;
2402 if clickedKey(KEY_MENU_DOWN
) then
2405 if m_cur
>1 then m_cur
:=0;
2407 if clickedKey(KEY_MENU_SELECT
) then
2413 if last_sleep_x
=0 then
2415 x
:=get_spawn_x
*16+4;
2419 x
:=last_sleep_x
*16+4;
2426 if last_sleep_x
=0 then
2428 x
:=get_spawn_x
*16+4;
2432 x
:=last_sleep_x
*16+4;
2448 if m_cur
=1 then begin menu
; exit
; end;
2453 drawfonttext('You died!',getwidth
/2-32,getheight
/2-16);
2455 drw_btn('Respawn',0,m_cur
,0,1);
2456 drw_btn('Main menu',1,m_cur
,0,1);
2463 procedure fast_menu
;
2469 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=3; end;
2470 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>3 then m_cur
:=0; end;
2471 if clickedKey(KEY_MENU_SELECT
) then
2479 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2488 //clear_gui(keymode);
2494 drawfonttext('Game menu',getwidth
/2-36,getheight
/2-20);
2495 drw_btn('Back to Game',0,m_cur
,0,1);
2496 drw_btn('Save Game',1,m_cur
,0,1);
2497 drw_btn('Options',2,m_cur
,0,1);
2498 drw_btn('Quit to Title',3,m_cur
,0,1);
2505 procedure keyFastInv
;
2507 if clickedKey(KEY_FASTINV_NEXT
) then
2514 if clickedKey(KEY_FASTINV_PREV
) then
2522 procedure keyConsole
;
2524 if clickedKey(KEY_CHAT
) then
2525 SetTimer(1000,T_CONSOLE
);
2527 if pressedKey(KEY_CHAT
) then
2529 if GetTimer(T_CONSOLE
)=TIMER_OK
then
2532 ResetTimer(T_CONSOLE
);
2537 if GetTimer(T_CONSOLE
)>TIMER_OK
then
2540 ResetTimer(T_CONSOLE
);
2545 procedure keyInventory
;
2547 if clickedKey(KEY_PLR_OPENINV
) then
2549 OpenPlayerInventory
;
2554 procedure keyhandler
;
2558 if WindowKeyHanler
then
2566 if clickedKey(KEY_PLR_EDITMODE
) then
2569 curx
:=player
.getX
div 16;
2570 cury
:=player
.getY
div 16;
2573 if clickedKey(KEY_PLR_USE
) then
2576 if clickedKey(KEY_MENU
) then
2579 if clickedKey(KEY_PLR_ATTACK
) then
2580 if rt_useweap
=false then
2583 if pressedKey(KEY_PLR_ATTACK
) then
2586 playAnim(ANIM_HAND
);
2591 cancelAnim(ANIM_HAND
);
2594 if pressedKey(KEY_PLR_UP
) then
2596 if pressedKey(KEY_PLR_DOWN
) then
2598 if pressedKey(KEY_PLR_LEFT
) then
2600 if pressedKey(KEY_PLR_RIGHT
) then
2610 if clickedKey(KEY_PLR_UP
) then
2616 if clickedKey(KEY_PLR_DOWN
) then
2622 if clickedKey(KEY_PLR_LEFT
) then
2628 if clickedKey(KEY_PLR_RIGHT
) then
2635 if clickedKey(KEY_PLR_EDITMODE
) then
2638 if clickedKey(KEY_PLR_USE
) then
2639 actionUse(invslot
, curx
, cury
);
2641 if pressedKey(KEY_PLR_ATTACK
) then
2643 usetools(invslot
, curx
, cury
);
2644 playAnim(ANIM_HAND
);
2649 cancelAnim(ANIM_HAND
);
2652 if clickedKey(KEY_MENU
) then
2660 procedure phyhandler
;
2669 procedure light_fillrect(l
,x
,y
,r
:integer);
2671 ix
,iy
,ym
,yp
,xm
,xp
:integer;
2679 setmaplight(getmaplight(ix
,iy
)+l
,ix
,iy
);
2682 procedure light_rect(l
,x
,y
,r
:integer);
2684 ix
,iy
,ym
,yp
,xm
,xp
:integer;
2692 setmaplight(getmaplight(ix
,ym
)+l
,ix
,ym
);
2693 setmaplight(getmaplight(ix
,yp
)+l
,ix
,yp
);
2695 for iy
:=ym
+1 to yp
-1 do
2697 setmaplight(getmaplight(xm
,iy
)+l
,xm
,iy
);
2698 setmaplight(getmaplight(xp
,iy
)+l
,xp
,iy
);
2702 procedure calc_light(m
,x
,y
:integer);
2704 ix
,iy
,l
,ss
,sf
:integer;
2706 if light_type
=1 then light_fillrect(m
,x
,y
,m
/2); else
2707 for l
:=m
downto 1 do
2709 if ss
mod 2=0 then light_rect(l
,x
,y
,ss
/2);
2714 procedure calc_sun(ix
,m
:integer);
2721 setmaplight(ss
,ix
,iy
);
2723 ss
:= ss
- Blocks
.GetLightAbsorbtion(getmap(ix
, iy
));
2726 for iy
:=iy
+1 to 127 do
2728 setmaplight(0,ix
,iy
);
2737 for i
:=0 to INV_SIZE
do
2739 if inv
.isNull(i
)=false then
2740 player
.dropItem(inv
.getItem(i
), inv
.getSum(i
));
2744 if gamemode
<2 then plr_is_dead
; else plr_is_dead_hardcore
;
2747 procedure hunger_and_air
;
2755 if getrelativetimems
-hung_time
>=90000/(gamemode
+1) then
2757 hung_time
:=getrelativetimems
;
2760 if getrelativetimems
-hp_time
>=5000*(gamemode
+1) then
2764 hp_time
:=getrelativetimems
;
2766 if hp
>20 then hp
:=20;
2770 hp_time
:=getrelativetimems
;
2772 if hp
<1 then if gamemode
<2 then hp
:=1;
2776 if getmap((x
+4)/16,y
/16)=50 then
2778 if getrelativetimems
-air_time
>=500 then
2781 air_time
:=getrelativetimems
;
2784 hp_time
:=getrelativetimems
;
2795 ix
,iy
,minx
,maxx
,miny
,maxy
,fps_t
,tim
, x
, y
:integer;
2802 if hunger
<0 then hunger
:=0;
2803 if air
<0 then air
:=0;
2806 if fps_t
<1 then fps_t
:=1;
2809 if bl_ani5_v
=false then
2815 bl_ani5_v
:=not bl_ani5_v
;
2824 bl_ani5_v
:=not bl_ani5_v
;
2827 bl_ani5_d
:=not bl_ani5_d
;
2832 game_time
:=game_time
+(600000 div (fps_t
*1000));
2834 // Ускорение игрового времени в 10 раз
2835 // game_time := game_time + (600000 div (fps_t*100));
2837 if (game_time
>600000) or (game_time
<0) then
2840 moon_phase
:=moon_phase
+1;
2841 if moon_phase
>7 then moon_phase
:=0;
2842 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2845 tim
:= 10000 * getimagewidth(sky
) / 600000 * game_time
/ 10000;
2846 global_light
:= effects
.get(sky
, tim
, 1, 1) div 16;
2848 if clock_stage
<>game_time
div 75000 then begin clock_stage
:=clock_stage
+1; if clock_stage
>7 then clock_stage
:=0; end;
2850 if x
< 0 then x
:= 0;
2851 else if x
+ 8 > 4094 then x
:= 4086;
2852 if Blocks
.IsSolid(getmap(x
div 16, y
div 16)) then hp
:= hp
- 1;
2854 if random(4096)=random(4096) then begin osadki
:=not osadki
; end;
2855 osadki_ani
:=osadki_ani
+1;
2856 if osadki_ani
>7 then osadki_ani
:=0;
2858 if Random(20) = Random(20) then Particles
.Create(Particles
.bubble
, x
, y
);
2860 if gamemode
=1 then begin hp
:=666; hunger
:=666; end;
2862 if inv
.getItem(invslot
)=186 then
2867 //if s_spawn_mob then if random(4096)=1547 then megaspawn;
2872 if light_type
>0 then
2875 maxx
:=(camx
+getWidth
)/16+1;
2876 if minx
<0 then minx
:=0;
2877 if maxx
>255 then maxx
:=255;
2878 for ix
:=minx
to maxx
do calc_sun(ix
,global_light
);
2882 maxx
:=(camx
+getWidth
)/16+16;
2884 maxy
:=(camy
+getHeight
)/16+16;
2885 if minx
<0 then minx
:=0;
2886 if maxx
>255 then maxx
:=255;
2887 if miny
<0 then miny
:=0;
2888 if maxy
>127 then maxy
:=127;
2889 for ix
:=minx
to maxx
do
2890 for iy
:=miny
to maxy
do
2892 if light_type
= 0 then begin
2893 SetMapLight(15, ix
, iy
);
2894 end else if (light_type
> 0) and (Blocks
.GetLightEmission(getmap(ix
, iy
)) > 0) then begin
2895 calc_light(Blocks
.GetLightEmission(GetMap(ix
, iy
)), ix
, iy
);
2899 minx
:=(camx
/16)-((getwidth
/2)/16);
2900 miny
:=(camy
/16)-((getheight
/2)/16);
2901 maxx
:=(camx
+(getWidth
+getWidth
/2))/16;
2902 maxy
:=(camy
+(getHeight
+getHeight
/2))/16;
2903 if minx
<0 then minx
:=0;
2904 if miny
<0 then miny
:=0;
2905 if maxx
>255 then maxx
:=255;
2906 if maxy
>127 then maxy
:=127;
2907 if updx
<minx
then updx
:=minx
;
2908 if updy
<miny
then updy
:=miny
;
2909 if updx
>maxx
then updx
:=minx
;
2910 if updy
>maxy
then updy
:=miny
;
2914 for ix
:=0 to (((2*getWidth
/16)*(2*getHeight
/16))-1) div ((fps_t
*bl_upd
)) do
2916 updateBlock(updx
, updy
);
2922 if updy
>maxy
then updy
:=miny
;
2927 {if coll_bl(110)=true then
2929 if getrelativetimems-portal_time>5000 then
2931 if pl_world=0 then begin go_to_nether; portal_time:=getrelativetimems; end; else
2932 if pl_world=1 then begin go_to_world; portal_time:=getrelativetimems; end;
2936 if coll_bl(51)=true then hp:=hp-1;
2938 if coll_bl(59)=true then
2940 if vely<0 then vely:=-1;
2942 if vely>0 then vely:=1;
2947 if hp
>20 then hp
:=20;
2948 if hunger
>20 then hunger
:=20;
2951 if y
>2048 then kill_plr
;
2952 if (hp
<1) and (gamemode
<>1) then kill_plr
;
2953 if fish
=true then fishing
;
2955 if (fish
=true) and (inv
.getItem(invslot
)<>152) then fish
:=false;
2957 //if (keymode>3) and (cury<(y div 16)-4) then begin clear_gui(keymode); keymode:=0; curx:=x div 16; cury:=y div 16; end;
2961 if cury
<(y
div 16)-4 then cury
:=(y
div 16)-4;
2962 if cury
>(y
div 16)+5 then cury
:=(y
div 16)+5;
2963 if curx
<(x
div 16)-4 then curx
:=(x
div 16)-4;
2964 if curx
>(x
div 16)+4 then curx
:=(x
div 16)+4;
2975 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
2978 if load_key_tex
=1 then init_touch
;
2982 msg_time
[i
]:=getrelativetimems
;
2984 InitMap(MAP_W
, MAP_H
);
2988 procedure draw_debug
;
2992 //drawfonttext('X:'+(x div 16-128),0,0);
2993 //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8);
2994 drawfonttext('CURX:'+(curx
-128),0,16);
2995 drawfonttext('CURY:'+cury
,0,24);
2996 drawfonttext('UPDX:'+updx
,0,32);
2997 drawfonttext('UPDY:'+updy
,0,40);
2998 drawfonttext('FPS:'+fps
,0,56);
2999 drawfonttext('Free RAM:'+free_ram
/1024+' KB',0,64);
3000 drawfonttext('Total RAM:'+memory
.get_totalmemory
div 1024+' KB',0,72);
3001 drawfonttext('SEED:'+seed
,0,88);
3002 drawfonttext('Game time:'+game_time
,0,96);
3003 drawfonttext('Global light:' + global_light
, 0, 104);
3006 drawImage(light
[i
], getWidth
- 16, 16 * i
);
3009 function ItemToString(id
: integer) : string;
3013 if id
= Items
.none
then name
:= 'none'
3014 else if id
= Items
.dirt
then name
:= 'dirt'
3015 else if id
= Items
.grass
then name
:= 'grass'
3016 else if id
= Items
.stone
then name
:= 'stone'
3017 else if id
= Items
.oakWoodPlanks
then name
:= 'oakWoodPlanks'
3018 else if id
= Items
.cobblestone
then name
:= 'cobblestone'
3019 else if id
= Items
.bedrock
then name
:= 'bedrock'
3020 else if id
= Items
.sand
then name
:= 'sand'
3021 else if id
= Items
.gravel
then name
:= 'gravel'
3022 else if id
= Items
.oakWood
then name
:= 'oakWood'
3023 else if id
= Items
.obsidian
then name
:= 'obsidian'
3024 else if id
= Items
.bookshelf
then name
:= 'bookshelf'
3025 else if id
= Items
.mossStone
then name
:= 'mossStone'
3026 else if id
= Items
.blockOfIron
then name
:= 'blockOfIron'
3027 else if id
= Items
.blockOfGold
then name
:= 'blockOfGold'
3028 else if id
= Items
.blockOfDiamond
then name
:= 'blockOfDiamond'
3029 else if id
= Items
.goldOre
then name
:= 'goldOre'
3030 else if id
= Items
.ironOre
then name
:= 'ironOre'
3031 else if id
= Items
.coalOre
then name
:= 'coalOre'
3032 else if id
= Items
.diamondOre
then name
:= 'diamondOre'
3033 else if id
= Items
.redstoneOre
then name
:= 'redstoneOre'
3034 else if id
= Items
.oakLeaves
then name
:= 'oakLeaves'
3035 else if id
= Items
.redFlower
then name
:= 'redFlower'
3036 else if id
= Items
.yellowFlower
then name
:= 'yellowFlower'
3037 else if id
= Items
.redMooshroom
then name
:= 'redMooshroom'
3038 else if id
= Items
.brownMooshroom
then name
:= 'brownMooshroom'
3039 else if id
= Items
.torch
then name
:= 'torch'
3040 else if id
= Items
.tnt
then name
:= 'tnt'
3041 else if id
= Items
.chest
then name
:= 'chest'
3042 else if id
= Items
.craftingTable
then name
:= 'craftingTable'
3043 else if id
= Items
.cactus
then name
:= 'cactus'
3044 else if id
= Items
.glass
then name
:= 'glass'
3045 else if id
= Items
.wool1
then name
:= 'wool1'
3046 else if id
= Items
.wool2
then name
:= 'wool2'
3047 else if id
= Items
.wool3
then name
:= 'wool3'
3048 else if id
= Items
.wool4
then name
:= 'wool4'
3049 else if id
= Items
.wool5
then name
:= 'wool5'
3050 else if id
= Items
.wool6
then name
:= 'wool6'
3051 else if id
= Items
.wool7
then name
:= 'wool7'
3052 else if id
= Items
.wool8
then name
:= 'wool8'
3053 else if id
= Items
.wool9
then name
:= 'wool9'
3054 else if id
= Items
.wool10
then name
:= 'wool10'
3055 else if id
= Items
.wool11
then name
:= 'wool11'
3056 else if id
= Items
.wool12
then name
:= 'wool12'
3057 else if id
= Items
.wool13
then name
:= 'wool13'
3058 else if id
= Items
.wool14
then name
:= 'wool14'
3059 else if id
= Items
.wool15
then name
:= 'wool15'
3060 else if id
= Items
.wool16
then name
:= 'wool16'
3061 else if id
= Items
.snow
then name
:= 'snow'
3062 else if id
= Items
.ladder
then name
:= 'ladder'
3063 else if id
= Items
.water
then name
:= 'water'
3064 else if id
= Items
.lava
then name
:= 'lava'
3065 else if id
= Items
.oakSapling
then name
:= 'oakSapling'
3066 else if id
= Items
.sponge
then name
:= 'sponge'
3067 else if id
= Items
.lapisLazuliOre
then name
:= 'lapisLazuliOre'
3068 else if id
= Items
.lapisLazuliBlock
then name
:= 'lapisLazuliBlock'
3069 else if id
= Items
.sandstone
then name
:= 'sandstone'
3070 else if id
= Items
.tallGrass
then name
:= 'tallGrass'
3071 else if id
= Items
.deadBush
then name
:= 'deadBush'
3072 else if id
= Items
.cobweb
then name
:= 'cobweb'
3073 else if id
= Items
.bricks
then name
:= 'bricks'
3074 else if id
= Items
.snowBlock
then name
:= 'snowBlock'
3075 else if id
= Items
.ice
then name
:= 'ice'
3076 else if id
= Items
.snowLayer
then name
:= 'snowLayer'
3077 else if id
= Items
.clayBlock
then name
:= 'clayBlock'
3078 else if id
= Items
.sugarCane
then name
:= 'sugarCane'
3079 else if id
= Items
.pumpkin
then name
:= 'pumpkin'
3080 else if id
= Items
.jackLantern
then name
:= 'jackLantern'
3081 else if id
= Items
.stoneBricks
then name
:= 'stoneBricks'
3082 else if id
= Items
.mossyStoneBricks
then name
:= 'mossyStoneBricks'
3083 else if id
= Items
.crackedStoneBricks
then name
:= 'crackedStoneBricks'
3084 else if id
= Items
.chiseledStokeBricks
then name
:= 'chiseledStokeBricks'
3085 else if id
= Items
.ironBras
then name
:= 'ironBras'
3086 else if id
= Items
.melonBlock
then name
:= 'melonBlock'
3087 else if id
= Items
.mycelium
then name
:= 'mycelium'
3088 else if id
= Items
.backgroundOakWood
then name
:= 'backgroundOakWood'
3089 else if id
= Items
.spawner
then name
:= 'spawner'
3090 else if id
= Items
.bed1
then name
:= 'bed1'
3091 else if id
= Items
.bed2
then name
:= 'bed2'
3092 else if id
= Items
.openWoodenDoor1
then name
:= 'openWoodenDoor1'
3093 else if id
= Items
.openWoodenDoor2
then name
:= 'openWoodenDoor2'
3094 else if id
= Items
.closedWoodenDoor1
then name
:= 'closedWoodenDoor1'
3095 else if id
= Items
.closedWoodenDoor2
then name
:= 'closedWoodenDoor2'
3096 else if id
= Items
.birchWood
then name
:= 'birchWood'
3097 else if id
= Items
.backgroundBirchWood
then name
:= 'backgroundBirchWood'
3098 else if id
= Items
.spruceWood
then name
:= 'spruceWood'
3099 else if id
= Items
.backgroundSpruceWood
then name
:= 'backgroundSpruceWood'
3100 else if id
= Items
.spruceLeaves
then name
:= 'spruceLeaves'
3101 else if id
= Items
.redMushroomBlock1
then name
:= 'redMushroomBlock1'
3102 else if id
= Items
.redMushroomBlock2
then name
:= 'redMushroomBlock2'
3103 else if id
= Items
.brownMushroomBlock1
then name
:= 'brownMushroomBlock1'
3104 else if id
= Items
.brownMushroomBlock2
then name
:= 'brownMushroomBlock2'
3105 else if id
= Items
.oakFence
then name
:= 'oakFence'
3106 else if id
= Items
.backgroundOakFence
then name
:= 'backgroundOakFence'
3107 else if id
= Items
.backgroundOakWoodPlanks
then name
:= 'backgroundOakWoodPlanks'
3108 else if id
= Items
.painting1
then name
:= 'painting1'
3109 else if id
= Items
.painting2
then name
:= 'painting2'
3110 else if id
= Items
.painting3
then name
:= 'painting3'
3111 else if id
= Items
.painting4
then name
:= 'painting4'
3112 else if id
= Items
.painting5
then name
:= 'painting5'
3113 else if id
= Items
.painting6
then name
:= 'painting6'
3114 else if id
= Items
.painting7
then name
:= 'painting7'
3115 else if id
= Items
.giftChest
then name
:= 'giftChest'
3116 else if id
= Items
.vines
then name
:= 'vines'
3117 else if id
= Items
.sign
then name
:= 'sign'
3118 else if id
= Items
.redstoneTorch
then name
:= 'redstoneTorch'
3119 else if id
= Items
.furnace
then name
:= 'furnace'
3120 else if id
= Items
.closedWoodenTrapdoor
then name
:= 'closedWoodenTrapdoor'
3121 else if id
= Items
.openWoodenTrapdoor
then name
:= 'openWoodenTrapdoor'
3122 else if id
= Items
.netherrack
then name
:= 'netherrack'
3123 else if id
= Items
.netherPortal
then name
:= 'netherPortal'
3124 else if id
= Items
.glowstone
then name
:= 'glowstone'
3125 else if id
= Items
.birchLeaves
then name
:= 'birchLeaves'
3126 else if id
= Items
.soulSand
then name
:= 'soulSand'
3127 else if id
= Items
.birchSapling
then name
:= 'birchSapling'
3128 else if id
= Items
.spruceSapling
then name
:= 'spruceSapling'
3129 else if id
= Items
.redstoneLampOff
then name
:= 'redstoneLampOff'
3130 else if id
= Items
.redstoneLampOn
then name
:= 'redstoneLampOn'
3131 else if id
= Items
.backgroundObsidian
then name
:= 'backgroundObsidian'
3132 else if id
= Items
.glassPlane
then name
:= 'glassPlane'
3133 else if id
= Items
.farmland
then name
:= 'farmland'
3134 else if id
= Items
.cake
then name
:= 'cake'
3135 else if id
= Items
.wheatBlock
then name
:= 'wheatBlock'
3136 else if id
= Items
.melonStem
then name
:= 'melonStem'
3137 else if id
= Items
.pumpkinStem
then name
:= 'pumpkinStem'
3138 else if id
= Items
.burningFurnace
then name
:= 'burningFurnace'
3139 else if id
= Items
.reservedBlockItem
then name
:= 'reservedBlockItem'
3140 else if id
= Items
.stick
then name
:= 'stick'
3141 else if id
= Items
.dandelionYellow
then name
:= 'dandelionYellow'
3142 else if id
= Items
.roseRed
then name
:= 'roseRed'
3143 else if id
= Items
.superSpecialUnneededTool
then name
:= 'superSpecialUnneededTool'
3144 else if id
= Items
.pickaxe1
then name
:= 'pickaxe1'
3145 else if id
= Items
.pickaxe2
then name
:= 'pickaxe2'
3146 else if id
= Items
.pickaxe3
then name
:= 'pickaxe3'
3147 else if id
= Items
.pickaxe4
then name
:= 'pickaxe4'
3148 else if id
= Items
.pickaxe5
then name
:= 'pickaxe5'
3149 else if id
= Items
.shovel1
then name
:= 'shovel1'
3150 else if id
= Items
.shovel2
then name
:= 'shovel2'
3151 else if id
= Items
.shovel3
then name
:= 'shovel3'
3152 else if id
= Items
.shovel4
then name
:= 'shovel4'
3153 else if id
= Items
.shovel5
then name
:= 'shovel5'
3154 else if id
= Items
.axe1
then name
:= 'axe1'
3155 else if id
= Items
.axe2
then name
:= 'axe2'
3156 else if id
= Items
.axe3
then name
:= 'axe3'
3157 else if id
= Items
.axe4
then name
:= 'axe4'
3158 else if id
= Items
.axe5
then name
:= 'axe5'
3159 else if id
= Items
.shears
then name
:= 'shears'
3160 else if id
= Items
.sword1
then name
:= 'sword1'
3161 else if id
= Items
.sword2
then name
:= 'sword2'
3162 else if id
= Items
.sword3
then name
:= 'sword3'
3163 else if id
= Items
.sword4
then name
:= 'sword4'
3164 else if id
= Items
.sword5
then name
:= 'sword5'
3165 else if id
= Items
.fishingRod
then name
:= 'fishingRod'
3166 else if id
= Items
.lighter
then name
:= 'lighter'
3167 else if id
= Items
.hoe1
then name
:= 'hoe1'
3168 else if id
= Items
.hoe2
then name
:= 'hoe2'
3169 else if id
= Items
.hoe3
then name
:= 'hoe3'
3170 else if id
= Items
.hoe4
then name
:= 'hoe4'
3171 else if id
= Items
.hoe5
then name
:= 'hoe5'
3172 else if id
= Items
.reservedToolItem
then name
:= 'reservedToolItem'
3173 else if id
= Items
.coal
then name
:= 'coal'
3174 else if id
= Items
.redstone
then name
:= 'redstone'
3175 else if id
= Items
.diamond
then name
:= 'diamond'
3176 else if id
= Items
.brick
then name
:= 'brick'
3177 else if id
= Items
.ironIngot
then name
:= 'ironIngot'
3178 else if id
= Items
.goldIngot
then name
:= 'goldIngot'
3179 else if id
= Items
.lapisLazuli
then name
:= 'lapisLazuli'
3180 else if id
= Items
.strand
then name
:= 'strand'
3181 else if id
= Items
.snowball
then name
:= 'snowball'
3182 else if id
= Items
.clay
then name
:= 'clay'
3183 else if id
= Items
.book
then name
:= 'book'
3184 else if id
= Items
.bucket
then name
:= 'bucket'
3185 else if id
= Items
.waterBucket
then name
:= 'waterBucket'
3186 else if id
= Items
.lavaBucket
then name
:= 'lavaBucket'
3187 else if id
= Items
.milkBucket
then name
:= 'milkBucket'
3188 else if id
= Items
.paper
then name
:= 'paper'
3189 else if id
= Items
.melon
then name
:= 'melon'
3190 else if id
= Items
.egg
then name
:= 'egg'
3191 else if id
= Items
.door
then name
:= 'door'
3192 else if id
= Items
.bed
then name
:= 'bed'
3193 else if id
= Items
.spawnEggZombie
then name
:= 'spawnEggZombie'
3194 else if id
= Items
.spawnEggSheep
then name
:= 'spawnEggSheep'
3195 else if id
= Items
.spawnEggPig
then name
:= 'spawnEggPig'
3196 else if id
= Items
.gunpowder
then name
:= 'gunpowder'
3197 else if id
= Items
.bowl
then name
:= 'bowl'
3198 else if id
= Items
.mushroomStew
then name
:= 'mushroomStew'
3199 else if id
= Items
.map
then name
:= 'map'
3200 else if id
= Items
.painting
then name
:= 'painting'
3201 else if id
= Items
.rawPorkchop
then name
:= 'rawPorkchop'
3202 else if id
= Items
.cookedPorkchop
then name
:= 'cookedPorkchop'
3203 else if id
= Items
.rottenFlesh
then name
:= 'rottenFlesh'
3204 else if id
= Items
.camera1
then name
:= 'camera1'
3205 else if id
= Items
.camera2
then name
:= 'camera2'
3206 else if id
= Items
.camera3
then name
:= 'camera3'
3207 else if id
= Items
.goldNugget
then name
:= 'goldNugget'
3208 else if id
= Items
.sugar
then name
:= 'sugar'
3209 else if id
= Items
.spiderEye
then name
:= 'spiderEye'
3210 else if id
= Items
.feather
then name
:= 'feather'
3211 else if id
= Items
.leather
then name
:= 'leather'
3212 else if id
= Items
.rawBeef
then name
:= 'rawBeef'
3213 else if id
= Items
.steak
then name
:= 'steak'
3214 else if id
= Items
.apple
then name
:= 'apple'
3215 else if id
= Items
.goldenApple
then name
:= 'goldenApple'
3216 else if id
= Items
.rawChicken
then name
:= 'rawChicken'
3217 else if id
= Items
.cookedChicken
then name
:= 'cookedChicken'
3218 else if id
= Items
.spawnEggChicken
then name
:= 'spawnEggChicken'
3219 else if id
= Items
.spawnEggCreeper
then name
:= 'spawnEggCreeper'
3220 else if id
= Items
.flint
then name
:= 'flint'
3221 else if id
= Items
.spawnEggCow
then name
:= 'spawnEggCow'
3222 else if id
= Items
.spawnEggMooshroom
then name
:= 'spawnEggMooshroom'
3223 else if id
= Items
.rawFish
then name
:= 'rawFish'
3224 else if id
= Items
.cookedFish
then name
:= 'cookedFish'
3225 else if id
= Items
.spawnEggPigman
then name
:= 'spawnEggPigman'
3226 else if id
= Items
.spawnEggSpider
then name
:= 'spawnEggSpider'
3227 else if id
= Items
.glowstoneDust
then name
:= 'glowstoneDust'
3228 else if id
= Items
.clock
then name
:= 'clock'
3229 else if id
= Items
.compass
then name
:= 'compass'
3230 else if id
= Items
.seeds
then name
:= 'seeds'
3231 else if id
= Items
.wheat
then name
:= 'wheat'
3232 else if id
= Items
.bread
then name
:= 'bread'
3233 else if id
= Items
.boneMeal
then name
:= 'boneMeal'
3234 else if id
= Items
.melonSeeds
then name
:= 'melonSeeds'
3235 else if id
= Items
.pumpkinSeeds
then name
:= 'pumpkinSeeds'
3236 else name
:= '' + id
;
3240 procedure PrintItem(id
, typ
, tex
, max
, info
, texsource
, indicator
: integer; dividable
: boolean);
3242 name
, tname
, indname
: string;
3244 name
:= ItemToString(id
);
3246 if typ
= Items
.block
then tname
:= 'block'
3247 else if typ
= Items
.tool
then tname
:= 'tool'
3248 else if typ
= Items
.reserved
then tname
:= 'reserved'
3249 else if typ
= Items
.orditem
then tname
:= 'orditem'
3250 else tname
:= '' + typ
;
3252 if indicator
= Items
.noindicator
then indname
:= 'noindicator'
3253 else if indicator
= Items
.numeric
then indname
:= 'numeric'
3254 else if indicator
= Items
.line
then indname
:= 'line'
3255 else indname
:= '' + indicator
;
3257 Debug(' InitItem(' + name
+ ', ' + tname
+ ', ' + tex
+ ', ' + max
+ ', ' + info
+ ', ' + texsource
+ ', ' + indname
+ ', ' + dividable
+ ');');
3260 procedure PrintItemTable
;
3264 for id
:= 0 to 222 do begin
3268 Items
.GetTexture(id
),
3269 Items
.GetMaximum(id
),
3271 Items
.GetTextureSource(id
),
3272 Items
.GetIndicatorType(id
),
3273 Items
.IsDividable(id
)
3277 for id
:= 0 to 194 do begin
3278 Debug(' InitOrdItem(' + ItemToString(Items
.GetOrdinary(id
)) + ');');
3281 for id
:= 0 to 125 do begin
3282 Debug(' InitBlock(' + ItemToString(id
) + ', ' +
3283 Blocks
.GetTexture(id
) + ', ' +
3284 Blocks
.GetResistant(id
) + ', ' +
3285 Blocks
.GetTool(id
) + ', ' +
3286 Blocks
.GetLevel(id
) + ', ' +
3287 Blocks
.GetLightAbsorbtion(id
) + ', ' +
3288 Blocks
.GetLightEmission(id
) + ', ' +
3289 Blocks
.IsSolid(id
) + ', ' +
3290 Blocks
.IsTransporent(id
) + ', ' +
3291 Blocks
.IsForeground(id
) + ', ' +
3292 Blocks
.IsOverlapped(id
) + ');'
3299 hung_time
:=getrelativetimems
;
3300 hp_time
:=getrelativetimems
;
3301 air_time
:=getrelativetimems
;
3302 portal_time
:=getrelativetimems
;
3312 drawfonttext(version
,getWidth
-(length(version
)*8),getHeight
-8);
3313 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;