38 keymode
,updx
,updy
:integer;
39 seed
,nextseed
:integer;
42 light
:array [0..15] of image
;
43 bg
:array[0..1] of image
;
44 osad
:array [0..1,0..7] of image
;
45 back
:array [0..8] of image
;
46 gui
:array [0..34] of image
;
47 tue
:array [0..9] of image
;
54 toolus
,toolind
:integer;
61 msg
:array [0..4] of string;
62 msg_time
:array[0..4] of integer;
63 last_sleep_x
,last_sleep_y
:integer;
76 if nextseed
=0 then seed
:=getrelativetimems
; else seed
:=nextseed
;
79 if world_typ
=0 then genworld
;
81 if world_typ
=1 then genflat
;
83 player
.setX(get_spawn_x
*16+4);
84 player
.setY(get_spawn_y
*16);
88 procedure drwrect(x
,y
,w
,h
,t
:integer);
93 drawrect(x
+i
,y
+i
,w
-i
*2,h
-i
*2);
98 dt
:=GetRelativeTimeMs
- time
;
99 time
:=GetRelativeTimeMs
;
105 if fps
<s_max_fps
then if del
>0 then del
:=del
-1;
106 if fps
>s_max_fps
then if del
<200 then del
:=del
+1;
110 procedure ClearTextures
;
113 ix
, iy
, iz
: integer;
120 Vars
.clock
[ix
] := no
;
122 for ix
:= 0 to maxBlockTex
do
127 for ix
:= 0 to maxItemTex
do
150 Particles
.FreeTextures
;
158 for ix
:= 0 to CONST_MAX_CURS
do
161 //resetVirtualKeyboard(-1);
164 procedure create_msg(s
:string);
171 msg_time
[i
]:=msg_time
[i
-1];
174 msg_time
[0]:=getrelativetimems
;
178 procedure loadtexture(path
:string);
184 im
:=ld_tex('background.png',path
,'title/');
186 bg
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
187 float
:=ld_tex('float.png',path
,'gui/');
188 compas
:=ld_tex('compass.png',path
,'gui/');
189 im
:=ld_tex('clock.png',path
,'gui/');
191 Vars
.clock
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
192 if load_back_tex
then
194 im
:=ld_tex('back.png',path
,'');
195 for ix
:=0 to 8 do back
[ix
]:=rotate_image_from_image(im
,ix
*16,0,16,16,0);
198 console
.exec('textures.cfg', 'AUTO');
200 Player
.LoadSkin('char_ani.png', path
);
201 Mobs
.LoadTextures(path
);
203 im
:=ld_tex('gui.png',path
,'gui/');
204 gui
[0]:=rotate_image_from_image(im
,0,0,16,16,0);
205 LoadCurImg(gui
[0], CUR_SELECT1
);
206 gui
[1]:=rotate_image_from_image(im
,0,16,168,21,0);
207 gui
[3]:=rotate_image_from_image(im
,16,0,16,16,0);
208 LoadCurImg(gui
[3], CUR_SELECT2
);
209 gui
[6]:=rotate_image_from_image(im
,0,56,120,12,0);
210 gui
[7]:=rotate_image_from_image(im
,0,68,120,12,0);
211 gui
[8]:=rotate_image_from_image(im
,0,80,120,12,0);
212 gui
[13]:=rotate_image_from_image(im
,1,93,9,9,0);//hp
213 gui
[14]:=rotate_image_from_image(im
,12,93,9,9,0);//hp
214 gui
[15]:=rotate_image_from_image(im
,23,93,9,9,0);//hp
215 gui
[17]:=rotate_image_from_image(im
,120,56,18,18,0);
217 gui
[26]:=rotate_image_from_image(im
,89,93,9,9,0);//hunger
218 gui
[27]:=rotate_image_from_image(im
,100,93,9,9,0);//hunger
219 gui
[28]:=rotate_image_from_image(im
,111,93,9,9,0);//hunger
221 gui
[29]:=rotate_image_from_image(im
,67,93,9,9,0);//air
222 gui
[30]:=rotate_image_from_image(im
,78,93,9,9,0);//air
224 gui
[31]:=rotate_image_from_image(im
,122,93,9,9,0);//hp hardcore
225 gui
[32]:=rotate_image_from_image(im
,133,93,9,9,0);//hp hardcore
226 gui
[33]:=rotate_image_from_image(im
,144,93,9,9,0);//hp hardcore
228 gui
[20]:=rotate_image_from_image(im
,121,75,9,13,0);
229 gui
[21]:=rotate_image_from_image(im
,130,75,9,13,0);
230 gui
[22]:=rotate_image_from_image(im
,0,103,120,12,0);
232 if load_minimap_tex
then gui
[16]:=ld_tex('mapbg.png',path
,'gui/');
234 for ix
:=0 to 9 do tue
[ix
]:=rotate_image_from_image(im
,16*ix
,40,16,16,0);
236 if load_weather_tex
then
238 im
:=ld_tex('rain.png',path
,'terrain/');
239 for ix
:=0 to 7 do osad
[0,ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
240 im
:=ld_tex('snow.png',path
,'terrain/');
241 for ix
:=0 to 7 do osad
[1,ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
244 if load_light_tex
then
246 im
:=ld_tex('light.png',path
,'terrain/');
247 for ix
:=0 to 15 do light
[ix
]:=rotate_image_from_image(im
,16*ix
,0,16,16,0);
250 Particles
.LoadTextures(path
);
252 im
:=ld_tex('partition.png',path
,'gui/');
253 gui
[18]:=rotate_image_from_image(im
,0,0,84,42,0);
254 gui
[19]:=rotate_image_from_image(im
,0,42,4,4,0);
256 if load_sky_siz
<=0 then
257 sky
:=ld_tex('sky.png',path
,'terrain/');
259 sky
:=resize_image(ld_tex('sky.png',path
,'terrain/'),load_sky_siz
,2);
263 sun
:=ld_tex('sun.png',path
,'terrain/');
264 moon
:=ld_tex('moon_phase_0.png',path
,'terrain/moon_phases/');
268 sun
:=resize_image(ld_tex('sun.png',path
,'terrain/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
269 moon
:=resize_image(ld_tex('moon_phase_0.png',path
,'terrain/moon_phases/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
272 //load_virt_tex(ld_tex('touch.png',path,'gui/'));
330 setmaplight(0,ix
,iy
);
340 for ix
:=0 to CONST_MAX_LAYERS
do
344 procedure drw_load_line(s
:string;percent
:integer);
348 for ix
:=0 to getWidth
/16 do
349 for iy
:=0 to getHeight
/16 do
350 drawimage(bg
[0],ix
*16,iy
*16);
351 drawfonttext(s
,(getWidth
/2)-(length(s
)*8/2),(getHeight
/2)-8);
352 setcolor(128,128,128);
353 fillrect(getwidth
/2-50,getheight
/2+6,100,3);
354 setcolor(128,255,128);
355 fillrect(getwidth
/2-50,getheight
/2+6,percent
,3);
356 drawfonttext(integertostring(percent
)+'%',getwidth
/2-(length(integertostring(percent
)+'%')*8)/2,getheight
/2+12);
360 function getFlatMap(i
:integer):integer;
366 getFlatMap
:=getmap(ix
,iy
);
369 procedure setFlatMap(n
, i
:integer);
378 function getFlatMapInfo(i
:integer):integer;
384 getFlatMapInfo
:=getmapinfo(ix
,iy
);
387 procedure setFlatMapInfo(n
, i
:integer);
396 procedure SaveMapRLE
;
404 if (id
<>getFlatMap(i
+s
)) or (i
+s
>32767) then
414 procedure SaveMapInfoRLE
;
420 id
:=getFlatMapInfo(i
);
422 if (id
<>getFlatMapInfo(i
+s
)) or (i
+s
>32767) then
432 procedure LoadMapRLE
;
447 procedure LoadMapInfoRLE
;
456 setFlatMapInfo(id
, i
+j
);
462 procedure saveworld(path
:string);
467 if pl_world
=0 then world_name
:='world.sav';
469 if pl_world
=1 then world_name
:='nether.sav';
470 if file_exists(path
)<>1 then if create_folder(path
)=1 then debug('Folder created!');
471 if file_exists(path
+world_name
)>0 then delete_file(path
+world_name
);
472 if file_exists(path
+world_name
)<>1 then file_create(path
+world_name
);
473 if open_file(path
+world_name
)=1 then
475 writeint(player
.getX
);
476 writeint(player
.getY
);
480 drw_load_line('Background',50);
481 //Background and biomes
484 write_byte(getBackMap(ix
));
485 write_byte(getBiomMap(ix
));
488 drw_load_line('Chests', 55);
490 drw_load_line('Furnaces', 60);
492 drw_load_line('Mobs', 70);
494 drw_load_line('Drop', 80);
496 drw_load_line('Particles', 85);
499 drw_load_line('Other', 90);
503 write_byte(osadki_ani
);
504 write_byte(global_light
);
507 write_byte(clock_stage
);
510 writebool(b_sign
[ix
]);
511 writestr(t_sign
[ix
]);
514 drw_load_line('Ready',100);
515 if close_file(path
+world_name
)=1 then debug('World Saved!');
519 procedure savegame(path
:string);
523 drw_load_line('Basic',0);
524 if file_exists(path
+'player.dat')=1 then delete_file(path
+'player.dat');
525 if file_exists(path
)<>1 then if create_folder(path
)=1 then debug('Folder created!');
526 if file_exists(path
+'player.dat')<>1 then file_create(path
+'player.dat');
527 if open_file(path
+'player.dat')=1 then
530 write_byte(version_map
);
531 write_byte(gamemode
);
534 write_byte(pl_world
);
536 writeint(last_sleep_x
);
537 writeint(last_sleep_y
);
544 write_byte(moon_phase
);
547 if close_file(path
+'player.dat')=1 then debug('Saved!');
548 drw_load_line('Matrix',10);
554 function version_err(ver
:integer):boolean;
558 for ix
:=0 to getWidth
/16 do
559 for iy
:=0 to getHeight
/16 do
561 drawimage(bg
[0],ix
*16,iy
*16);
563 if version_map
=ver
then version_err
:=true; else
564 if version_map
>ver
then
566 drawfonttext('Old save format!',(getWidth
/2)-60,(getHeight
/2)-4);
571 if version_map
<ver
then
573 drawfonttext('New save format!',(getWidth
/2)-60,(getHeight
/2)-4);
581 function loadworld(path
:string):boolean;
586 if pl_world
=0 then world_name
:='world.sav';
588 if pl_world
=1 then world_name
:='nether.sav';
589 if file_exists(path
)=1 then
591 if file_exists(path
+world_name
)=1 then
593 if open_file(path
+world_name
)=1 then
595 player
.setX(readint
);
596 player
.setY(readint
);
600 drw_load_line('Background',50);
601 //Background and biomes
604 setBackMap(read_byte
, ix
);
605 setBiomMap(read_byte
, ix
);
607 drw_load_line('Chests', 55);
609 drw_load_line('Furnaces', 60);
612 drw_load_line('Drop', 80);
614 drw_load_line('Particles', 85);
617 drw_load_line('Other',90);
621 osadki_ani
:=read_byte
;
622 global_light
:=read_byte
;
625 clock_stage
:=read_byte
;
628 b_sign
[ix
]:=readbool
;
631 drw_load_line('Ready',100);
632 ///////////////////////
633 if close_file(path
+world_name
)=1 then begin loadworld
:=true; debug('World loaded!'); end;
634 end; else begin loadworld
:=false; debug('File not opened!'); end;
635 end; else begin loadworld
:=false; debug('File not exists!'); end;
636 end; else begin loadworld
:=false; debug('Folder not exists!'); end;
639 function loadgame(path
:string):boolean;
643 drw_load_line('Basic',0);
644 if file_exists(path
)=1 then
646 if file_exists(path
+'player.dat')=1 then
648 if open_file(path
+'player.dat')=1 then
652 if version_err(ver
)=false then
654 if close_file(path
+'player.dat')=1 then loadgame
:=false;
662 last_sleep_x
:=readint
;
663 last_sleep_y
:=readint
;
670 moon_phase
:=read_byte
;
673 drw_load_line('Matrix',10);
674 if close_file(path
+'player.dat')=1 then loadgame
:=loadworld(path
);
675 end; else loadgame
:=false;
676 end; else loadgame
:=false;
677 end; else loadgame
:=false;
680 procedure drawdeadlogo
;
685 fillrect(0,0,getWidth
,getHeight
);
686 dead
:=loadimage('/dl');
687 drawimage(dead
,(getWidth
/2)-(getimagewidth(dead
)/2),(getHeight
/2)-(getimageheight(dead
)/2));
688 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));
689 drawfonttext('Loading...',(getWidth
/2)-(40),getHeight
-8);
698 for ix
:=0 to getWidth
/16 do
699 for iy
:=0 to getHeight
/16 do
701 drawimage(bg
[0],ix
*16,iy
*16);
703 drawfonttext('Generation World...',(getWidth
/2)-(76),(getHeight
/2)-4);
709 //if s_spawn_mob then begin if pl_world=0 then begin megaspawn; end; else begin netherspawn; end; end;
710 if gamemode
=1 then fly
:=true else fly
:=false;
714 function gettext(text,text_f
:string; max
,typ
:integer;):string;
716 textField_id
:integer;
720 exitCmd
:=createCommand('Ok',CM_OK
,1);
723 textField_id
:=formAddTextField(text,text_f
,max
,typ
);
727 cli
:=getClickedCommand
;
729 gettext
:=formGetText(textField_id
);
733 procedure drw_btn(text:string; cur
,ccur
,h
,ty
:integer);
737 m_x
:=(getWidth
/2)-(120/2);
738 m_y
:=h
+((getHeight
/2))-((getimageheight(gui
[7])-2*cur
)/2)+((getimageheight(gui
[7])+2)*cur
);
741 if ccur
=cur
then drawimage(gui
[22],m_x
+i
*4,m_y
); else drawimage(gui
[6],m_x
+i
*8,m_y
);
745 if ccur
=cur
then drawimage(gui
[8],m_x
+i
*8,m_y
); else drawimage(gui
[7],m_x
+i
*8,m_y
);
747 setclip(0,0,getwidth
,getheight
);
748 m_x
:=(getWidth
/2)-(length(text)*8/2);
749 m_y
:=h
+((getHeight
/2))-((getimageheight(gui
[7])-2*cur
)/2)+((getimageheight(gui
[7])+2)*cur
)+((getimageheight(gui
[7])-8)/2);
750 drawfonttext(text,m_x
,m_y
);
753 procedure drw_txt(str
:string; xx
,n
,t
:integer);
757 m_x
:=(getWidth
/2)-(length(str
)*8/2);
759 if t
=0 then drawfonttext(str
,0,m_y
); else
760 if t
=1 then drawfonttext(str
,m_x
,m_y
);
763 function pos_end(s
:string; c
:char):integer;
767 for i
:=length(s
)-1 downto 0 do
769 if getchar(s
,i
)=c
then
778 function getroot(cancel_b
:boolean):string;
780 m_cur
,max_r
,pars
,ix
,iy
:integer;
783 roots
:array [0..15] of string;
785 im
:=rotate_image_from_image(ld_tex('background.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/'),16,0,16,16,0);
787 if cancel_b
then roots
[0]:='<CANCEL>';
788 if cancel_b
then max_r
:=1; else max_r
:=0;
789 while pos(rr
,'|')<>-1 do
792 roots
[max_r
]:=copy(rr
,0,pars
-1);
793 rr
:=copy(rr
,pars
+1,length(rr
));
799 if clickedKey(KEY_FM_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=max_r
; end;
800 if clickedKey(KEY_FM_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>max_r
then m_cur
:=0; end;
801 if clickedKey(KEY_FM_SELECT
) then
803 if (m_cur
=0) and (cancel_b
) then
810 getroot
:=roots
[m_cur
];
815 for ix
:=0 to getWidth
/16 do
816 for iy
:=0 to getHeight
/16 do
817 drawimage(im
,ix
*16,iy
*16);
820 fillrect(0,m_cur
*8,getWidth
-1,8);
821 for ix
:=0 to max_r
do
823 drawfonttext(roots
[ix
],0,ix
*8);
825 setcolor(255,255,255);
826 drawrect(0,m_cur
*8,getWidth
-1,8);
833 function filemanager(cancel_b
:boolean):string;
835 m_cur
,ix
,iy
,max_r
,pars
:integer;
837 last
,rr
,root
,path
:string;
838 names
:array [0..255] of string;
840 im
:=rotate_image_from_image(ld_tex('background.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/'),16,0,16,16,0);
843 root
:=getroot(cancel_b
);
850 if cancel_b
then names
[2]:='<CANCEL>';
852 if cancel_b
then max_r
:=3; else max_r
:=2;
853 while pos(rr
,'|')<>-1 do
856 names
[max_r
]:=copy(rr
,0,pars
-1);
857 rr
:=copy(rr
,pars
+1,length(rr
));
864 if clickedKey(KEY_FM_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=max_r
; end;
865 if clickedKey(KEY_FM_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>max_r
then m_cur
:=0; end;
866 if clickedKey(KEY_FM_SELECT
) then
871 debug('lol:'+pos_end(path
,'/'));
872 if (path
=root
) or (path
=root
+'/') then
874 root
:=getroot(cancel_b
);
884 path
:=copy(path
,0,pos_end(path
,'/'));
885 if cancel_b
then names
[2]:='<CANCEL>';
887 if cancel_b
then max_r
:=3; else max_r
:=2;
888 while pos(rr
,'|')<>-1 do
891 names
[max_r
]:=copy(rr
,0,pars
-1);
892 rr
:=copy(rr
,pars
+1,length(rr
));
904 if (m_cur
=2) and (cancel_b
) then
911 path
:=path
+'/'+names
[m_cur
];
913 if cancel_b
then names
[2]:='<CANCEL>';
915 if cancel_b
then max_r
:=3; else max_r
:=2;
916 while pos(rr
,'|')<>-1 do
919 names
[max_r
]:=copy(rr
,0,pars
-1);
920 rr
:=copy(rr
,pars
+1,length(rr
));
929 for ix
:=0 to getWidth
/16 do
930 for iy
:=0 to getHeight
/16 do
931 drawimage(im
,ix
*16,iy
*16);
934 fillrect(0,m_cur
*8,getWidth
-1,8);
935 for ix
:=0 to max_r
do
937 drawfonttext(names
[ix
],0,ix
*8);
939 setcolor(255,255,255);
940 drawrect(0,m_cur
*8,getWidth
-1,8);
948 procedure setsd(cancel_b
:boolean);
954 s
:=filemanager(cancel_b
);
958 if file_exists('/'+sd
+'/cavecraft')<>1 then
959 if create_folder('/'+sd
+'/cavecraft')=1 then debug('/cavecraft created!');
961 if file_exists('/'+sd
+'/cavecraft/saves')<>1 then
962 if create_folder('/'+sd
+'/cavecraft/saves')=1 then debug('/saves created!');
964 if file_exists('/'+sd
+'/cavecraft/screenshots')<>1 then
965 if create_folder('/'+sd
+'/cavecraft/screenshots')=1 then debug('/screenshots created!');
967 if file_exists('/'+sd
+'/cavecraft/texturepacks')<>1 then
968 if create_folder('/'+sd
+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');
970 deleteRecordStore('SD');
971 rs
:=openRecordStore('SD');
972 t
:=addRecordStoreEntry(rs
,sd
);
973 closeRecordStore(rs
);
984 rs
:=openRecordStore('SD');
985 sd
:=readRecordStoreEntry(rs
,1);
986 closeRecordStore(rs
);
987 console
.exec('autoexec.cfg', 'AUTO');
995 //load_virt_tex(loadimage('/gui/touch.png'));
999 if file_exists('/'+sd
+'/cavecraft')<>1 then
1000 if create_folder('/'+sd
+'/cavecraft')=1 then debug('/cavecraft created!');
1002 if file_exists('/'+sd
+'/cavecraft/saves')<>1 then
1003 if create_folder('/'+sd
+'/cavecraft/saves')=1 then debug('/saves created!');
1005 if file_exists('/'+sd
+'/cavecraft/screenshots')<>1 then
1006 if create_folder('/'+sd
+'/cavecraft/screenshots')=1 then debug('/screenshots created!');
1008 if file_exists('/'+sd
+'/cavecraft/texturepacks')<>1 then
1009 if create_folder('/'+sd
+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');
1011 rs
:=openRecordStore('TX');
1012 ss
:=readRecordStoreEntry(rs
,1);
1013 closeRecordStore(rs
);
1018 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1019 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1028 function question(text:string):boolean;
1030 ix
,iy
,m_cur
:integer;
1034 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=1; end;
1035 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>1 then m_cur
:=0; end;
1036 if clickedKey(KEY_MENU_SELECT
) then begin if m_cur
=0 then question
:=true; else question
:=false; exit
; end;
1037 for ix
:=0 to getwidth
/16 do for iy
:=0 to getheight
/16 do drawimage(bg
[0],ix
*16,iy
*16);
1038 drawfonttext(text,getwidth
/2-(length(text)*8)/2,getheight
/2-16);
1039 drw_btn('Yes',0,m_cur
,0,1);
1040 drw_btn('No',1,m_cur
,0,1);
1046 function menu_game_new
:boolean;
1048 m_cur
,tmp_gm
,ix
,iy
,lol
:integer;
1049 tmp_cheats
,tmp_bon_chest
:boolean;
1050 newgametxt
:array[0..4] of string;
1054 newgametxt
[0]:='Survival';
1055 newgametxt
[1]:='Creative';
1056 newgametxt
[2]:='Hardcore';
1057 newgametxt
[3]:='Normal';
1058 newgametxt
[4]:='Flat';
1062 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<-2 then m_cur
:=5; end;
1063 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>5 then m_cur
:=-2; end;
1064 if clickedKey(KEY_MENU_SELECT
) then
1068 name
:=gettext('Name:',name
,10,TF_ANY
);
1072 tmp_gm
:=tmp_gm
+1; if tmp_gm
>2 then tmp_gm
:=0;
1073 if tmp_gm
=0 then tmp_cheats
:=false;
1074 if tmp_gm
=1 then tmp_cheats
:=true;
1075 if tmp_gm
=2 then begin tmp_cheats
:=false; tmp_bon_chest
:=false; end;
1079 nextseed
:=stringtointeger(gettext('Seed:',''+nextseed
,10,TF_NUMERIC
));
1083 world_typ
:=world_typ
+1;
1084 if world_typ
>1 then world_typ
:=0;
1088 if tmp_gm
<2 then tmp_cheats
:= not tmp_cheats
;
1092 if tmp_gm
<2 then tmp_bon_chest
:= not tmp_bon_chest
;
1098 bon_chest
:=tmp_bon_chest
;
1100 while file_exists('/'+sd
+'/cavecraft/saves/'+name
)=1 do
1107 menu_game_new
:=true;
1115 for ix
:=0 to getWidth
/16 do
1116 for iy
:=0 to getHeight
/16 do
1117 drawimage(bg
[0],ix
*16,iy
*16);
1119 drw_btn('Name:'+name
,-2,m_cur
,0,1);
1120 drw_btn('Mode:'+newgametxt
[tmp_gm
],-1,m_cur
,0,1);
1121 drw_btn('Seed:'+nextseed
,0,m_cur
,0,1);
1122 drw_btn('Type:'+newgametxt
[world_typ
+3],1,m_cur
,0,1);
1124 drw_btn('Cheats:'+tmp_cheats
,2,m_cur
,0,1);
1126 drw_btn('Cheats:'+tmp_cheats
,2,m_cur
,0,0);
1128 drw_btn('Chest:'+tmp_bon_chest
,3,m_cur
,0,1);
1130 drw_btn('Chest:'+tmp_bon_chest
,3,m_cur
,0,0);
1131 drw_btn('Create',4,m_cur
,0,1);
1132 drw_btn('Cancel',5,m_cur
,0,1);
1139 procedure deleteworld(path
:string);
1141 if file_exists(path
+'player.dat')=1 then delete_file(path
+'player.dat');
1142 if file_exists(path
+'world.sav')=1 then delete_file(path
+'world.sav');
1143 if file_exists(path
+'nether.sav')=1 then delete_file(path
+'nether.sav');
1144 if file_exists(path
+'pic.png')=1 then delete_file(path
+'pic.png');
1145 if file_exists(path
)=1 then delete_file(path
);
1146 if file_exists(path
)=0 then debug('World deleted!');
1149 function menu_game
:boolean;
1151 ix
,iy
,pars
,max_r
,cur_name
,m_cur
:integer;
1155 names
:array[0..255] of string;
1157 rr
:=get_dirs('/'+sd
+'/cavecraft/saves/');
1158 while pos(rr
,'|')<>-1 do
1161 names
[max_r
]:=copy(rr
,0,pars
-1);
1162 rr
:=copy(rr
,pars
+1,length(rr
));
1163 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[max_r
]+'/player.dat')=1 then max_r
:=max_r
+1;
1166 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1167 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1168 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1170 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1171 mm_t_b
:=true; else mm_t_b
:=false;
1175 if clickedKey(KEY_MENU_UP
) then
1178 if m_cur
<0 then m_cur
:=3;
1180 if clickedKey(KEY_MENU_DOWN
) then
1183 if m_cur
>3 then m_cur
:=0;
1186 if (max_r
>= 0) and clickedKey(KEY_MENU_LEFT
) then
1188 cur_name
:=cur_name
-1;
1189 if cur_name
<0 then cur_name
:=0;
1190 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1191 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1192 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1194 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1196 if (max_r
>= 0) and clickedKey(KEY_MENU_RIGHT
) then
1198 cur_name
:=cur_name
+1;
1199 if cur_name
>max_r
then cur_name
:=max_r
;
1200 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1201 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1202 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1204 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/player.dat')=1 then
1206 if clickedKey(KEY_MENU_SELECT
) then
1211 if loadgame('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/') then
1213 sav_fl
:=names
[cur_name
];
1220 if menu_game_new
then begin menu_game
:=true; break
; end;
1224 debug('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/');
1226 if question('Are you sure?')=true then deleteworld('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/');
1229 rr
:=get_dirs('/'+sd
+'/cavecraft/saves/');
1230 while pos(rr
,'|')<>-1 do
1233 names
[max_r
]:=copy(rr
,0,pars
-1);
1234 rr
:=copy(rr
,pars
+1,length(rr
));
1238 if file_exists('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png')=1 then
1239 im_game
:=safely_load_image_fs('/'+sd
+'/cavecraft/saves/'+names
[cur_name
]+'/pic.png');
1240 else im_game
:=ld_tex('maps.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','');
1248 for ix
:=0 to getWidth
/16 do
1250 drawimage(bg
[1],ix
*16,iy
*16);
1251 for ix
:=0 to getWidth
/16 do
1252 drawimage(bg
[0],ix
*16,0);
1253 for ix
:=0 to getWidth
/16 do
1254 for iy
:=8 to getHeight
/16 do
1255 drawimage(bg
[0],ix
*16,iy
*16);
1260 fillrect(32,24,getWidth
-64,96);
1261 setclip(32,24,getWidth
-64,96);
1262 drawimage(im_game
,(getWidth
/2)-(32),32);
1263 drawfonttext(names
[cur_name
],(getWidth
/2)-(length(names
[cur_name
])*8/2),104);
1264 setclip(0,0,getWidth
,getHeight
);
1265 setcolor(128,128,128);
1266 drawrect(32,24,getWidth
-64,96);
1267 if cur_name
>0 then drawimage(gui
[20],0,58);
1268 if cur_name
<max_r
then drawimage(gui
[21],getWidth
-9,58);
1273 fillrect(32,24,getWidth
-64,96);
1274 setclip(32,24,getWidth
-64,96);
1275 drawfonttext('No saves!',(getWidth
/2)-(length('No saves!')*8/2),104);
1276 setclip(0,0,getWidth
,getHeight
);
1277 setcolor(128,128,128);
1278 drawrect(32,24,getWidth
-64,96);
1281 if mm_t_b
then drw_btn('Play',0,m_cur
,32,1); else drw_btn('Play',0,m_cur
,32,0);
1282 drw_btn('Create new',1,m_cur
,32,1);
1283 if mm_t_b
then drw_btn('Delete',2,m_cur
,32,1); else drw_btn('Delete',2,m_cur
,32,0);
1284 drw_btn('Back',3,m_cur
,32,1);
1285 if not mm_t_b
then cur_name
:=cur_name
+1;
1294 ix
,iy
,pars
,max_r
,cur_name
,m_cur
,t
:integer;
1297 names
:array[0..255] of string;
1300 rr
:=get_dirs('/'+sd
+'/cavecraft/texturepacks/');
1301 names
[0]:='Default';
1303 while pos(rr
,'|')<>-1 do
1306 names
[max_r
]:=copy(rr
,0,pars
-1);
1307 rr
:=copy(rr
,pars
+1,length(rr
));
1311 im_game
:=loadimage('/pack.png');
1315 if clickedKey(KEY_MENU_UP
) then
1318 if m_cur
<0 then m_cur
:=1;
1320 if clickedKey(KEY_MENU_DOWN
) then
1323 if m_cur
>1 then m_cur
:=0;
1326 if clickedKey(KEY_MENU_LEFT
) then
1328 cur_name
:=cur_name
-1;
1329 if cur_name
<0 then cur_name
:=0;
1330 im_game
:=ld_tex('pack.png','/'+sd
+'/cavecraft/texturepacks/'+names
[cur_name
]+'/','');
1332 if clickedKey(KEY_MENU_RIGHT
) then
1334 cur_name
:=cur_name
+1;
1335 if cur_name
>max_r
then cur_name
:=max_r
;
1336 im_game
:=ld_tex('pack.png','/'+sd
+'/cavecraft/texturepacks/'+names
[cur_name
]+'/','');
1338 if clickedKey(KEY_MENU_SELECT
) then
1340 if m_cur
=0 then begin
1343 debug("Select TexturePack @ /" + sd
+ "/cavecraft/texturepacks/" + names
[cur_name
]);
1344 tex_pack
:=names
[cur_name
];
1345 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1346 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1347 deleteRecordStore('TX');
1348 rs
:=openRecordStore('TX');
1349 t
:=addRecordStoreEntry(rs
,tex_pack
);
1350 closeRecordStore(rs
);
1352 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1353 loadtexture('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
1357 debug("Cancel Select TecturePack");
1360 deleteRecordStore('TX');
1361 rs
:=openRecordStore('TX');
1362 t
:=addRecordStoreEntry(rs
,'');
1363 closeRecordStore(rs
);
1366 if m_cur
=1 then break
;
1370 for ix
:=0 to getWidth
/16 do
1372 drawimage(bg
[1],ix
*16,iy
*16);
1373 for ix
:=0 to getWidth
/16 do
1374 drawimage(bg
[0],ix
*16,0);
1375 for ix
:=0 to getWidth
/16 do
1376 for iy
:=8 to getHeight
/16 do
1377 drawimage(bg
[0],ix
*16,iy
*16);
1382 fillrect(32,24,getWidth
-64,96);
1383 setclip(32,24,getWidth
-64,96);
1384 drawimage(im_game
,(getWidth
/2)-(32),32);
1385 drawfonttext(names
[cur_name
],(getWidth
/2)-(length(names
[cur_name
])*8/2),104);
1386 setclip(0,0,getWidth
,getHeight
);
1387 setcolor(128,128,128);
1388 drawrect(32,24,getWidth
-64,96);
1389 if cur_name
>0 then drawimage(gui
[20],0,58);
1390 if cur_name
<max_r
then drawimage(gui
[21],getWidth
-9,58);
1393 drw_btn('Done',0,m_cur
,32,1);
1394 drw_btn('Back',1,m_cur
,32,1);
1401 procedure menu_sett
;
1403 ix
,iy
,m_cur
:integer;
1408 if clickedKey(KEY_MENU_UP
) then
1411 if m_cur
<-3 then m_cur
:=5;
1413 if clickedKey(KEY_MENU_DOWN
) then
1416 if m_cur
>5 then m_cur
:=-3;
1418 if clickedKey(KEY_MENU_SELECT
) then
1422 light_type
:=light_type
+1;
1423 if light_type
>2 then light_type
:=0;
1431 Particles
.enabled
:= not Particles
.enabled
;
1435 drawgui
:=not drawgui
;
1439 if question('Are you sure?')=true then
1441 if load_key_tex
=0 then
1445 //load_virt_tex(ld_tex('touch.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'));
1448 if load_key_tex
=1 then
1451 resetVirtualKeyboard(-1);
1457 s_jpeg_quality
:=stringtointeger(gettext('JPEG quality:',''+s_jpeg_quality
,3,TF_NUMERIC
));
1458 if s_jpeg_quality
>100 then s_jpeg_quality
:=100; else
1459 if s_jpeg_quality
<0 then s_jpeg_quality
:=0;
1467 deleteRecordStore('S');
1468 deleteRecordStore('SD');
1469 deleteRecordStore('TX');
1479 for ix
:=0 to getWidth
/16 do
1480 for iy
:=0 to getHeight
/16 do
1481 drawimage(bg
[0],ix
*16,iy
*16);
1483 drw_btn('Light:'+light_type
,-3,m_cur
,0,1);
1484 drw_btn('Weather:'+ifosad
,-2,m_cur
,0,1);
1485 drw_btn('Particles:' + Particles
.enabled
, -1, m_cur
, 0, 1);
1486 drw_btn('Hide GUI:'+not drawgui
,0,m_cur
,0,1);
1487 drw_btn('Touch:'+(load_key_tex
>0),1,m_cur
,0,1);
1488 drw_btn('JPEG:'+s_jpeg_quality
,2,m_cur
,0,1);
1489 drw_btn('Set Root',3,m_cur
,0,1);
1490 drw_btn('Reset',4,m_cur
,0,1);
1491 drw_btn('Back',5,m_cur
,0,1);
1498 procedure menu_help
;
1504 if clickedKey(KEY_MENU_SELECT
) then break
;
1505 if pressedKey(KEY_MENU_UP
) then cur
:=cur
+1;
1506 if pressedKey(KEY_MENU_DOWN
) then cur
:=cur
-1;
1508 for ix
:=0 to getWidth
/16 do
1509 for iy
:=2 to (getHeight
/16)-2 do
1510 drawimage(bg
[1],ix
*16,iy
*16);
1512 for ix
:=0 to getWidth
/16 do
1514 drawimage(bg
[0],ix
*16,iy
*16);
1516 for ix
:=0 to getWidth
/16 do
1517 for iy
:=(getHeight
/16)-2 to getHeight
/16 do
1518 drawimage(bg
[0],ix
*16,iy
*16);
1520 setclip(0,32,getWidth
,(getHeight
/16-4)*16);
1522 drw_txt('Controls:',cur
,0,1);
1523 drw_txt('Left - Move left',cur
,1,0);
1524 drw_txt('Right - Move right',cur
,2,0);
1525 drw_txt('Up - Jump',cur
,3,0);
1526 drw_txt('Down - Put a block under you',cur
,4,0);
1527 drw_txt('1 - Inventory',cur
,5,0);
1528 drw_txt('Duble 1 - Craft',cur
,6,0);
1529 drw_txt('3 - Use block',cur
,7,0);
1530 drw_txt('7 - Debug info',cur
,8,0);
1531 drw_txt('Hold 7 - Console',cur
,9,0);
1532 drw_txt('9 - Pause',cur
,10,0);
1533 drw_txt('*, # - Browse inventory',cur
,11,0);
1534 drw_txt('0 - Edit mode',cur
,12,0);
1536 drw_txt('In inventory/chest:',cur
,14,1);
1537 drw_txt('3 - Enject object',cur
,15,0);
1538 drw_txt('Hold 3 - Enject stack',cur
,16,0);
1539 drw_txt('5 - Move the stack',cur
,17,0);
1540 drw_txt('Hold 5 - Divide stack',cur
,18,0);
1542 setclip(0,0,getWidth
,getHeight
);
1544 drw_btn('Back',0,0,getHeight
-getHeight
/2-16-6,1);
1551 procedure menu_about
;
1557 if clickedKey(KEY_MENU_SELECT
) then break
;
1558 if pressedKey(KEY_MENU_UP
) then cur
:=cur
+1;
1559 if pressedKey(KEY_MENU_DOWN
) then cur
:=cur
-1;
1561 for ix
:=0 to getWidth
/16 do
1562 for iy
:=2 to (getHeight
/16)-2 do
1563 drawimage(bg
[1],ix
*16,iy
*16);
1565 for ix
:=0 to getWidth
/16 do
1567 drawimage(bg
[0],ix
*16,iy
*16);
1569 for ix
:=0 to getWidth
/16 do
1570 for iy
:=(getHeight
/16)-2 to getHeight
/16 do
1571 drawimage(bg
[0],ix
*16,iy
*16);
1573 setclip(0,32,getWidth
,(getHeight
/16-4)*16);
1575 drw_txt('Developers:',cur
,0,1);
1576 drw_txt(#68+#101+#97+#68+#68+#111+#111+#77+#69+#82+' - Programmer',cur
,1,0);//dead
1577 drw_txt(#102+#114+#101+#100+#45+#98+#111+#121+' - Programmer',cur
,2,0);//fred-boy
1578 drw_txt(#65+#110+#100+#114+#101+#121+#53+#57+' - Programmer',cur
,3,0);//andrey59
1579 drw_txt(#89+#117+#82+#97+#78+#110+#78+#122+#90+#90+' - Artist',cur
,4,0);//yura
1580 drw_txt(#83+#97+#115+#104+#97+#71+' - Artist and idea generator',cur
,5,0);//sasha
1581 drw_txt(#66+#97+#74+#108+#101+#72+#84+#105+#72+' - Artist and tester',cur
,6,0);//valentin
1582 drw_txt(#65+#103+#114+#101+#115+#115+#111+#82+' - Tester',cur
,7,0);//agressor
1583 drw_txt(#118+#111+#108+#121+#97+#95+#110+#97+#115+#116+#97+#110+#101+' - Tester',cur
,8,0);//volya
1584 drw_txt(#97+#98+#97+#100+#111+#110+' - Tester',cur
,9,0);//abadon
1585 drw_txt(#77+#111+#110+#111+#103+#114+#111+#109+' - Tester',cur
,10,0);//monogrom
1586 drw_txt(#75+#97+#108+#116+#101+#114+' - Tester',cur
,11,0);//kalter
1588 drw_txt('Thanks:',cur
,12,1);
1589 drw_txt('Piligrim and 0vZ - Lib_jsr75i',cur
,13,0);
1590 drw_txt('Piligrim - Lib_effects',cur
,14,0);
1591 drw_txt('Kurdt - Lib_canvas',cur
,15,0);
1592 drw_txt('ViNT - Lib_png and Lib_bmp',cur
,16,0);
1593 drw_txt('aleshka - Lib_jpeg',cur
,17,0);
1594 drw_txt('Roman_V - Lib_safeload',cur
,18,0);
1596 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);
1597 drw_txt(#68+#101+#97+#68+#83+#111+#102+#116+#87+#97+#114+#101+' 2012-'+getyear(getcurrenttime
),cur
,22,0);
1599 drw_txt('Hello! :D',cur
,100,1);
1601 setclip(0,0,getWidth
,getHeight
);
1603 drw_btn('Back',0,0,getHeight
-getHeight
/2-16-6,1);
1610 function sm_siz
:integer;
1612 sm_siz
:=(getWidth
+getHeight
)/5;
1615 function sm_siz4
:integer;
1620 procedure draw_menu_back
;
1624 for ix
:=0 to getWidth
/16 do
1625 for iy
:=0 to getHeight
/16 do
1626 drawimage(bg
[0],ix
*16,iy
*16);
1631 m_cur
,ix
,iy
,iz
:integer;
1637 spl_y
,spl_del
:integer;
1640 cavelogo
:=ld_tex('cavelogo.png','/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/','title/');
1642 spl_y
:=getimageheight(cavelogo
);
1644 spl_del
:=getrelativetimems
;
1645 res
:=openResource('/title/splashes.txt');
1646 if ResourceAvailable(res
) then
1648 spl_i
:=stringtointeger(readline(res
));
1649 iy
:=random(spl_i
-1)+1;
1650 debug('SPLASH #'+iy
);
1652 splash
:=readline(res
);
1655 time
:=getcurrenttime
;
1656 if (getmonth(time
)=5) and (getday(time
)=7) then splash
:='Happy birthday, DeaDDooMER!';
1657 if ((getmonth(time
)=0) and (getday(time
)<3)) or ((getmonth(time
)=11) and (getday(time
)>29)) then splash
:='Happy New Year!';
1661 if clickedKey(KEY_MENU_UP
) then
1664 if m_cur
<0 then m_cur
:=5;
1666 if clickedKey(KEY_MENU_DOWN
) then
1669 if m_cur
>5 then m_cur
:=0;
1671 if clickedKey(KEY_MENU_SELECT
) then
1673 if m_cur
=0 then begin if menu_game
then break
; end;
1675 if m_cur
=1 then menu_tex
;
1677 if m_cur
=2 then menu_sett
;
1679 if m_cur
=3 then menu_help
;
1681 if m_cur
=4 then menu_about
;
1683 if m_cur
=5 then begin save_settings
; halt
; end;
1688 drawimage(cavelogo
,(getWidth
/2)-(getimagewidth(cavelogo
)/2),0);
1689 setcolor(255,255,0);
1691 DrawFontTextSpec(splash
, (getWidth
/2)-(length(splash
)*FONT_SYM_SIZE
/2), spl_y
, FONT_YELLOW_COLOR
, true);
1693 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;
1694 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;
1695 drawfonttext(version
,0,getHeight
-8);
1697 drw_btn('Singleplayer',0,m_cur
,0,1);
1698 drw_btn('Texture Packs',1,m_cur
,0,1);
1699 drw_btn('Options',2,m_cur
,0,1);
1700 drw_btn('Help',3,m_cur
,0,1);
1701 drw_btn('About',4,m_cur
,0,1);
1702 drw_btn('Quit Game',5,m_cur
,0,1);
1709 function setBlock(invcur
, x
, y
:integer):boolean;
1711 item
, sum
, block
, sblock
:integer;
1713 item
:=inv
.getItem(invcur
);
1714 sum
:=inv
.getSum(invcur
);
1715 block
:=getMap(x
, y
);
1716 sblock
:= Items
.GetData(item
);
1718 if (Items
.GetType(item
) = Items
.block
) and (Inv
.IsNull(invcur
) = false) then
1719 if Blocks
.IsOverlapped(block
) then
1720 // if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then
1722 if set_block_code(sblock
, x
, y
)=false then
1725 setmap(sblock
, x
, y
);
1728 inv
.setSum(inv
.getSum(invcur
)-1, invcur
);
1729 inv
.fixNull(invcur
);
1743 if (getrelativetimems
-fish_time
>5000) and (getmap(fx
,fy
)=50) then
1745 if (random(3)=2) and (getmap(fx
,fy
)=50) then
1747 drop
.create(210,1,x
,y
);
1750 inv
.setSum(inv
.getSum(invslot
)-1, invslot
);
1751 inv
.fixNull(invslot
);
1754 if (getrelativetimems
-fish_time
<5000) and (getmap(fx
,fy
)=50) and (fish
=true) then
1756 if getmap(fx
,fy
-1)=50 then fy
:=fy
-1;
1760 procedure drawminimap
;
1762 ix
,iy
,tmp_gx
,tmp_gy
,minx
,miny
,maxx
,maxy
,loc_camx
,loc_camy
,x
,y
:integer;
1766 if load_minimap_tex
then
1768 tmp_gx
:=(getWidth
/2)-(getimagewidth(gui
[16])/2);
1769 tmp_gy
:=(getHeight
/2)-(getimageheight(gui
[16])/2);
1773 tmp_gx
:=(getWidth
/2)-(64/2);
1774 tmp_gy
:=(getHeight
/2)-(64/2);
1777 loc_camx
:=(x
+4)-(864/2);
1778 loc_camy
:=(y
+4)-(864/2);
1779 if loc_camx
<0 then loc_camx
:=0;
1780 if loc_camx
>4096-864 then loc_camx
:=4096-864;
1781 if loc_camy
<0 then loc_camy
:=0;
1782 if loc_camy
>2048-864 then loc_camy
:=2048-864;
1785 maxx
:=(loc_camx
+864)/16;
1786 maxy
:=(loc_camy
+864)/16;
1787 if minx
<0 then minx
:=0;
1788 if miny
<0 then miny
:=0;
1789 if maxx
>255 then maxx
:=255;
1790 if maxy
>127 then maxy
:=127;
1792 if load_minimap_tex
then
1793 drawimage(gui
[16],tmp_gx
,tmp_gy
);
1796 setcolor(214,190,150);
1797 fillrect(tmp_gx
,tmp_gy
,64,64);
1800 for ix
:=minx
to maxx
do
1801 for iy
:=miny
to maxy
do
1803 if (getmap(ix
,iy
)=1) or (getmap(ix
,iy
)=2) or (getmap(ix
,iy
)=74) then setcolor(121,85,58); else
1804 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
1805 if (getmap(ix
,iy
)=50) or (getmap(ix
,iy
)=62) then setcolor(38,92,255); else
1806 if getmap(ix
,iy
)=51 then setcolor(255,0,0); else
1807 if (getmap(ix
,iy
)=61) or (getmap(ix
,iy
)=32) then setcolor(255,255,255); else
1808 setcolor(127,127,127);
1810 if (getmap(ix
,iy
)<>0) then plot(tmp_gx
+4+ix
-minx
,tmp_gy
+4+iy
-miny
);
1815 procedure draw_sign
;
1818 str
:array[0..3] of string;
1819 i
,j
,tmp_gx
,tmp_gy
:integer;
1821 if load_gui_tex
then
1823 tmp_gx
:=(getWidth
/2)-(getimagewidth(sign_im
)/2);
1824 tmp_gy
:=(getHeight
/2)-(getimageheight(sign_im
)/2);
1828 tmp_gx
:=(getWidth
/2)-(120/2);
1829 tmp_gy
:=(getHeight
/2)-(60/2);
1832 tmp
:=t_sign
[getmapinfo(curx
,cury
)];
1833 while pos(tmp
,#13)<>-1 do
1836 str
[j
]:=copy(tmp
,0,i
);
1837 tmp
:=copy(tmp
,i
+1,length(tmp
));
1841 if load_gui_tex
then
1842 drawimage(sign_im
,tmp_gx
,tmp_gy
);
1845 setcolor(159,132,77);
1846 fillrect(tmp_gx
,tmp_gy
,120,60);
1849 drawfonttext(str
[0],tmp_gx
+(120/2)-(length(str
[0])*8/2),tmp_gy
+(60/4/2)+4);
1850 drawfonttext(str
[1],tmp_gx
+(120/2)-(length(str
[1])*8/2),tmp_gy
+(60/4/2)+8+4);
1851 drawfonttext(str
[2],tmp_gx
+(120/2)-(length(str
[2])*8/2),tmp_gy
+(60/4/2)+16+4);
1852 drawfonttext(str
[3],tmp_gx
+(120/2)-(length(str
[3])*8/2),tmp_gy
+(60/4/2)+24+4);
1855 procedure draw_back(ix
,iy
:integer);
1857 if getBiomMap(ix
)=0 then
1859 if (getBackMap(ix
)=iy
) then drawimage(back
[0],(ix
*16)-camx
,(iy
*16)-camy
); else
1860 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1861 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1862 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1863 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1865 if getBiomMap(ix
)=1 then
1867 if (getBackMap(ix
)=iy
) then drawimage(back
[4],(ix
*16)-camx
,(iy
*16)-camy
); else
1868 if (getBackMap(ix
)+1=iy
) then drawimage(back
[4],(ix
*16)-camx
,(iy
*16)-camy
); else
1869 if (getBackMap(ix
)+2=iy
) then drawimage(back
[6],(ix
*16)-camx
,(iy
*16)-camy
); else
1870 if (getBackMap(ix
)+3=iy
) then drawimage(back
[6],(ix
*16)-camx
,(iy
*16)-camy
); else
1871 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1873 if getBiomMap(ix
)=2 then
1875 if (getBackMap(ix
)=iy
) then drawimage(back
[5],(ix
*16)-camx
,(iy
*16)-camy
); else
1876 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1877 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1878 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1879 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1881 if getBiomMap(ix
)=3 then
1883 if (getBackMap(ix
)=iy
) then drawimage(back
[7],(ix
*16)-camx
,(iy
*16)-camy
); else
1884 if (getBackMap(ix
)+1=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1885 if (getBackMap(ix
)+2=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1886 if (getBackMap(ix
)+3=iy
) then drawimage(back
[1],(ix
*16)-camx
,(iy
*16)-camy
); else
1887 if (getBackMap(ix
)<iy
) then drawimage(back
[2],(ix
*16)-camx
,(iy
*16)-camy
);
1889 if getBiomMap(ix
)=4 then
1891 drawimage(back
[8],(ix
*16)-camx
,(iy
*16)-camy
);
1897 ix
,iy
,iz
,minx
,miny
,maxx
,maxy
,tmp_ax
,tim
,smy
,pa_xo
, x
, y
:integer;
1901 {===================[sky]===================}
1902 tim
:=10000*getimagewidth(sky
)/600000*game_time
/10000;
1903 setcolor(effects
.get(sky
,tim
,0,1),effects
.get(sky
,tim
,0,2),effects
.get(sky
,tim
,0,3));
1904 fillrect(0,0,getWidth
,getHeight
);
1908 setcolor(effects
.get(sky
,tim
,2,1),effects
.get(sky
,tim
,2,2),effects
.get(sky
,tim
,2,3));
1909 smy
:=10000*getWidth
*2/600000*game_time
/10000;
1910 for iz
:=1 to getWidth
do
1912 ix
:=rnd(getWidth
*2)-getWidth
+smy
;
1913 if ix
>getWidth
then ix
:=ix
-getWidth
*2;
1915 if (ix
>-1) and (ix
<getWidth
) then plot(ix
,iy
);
1923 smy
:=10000*(getWidth
+getimagewidth(sun
))/300000*game_time
/10000;
1924 drawimage(sun
,smy
-getimagewidth(sun
),getHeight
/2-getimageheight(sun
)/2);
1928 setcolor(255,213,74);
1929 smy
:=10000*(getWidth
+sm_siz
)/300000*game_time
/10000;
1930 fillrect(smy
-sm_siz
+sm_siz4
,getHeight
/2-sm_siz
/2+sm_siz4
,sm_siz
-sm_siz4
,sm_siz
-sm_siz4
);
1935 smy
:=10000*(getWidth
+getimagewidth(moon
))/300000*(game_time
-300000)/10000;
1936 drawimage(moon
,smy
-getimagewidth(moon
),getHeight
/2-getimageheight(moon
)/2);
1940 setcolor(175,184,204);
1941 smy
:=10000*(getWidth
+sm_siz
)/300000*(game_time
-300000)/10000;
1942 fillrect(smy
-sm_siz
+sm_siz4
,getHeight
/2-sm_siz
/2+sm_siz4
,sm_siz
-sm_siz4
,sm_siz
-sm_siz4
);
1945 {===================[camera]===================}
1946 camx
:=(x
+4)-(getWidth
/2);
1947 camy
:=(y
+4)-(getHeight
/2);
1948 if camx
<0 then camx
:=0;
1949 if camx
>4096-getWidth
then camx
:=4096-getWidth
;
1950 if camy
>2048-getHeight
then camy
:=2048-getHeight
;
1951 {===================[max_draw]===================}
1954 maxx
:=(camx
+getWidth
)/16;
1955 maxy
:=(camy
+getHeight
)/16;
1956 if minx
<0 then minx
:=0;
1957 if miny
<0 then miny
:=0;
1958 if maxx
>255 then maxx
:=255;
1959 if maxy
>127 then maxy
:=127;
1960 {===================[draw_back]===================}
1961 for ix
:=minx
to maxx
do
1962 for iy
:=miny
to maxy
do
1964 if ifosad
and osadki
and (getBackMap(ix
) >= iy
) and Blocks
.IsTransporent(getmap(ix
, iy
)) then begin
1965 if getBiomMap(ix
) = 0 then drawimage(osad
[0, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1966 else if getBiomMap(ix
) = 2 then drawimage(osad
[1, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1967 else if getBiomMap(ix
) = 3 then drawimage(osad
[0, osadki_ani
], (ix
* 16) - camx
, (iy
* 16) - camy
)
1969 if drw_back
and Blocks
.IsTransporent(getmap(ix
, iy
)) then draw_back(ix
, iy
);
1970 if Blocks
.IsForeground(getmap(ix
,iy
)) = false then draw_block(ix
,iy
);
1972 {===================[drop]===================}
1973 Drop
.Draw(camx
, camy
);
1974 {===================[particles]===================}
1975 Particles
.Draw(camx
, camy
);
1976 {===================[player]===================}
1977 Player
.Draw(camx
, camy
);
1978 {===================[mobs]===================}
1979 Mobs
.Draw(camx
, camy
);
1980 {===================[draw_blocks]===================}
1981 for ix
:=minx
to maxx
do
1982 for iy
:=miny
to maxy
do
1984 if Blocks
.IsForeground(getmap(ix
, iy
)) then draw_block(ix
, iy
);
1987 if light_type
= 1 then
1989 if getmaplight(ix
,iy
) = 0 then
1990 fillrect((ix
* 16) - camx
, (iy
* 16) - camy
, 16, 16);
1992 else if light_type
= 2 then
1994 if getmaplight(ix
, iy
) < 15 then
1995 drawimage(light
[getmaplight(ix
, iy
)], (ix
* 16) - camx
, (iy
* 16) - camy
);
2000 // drawimage(light[getmaplight(player.getX div 16, player.getY div 16)], 0, 0);
2002 if (toolus
> 0) and (toolind
< 10) and (getmap(curx
,cury
) > 0) then
2006 drawimage(tue
[toolind
], curx
* 16 - camx
, cury
* 16 - camy
);
2008 {===================[gui]===================}
2011 tmp_ax
:=(getWidth
/2)-(getImageWidth(gui
[1])/2);
2014 drawimage(gui
[0],curx
*16-camx
,cury
*16-camy
);
2019 DrawPlayerInventory
;
2022 if keymode
=3 then drawcraft
; else
2023 if keymode
=4 then drawchest
; else
2024 if keymode
=5 then draw_sign
; else
2025 if keymode
=6 then drawfurnace
; else
2026 if ifminimap
then drawminimap
;*/
2028 drawimage(gui
[1],tmp_ax
,0);
2031 Items
.Draw(inv
.getItem(ix
), inv
.getSum(ix
), (ix
*16)+tmp_ax
+ix
*2+4, 1, true);
2033 drawimage(gui
[17],(invslot
*16)+tmp_ax
+invslot
*2+2,0);
2039 for ix
:=0 to (hp
div 2)-1 do drawimage(gui
[13],ix
*9,getHeight
-9);
2040 if (hp
mod 2)<>0 then begin drawimage(gui
[14],ix
*9,getHeight
-9); ix
:=ix
+1 end;
2041 for ix
:=ix
to 9 do drawimage(gui
[15],ix
*9,getHeight
-9);
2045 for ix
:=0 to (hp
div 2)-1 do drawimage(gui
[31],ix
*9,getHeight
-9);
2046 if (hp
mod 2)<>0 then begin drawimage(gui
[32],ix
*9,getHeight
-9); ix
:=ix
+1 end;
2047 for ix
:=ix
to 9 do drawimage(gui
[33],ix
*9,getHeight
-9);
2050 for ix
:=0 to (hunger
div 2)-1 do drawimage(gui
[26],ix
*9,getHeight
-18);
2051 if (hunger
mod 2)<>0 then begin drawimage(gui
[27],ix
*9,getHeight
-18); ix
:=ix
+1 end;
2052 for ix
:=ix
to 9 do drawimage(gui
[28],ix
*9,getHeight
-18);
2054 if getmap((x
+4)/16,y
/16)=50 then
2056 for ix
:=0 to (air
div 2)-1 do drawimage(gui
[29],ix
*9,getHeight
-27);
2057 if (air
mod 2)<>0 then begin drawimage(gui
[30],ix
*9,getHeight
-27); ix
:=ix
+1 end;
2063 drawfonttext(msg
[ix
],0,getHeight
-20-ix
*9);
2064 if getrelativetimems
-msg_time
[ix
]>5000 then msg
[ix
]:='';
2069 procedure load_moon(path
:string;phase
:integer);
2076 moon
:=ld_tex('moon_phase_'+phase
+'.png',path
,'terrain/moon_phases/');
2080 moon
:=resize_image(ld_tex('moon_phase_'+phase
+'.png',path
,'terrain/moon_phases/'),(getWidth
+getHeight
)/5,(getWidth
+getHeight
)/5);
2088 if game_time
>300000 then
2090 if load_light_tex
then
2096 for iy
:=0 to getheight
/16 do
2097 for ix
:=0 to getwidth
/16 do
2098 drawimage(light
[i
],ix
*16,iy
*16);
2103 moon_phase
:=moon_phase
+1;
2104 if moon_phase
>7 then moon_phase
:=0;
2105 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2108 last_sleep_y
:=cury
-1;
2113 for iy
:=0 to getheight
/16 do
2114 for ix
:=0 to getwidth
/16 do
2115 drawimage(light
[i
],ix
*16,iy
*16);
2125 while i
<=getheight
do
2128 fillrect(0,0,getwidth
,i
);
2133 moon_phase
:=moon_phase
+1;
2134 if moon_phase
>7 then moon_phase
:=0;
2135 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2138 last_sleep_y
:=cury
-1;
2140 while i
<=getheight
do
2144 fillrect(0,i
,getwidth
,getheight
);
2150 end; else create_msg('You can sleep only at night');
2153 procedure resetToolProgerss
;
2159 procedure usetools(invcur
, x
, y
:integer);
2161 item
, sum
, block
:integer;
2163 block
:=getmap(x
, y
);
2164 item
:=inv
.getItem(invcur
);
2165 sum
:=inv
.getSum(invcur
);
2168 destroy_block_cr(block
, x
, y
);
2172 if (Items
.GetType(item
) = Items
.tool
) and (getBlockTool(block
)=getToolType(item
)) then
2173 toolus
:=toolus
+getToolSpeed(item
);
2177 if toolus
>=getBlockHP(block
) then
2179 if ((Items
.GetType(item
) = Items
.tool
) and (getBlockTool(block
)=getToolType(item
)) and (getToolLvl(item
)>=getBlockLvl(block
))) or (getBlockLvl(block
)<=0) then
2182 destroy_block_1(block
, x
, y
);
2183 setMapInfo(0, x
, y
);
2188 destroy_block_0(block
, x
, y
);
2189 setMapInfo(0, x
, y
);
2192 if Items
.GetType(item
) = Items
.tool
then
2194 inv
.setSum(inv
.getSum(invcur
)-1, invcur
);
2195 inv
.fixNull(invcur
);
2203 if (toolus
>0) and (toolus
<=getBlockHP(block
)) then
2204 toolind
:=((toolus
*100) div getBlockHP(block
)) div 10;
2207 function rt_useweap
:boolean;
2209 x
, y
, w
, h
, i
, damg
:integer;
2216 item
:=inv
.getItem(invslot
);
2218 if Items
.GetType(item
) = Items
.tool
then
2219 damg
:=getToolDamg(item
);
2224 i
:=Mobs
.findAndHit(damg
, x
-TILE_SIZE
, y
, TILE_SIZE
+(w
/2), h
, -2, -3);
2226 i
:=Mobs
.findAndHit(damg
, x
+(w
/2), y
, TILE_SIZE
+(w
/2), h
, 2, -3);
2230 inv
.setSum(inv
.getSum(invslot
)-1, invslot
);
2231 inv
.fixNull(invslot
);
2236 procedure rt_usetools
;
2243 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2245 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2247 if curx
<0 then curx
:=0;
2248 if curx
>255 then curx
:=255;
2249 if cury
<0 then cury
:=0;
2250 if cury
>127 then cury
:=127;
2252 usetools(invslot
, curx
, cury
);
2255 procedure rt_usemob
;
2262 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2264 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2266 if curx
<0 then curx
:=0;
2267 if curx
>255 then curx
:=255;
2268 if cury
<0 then cury
:=0;
2269 if cury
>127 then cury
:=127;
2271 //usemob(curx,cury);
2274 procedure actionUse(invcur
, x
, y
:integer);
2276 if setBlock(invcur
, x
, y
)=false then
2277 if useBlock(invcur
, x
, y
) then
2278 if useItem(invcur
, x
, y
) then
2281 procedure rt_useblock
;
2288 if posi
=0 then curx
:=(x
div 16)-1; else curx
:=(x
div 16)+1;
2290 if getmap(curx
,cury
)=0 then cury
:=cury
+1;
2292 if curx
<0 then curx
:=0;
2293 if curx
>255 then curx
:=255;
2294 if cury
<0 then cury
:=0;
2295 if cury
>127 then cury
:=127;
2297 actionUse(invslot
, curx
, cury
);
2300 procedure go_to_nether
;
2304 portal_time
:=getrelativetimems
;
2305 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2307 drw_load_line('Matrix',10);
2308 if loadworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/')=true then
2310 player
.setX(get_spawn_x
*16+4);
2311 player
.setY((get_up(get_spawn_x
)-1)*16);
2324 mob[ix].m_min_vely:=0;
2327 mob[ix].m_fall:=false;
2328 mob[ix].m_jmp:=false;
2329 mob[ix].m_velani:=false;
2338 procedure go_to_world
;
2340 portal_time
:=getrelativetimems
;
2341 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2343 drw_load_line('Matrix',10);
2344 if loadworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/')=true then
2357 procedure plr_is_dead_hardcore
;
2365 if clickedKey(KEY_MENU_SELECT
) then
2367 deleteworld('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2372 drawfonttext('You died!',getwidth
/2-32,getheight
/2-16);
2374 drw_btn('Delete world',0,0,0,1);
2382 procedure plr_is_dead
;
2394 if clickedKey(KEY_MENU_UP
) then
2397 if m_cur
<0 then m_cur
:=1;
2399 if clickedKey(KEY_MENU_DOWN
) then
2402 if m_cur
>1 then m_cur
:=0;
2404 if clickedKey(KEY_MENU_SELECT
) then
2410 if last_sleep_x
=0 then
2412 x
:=get_spawn_x
*16+4;
2416 x
:=last_sleep_x
*16+4;
2423 if last_sleep_x
=0 then
2425 x
:=get_spawn_x
*16+4;
2429 x
:=last_sleep_x
*16+4;
2445 if m_cur
=1 then begin menu
; exit
; end;
2450 drawfonttext('You died!',getwidth
/2-32,getheight
/2-16);
2452 drw_btn('Respawn',0,m_cur
,0,1);
2453 drw_btn('Main menu',1,m_cur
,0,1);
2460 procedure fast_menu
;
2466 if clickedKey(KEY_MENU_UP
) then begin m_cur
:=m_cur
-1; if m_cur
<0 then m_cur
:=3; end;
2467 if clickedKey(KEY_MENU_DOWN
) then begin m_cur
:=m_cur
+1; if m_cur
>3 then m_cur
:=0; end;
2468 if clickedKey(KEY_MENU_SELECT
) then
2476 savegame('/'+sd
+'/cavecraft/saves/'+sav_fl
+'/');
2485 //clear_gui(keymode);
2491 drawfonttext('Game menu',getwidth
/2-36,getheight
/2-20);
2492 drw_btn('Back to Game',0,m_cur
,0,1);
2493 drw_btn('Save Game',1,m_cur
,0,1);
2494 drw_btn('Options',2,m_cur
,0,1);
2495 drw_btn('Quit to Title',3,m_cur
,0,1);
2502 procedure keyFastInv
;
2504 if clickedKey(KEY_FASTINV_NEXT
) then
2511 if clickedKey(KEY_FASTINV_PREV
) then
2519 procedure keyConsole
;
2521 if clickedKey(KEY_CHAT
) then
2522 SetTimer(1000,T_CONSOLE
);
2524 if pressedKey(KEY_CHAT
) then
2526 if GetTimer(T_CONSOLE
)=TIMER_OK
then
2529 ResetTimer(T_CONSOLE
);
2534 if GetTimer(T_CONSOLE
)>TIMER_OK
then
2537 ResetTimer(T_CONSOLE
);
2542 procedure keyInventory
;
2544 if clickedKey(KEY_PLR_OPENINV
) then
2546 OpenPlayerInventory
;
2551 procedure keyhandler
;
2555 if WindowKeyHanler
then
2563 if clickedKey(KEY_PLR_EDITMODE
) then
2566 curx
:=player
.getX
div 16;
2567 cury
:=player
.getY
div 16;
2570 if clickedKey(KEY_PLR_USE
) then
2573 if clickedKey(KEY_MENU
) then
2576 if clickedKey(KEY_PLR_ATTACK
) then
2577 if rt_useweap
=false then
2580 if pressedKey(KEY_PLR_ATTACK
) then
2583 playAnim(ANIM_HAND
);
2588 cancelAnim(ANIM_HAND
);
2591 if pressedKey(KEY_PLR_UP
) then
2593 if pressedKey(KEY_PLR_DOWN
) then
2595 if pressedKey(KEY_PLR_LEFT
) then
2597 if pressedKey(KEY_PLR_RIGHT
) then
2607 if clickedKey(KEY_PLR_UP
) then
2613 if clickedKey(KEY_PLR_DOWN
) then
2619 if clickedKey(KEY_PLR_LEFT
) then
2625 if clickedKey(KEY_PLR_RIGHT
) then
2632 if clickedKey(KEY_PLR_EDITMODE
) then
2635 if clickedKey(KEY_PLR_USE
) then
2636 actionUse(invslot
, curx
, cury
);
2638 if pressedKey(KEY_PLR_ATTACK
) then
2640 usetools(invslot
, curx
, cury
);
2641 playAnim(ANIM_HAND
);
2646 cancelAnim(ANIM_HAND
);
2649 if clickedKey(KEY_MENU
) then
2657 procedure phyhandler
;
2666 procedure light_fillrect(l
,x
,y
,r
:integer);
2668 ix
,iy
,ym
,yp
,xm
,xp
:integer;
2676 setmaplight(getmaplight(ix
,iy
)+l
,ix
,iy
);
2679 procedure light_rect(l
,x
,y
,r
:integer);
2681 ix
,iy
,ym
,yp
,xm
,xp
:integer;
2689 setmaplight(getmaplight(ix
,ym
)+l
,ix
,ym
);
2690 setmaplight(getmaplight(ix
,yp
)+l
,ix
,yp
);
2692 for iy
:=ym
+1 to yp
-1 do
2694 setmaplight(getmaplight(xm
,iy
)+l
,xm
,iy
);
2695 setmaplight(getmaplight(xp
,iy
)+l
,xp
,iy
);
2699 procedure calc_light(m
,x
,y
:integer);
2701 ix
,iy
,l
,ss
,sf
:integer;
2703 if light_type
=1 then light_fillrect(m
,x
,y
,m
/2); else
2704 for l
:=m
downto 1 do
2706 if ss
mod 2=0 then light_rect(l
,x
,y
,ss
/2);
2711 procedure calc_sun(ix
,m
:integer);
2718 setmaplight(ss
,ix
,iy
);
2720 ss
:=ss
-getBlockTr(getmap(ix
,iy
));
2723 for iy
:=iy
+1 to 127 do
2725 setmaplight(0,ix
,iy
);
2734 for i
:=0 to INV_SIZE
do
2736 if inv
.isNull(i
)=false then
2737 player
.dropItem(inv
.getItem(i
), inv
.getSum(i
));
2741 if gamemode
<2 then plr_is_dead
; else plr_is_dead_hardcore
;
2744 procedure hunger_and_air
;
2752 if getrelativetimems
-hung_time
>=90000/(gamemode
+1) then
2754 hung_time
:=getrelativetimems
;
2757 if getrelativetimems
-hp_time
>=5000*(gamemode
+1) then
2761 hp_time
:=getrelativetimems
;
2763 if hp
>20 then hp
:=20;
2767 hp_time
:=getrelativetimems
;
2769 if hp
<1 then if gamemode
<2 then hp
:=1;
2773 if getmap((x
+4)/16,y
/16)=50 then
2775 if getrelativetimems
-air_time
>=500 then
2778 air_time
:=getrelativetimems
;
2781 hp_time
:=getrelativetimems
;
2792 ix
,iy
,minx
,maxx
,miny
,maxy
,fps_t
,tim
, x
, y
:integer;
2799 if hunger
<0 then hunger
:=0;
2800 if air
<0 then air
:=0;
2803 if fps_t
<1 then fps_t
:=1;
2806 if bl_ani5_v
=false then
2812 bl_ani5_v
:=not bl_ani5_v
;
2821 bl_ani5_v
:=not bl_ani5_v
;
2824 bl_ani5_d
:=not bl_ani5_d
;
2829 game_time
:=game_time
+(600000 div (fps_t
*1000));
2831 // Ускорение игрового времени в 10 раз
2832 // game_time := game_time + (600000 div (fps_t*100));
2834 if (game_time
>600000) or (game_time
<0) then
2837 moon_phase
:=moon_phase
+1;
2838 if moon_phase
>7 then moon_phase
:=0;
2839 load_moon('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/',moon_phase
);
2842 tim
:= 10000 * getimagewidth(sky
) / 600000 * game_time
/ 10000;
2843 global_light
:= effects
.get(sky
, tim
, 1, 1) div 16;
2845 if clock_stage
<>game_time
div 75000 then begin clock_stage
:=clock_stage
+1; if clock_stage
>7 then clock_stage
:=0; end;
2848 if x
+8>4094 then x
:=4086;
2849 if getBlockColl(getmap(x
div 16, y
div 16))>0 then hp
:=hp
-1;
2850 if random(4096)=random(4096) then begin osadki
:=not osadki
; end;
2851 osadki_ani
:=osadki_ani
+1;
2852 if osadki_ani
>7 then osadki_ani
:=0;
2854 if Random(20) = Random(20) then Particles
.Create(Particles
.bubble
, x
, y
);
2856 if gamemode
=1 then begin hp
:=666; hunger
:=666; end;
2858 if inv
.getItem(invslot
)=186 then
2863 //if s_spawn_mob then if random(4096)=1547 then megaspawn;
2868 if light_type
>0 then
2871 maxx
:=(camx
+getWidth
)/16+1;
2872 if minx
<0 then minx
:=0;
2873 if maxx
>255 then maxx
:=255;
2874 for ix
:=minx
to maxx
do calc_sun(ix
,global_light
);
2878 maxx
:=(camx
+getWidth
)/16+16;
2880 maxy
:=(camy
+getHeight
)/16+16;
2881 if minx
<0 then minx
:=0;
2882 if maxx
>255 then maxx
:=255;
2883 if miny
<0 then miny
:=0;
2884 if maxy
>127 then maxy
:=127;
2885 for ix
:=minx
to maxx
do
2886 for iy
:=miny
to maxy
do
2888 if light_type
=0 then setmaplight(15,ix
,iy
);
2890 if light_type
>0 then if getBlockLi(getmap(ix
,iy
))>0 then calc_light(getBlockLi(getmap(ix
,iy
)),ix
,iy
);
2893 minx
:=(camx
/16)-((getwidth
/2)/16);
2894 miny
:=(camy
/16)-((getheight
/2)/16);
2895 maxx
:=(camx
+(getWidth
+getWidth
/2))/16;
2896 maxy
:=(camy
+(getHeight
+getHeight
/2))/16;
2897 if minx
<0 then minx
:=0;
2898 if miny
<0 then miny
:=0;
2899 if maxx
>255 then maxx
:=255;
2900 if maxy
>127 then maxy
:=127;
2901 if updx
<minx
then updx
:=minx
;
2902 if updy
<miny
then updy
:=miny
;
2903 if updx
>maxx
then updx
:=minx
;
2904 if updy
>maxy
then updy
:=miny
;
2908 for ix
:=0 to (((2*getWidth
/16)*(2*getHeight
/16))-1) div ((fps_t
*bl_upd
)) do
2910 updateBlock(updx
, updy
);
2916 if updy
>maxy
then updy
:=miny
;
2921 {if coll_bl(110)=true then
2923 if getrelativetimems-portal_time>5000 then
2925 if pl_world=0 then begin go_to_nether; portal_time:=getrelativetimems; end; else
2926 if pl_world=1 then begin go_to_world; portal_time:=getrelativetimems; end;
2930 if coll_bl(51)=true then hp:=hp-1;
2932 if coll_bl(59)=true then
2934 if vely<0 then vely:=-1;
2936 if vely>0 then vely:=1;
2941 if hp
>20 then hp
:=20;
2942 if hunger
>20 then hunger
:=20;
2945 if y
>2048 then kill_plr
;
2946 if (hp
<1) and (gamemode
<>1) then kill_plr
;
2947 if fish
=true then fishing
;
2949 if (fish
=true) and (inv
.getItem(invslot
)<>152) then fish
:=false;
2951 //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;
2955 if cury
<(y
div 16)-4 then cury
:=(y
div 16)-4;
2956 if cury
>(y
div 16)+5 then cury
:=(y
div 16)+5;
2957 if curx
<(x
div 16)-4 then curx
:=(x
div 16)-4;
2958 if curx
>(x
div 16)+4 then curx
:=(x
div 16)+4;
2969 LoadDrawFont('/'+sd
+'/cavecraft/texturepacks/'+tex_pack
+'/');
2972 if load_key_tex
=1 then init_touch
;
2976 msg_time
[i
]:=getrelativetimems
;
2978 InitMap(MAP_W
, MAP_H
);
2982 procedure draw_debug
;
2986 //drawfonttext('X:'+(x div 16-128),0,0);
2987 //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8);
2988 drawfonttext('CURX:'+(curx
-128),0,16);
2989 drawfonttext('CURY:'+cury
,0,24);
2990 drawfonttext('UPDX:'+updx
,0,32);
2991 drawfonttext('UPDY:'+updy
,0,40);
2992 drawfonttext('FPS:'+fps
,0,56);
2993 drawfonttext('Free RAM:'+free_ram
/1024+' KB',0,64);
2994 drawfonttext('Total RAM:'+memory
.get_totalmemory
div 1024+' KB',0,72);
2995 drawfonttext('SEED:'+seed
,0,88);
2996 drawfonttext('Game time:'+game_time
,0,96);
2997 drawfonttext('Global light:' + global_light
, 0, 104);
3000 drawImage(light
[i
], getWidth
- 16, 16 * i
);
3003 function ItemToString(id
: integer) : string;
3007 if id
= Items
.none
then name
:= 'none'
3008 else if id
= Items
.dirt
then name
:= 'dirt'
3009 else if id
= Items
.grass
then name
:= 'grass'
3010 else if id
= Items
.stone
then name
:= 'stone'
3011 else if id
= Items
.oakWoodPlanks
then name
:= 'oakWoodPlanks'
3012 else if id
= Items
.cobblestone
then name
:= 'cobblestone'
3013 else if id
= Items
.bedrock
then name
:= 'bedrock'
3014 else if id
= Items
.sand
then name
:= 'sand'
3015 else if id
= Items
.gravel
then name
:= 'gravel'
3016 else if id
= Items
.oakWood
then name
:= 'oakWood'
3017 else if id
= Items
.obsidian
then name
:= 'obsidian'
3018 else if id
= Items
.bookshelf
then name
:= 'bookshelf'
3019 else if id
= Items
.mossStone
then name
:= 'mossStone'
3020 else if id
= Items
.blockOfIron
then name
:= 'blockOfIron'
3021 else if id
= Items
.blockOfGold
then name
:= 'blockOfGold'
3022 else if id
= Items
.blockOfDiamond
then name
:= 'blockOfDiamond'
3023 else if id
= Items
.goldOre
then name
:= 'goldOre'
3024 else if id
= Items
.ironOre
then name
:= 'ironOre'
3025 else if id
= Items
.coalOre
then name
:= 'coalOre'
3026 else if id
= Items
.diamondOre
then name
:= 'diamondOre'
3027 else if id
= Items
.redstoneOre
then name
:= 'redstoneOre'
3028 else if id
= Items
.oakLeaves
then name
:= 'oakLeaves'
3029 else if id
= Items
.redFlower
then name
:= 'redFlower'
3030 else if id
= Items
.yellowFlower
then name
:= 'yellowFlower'
3031 else if id
= Items
.redMooshroom
then name
:= 'redMooshroom'
3032 else if id
= Items
.brownMooshroom
then name
:= 'brownMooshroom'
3033 else if id
= Items
.torch
then name
:= 'torch'
3034 else if id
= Items
.tnt
then name
:= 'tnt'
3035 else if id
= Items
.chest
then name
:= 'chest'
3036 else if id
= Items
.craftingTable
then name
:= 'craftingTable'
3037 else if id
= Items
.cactus
then name
:= 'cactus'
3038 else if id
= Items
.glass
then name
:= 'glass'
3039 else if id
= Items
.wool1
then name
:= 'wool1'
3040 else if id
= Items
.wool2
then name
:= 'wool2'
3041 else if id
= Items
.wool3
then name
:= 'wool3'
3042 else if id
= Items
.wool4
then name
:= 'wool4'
3043 else if id
= Items
.wool5
then name
:= 'wool5'
3044 else if id
= Items
.wool6
then name
:= 'wool6'
3045 else if id
= Items
.wool7
then name
:= 'wool7'
3046 else if id
= Items
.wool8
then name
:= 'wool8'
3047 else if id
= Items
.wool9
then name
:= 'wool9'
3048 else if id
= Items
.wool10
then name
:= 'wool10'
3049 else if id
= Items
.wool11
then name
:= 'wool11'
3050 else if id
= Items
.wool12
then name
:= 'wool12'
3051 else if id
= Items
.wool13
then name
:= 'wool13'
3052 else if id
= Items
.wool14
then name
:= 'wool14'
3053 else if id
= Items
.wool15
then name
:= 'wool15'
3054 else if id
= Items
.wool16
then name
:= 'wool16'
3055 else if id
= Items
.snow
then name
:= 'snow'
3056 else if id
= Items
.ladder
then name
:= 'ladder'
3057 else if id
= Items
.water
then name
:= 'water'
3058 else if id
= Items
.lava
then name
:= 'lava'
3059 else if id
= Items
.oakSapling
then name
:= 'oakSapling'
3060 else if id
= Items
.sponge
then name
:= 'sponge'
3061 else if id
= Items
.lapisLazuliOre
then name
:= 'lapisLazuliOre'
3062 else if id
= Items
.lapisLazuliBlock
then name
:= 'lapisLazuliBlock'
3063 else if id
= Items
.sandstone
then name
:= 'sandstone'
3064 else if id
= Items
.tallGrass
then name
:= 'tallGrass'
3065 else if id
= Items
.deadBush
then name
:= 'deadBush'
3066 else if id
= Items
.cobweb
then name
:= 'cobweb'
3067 else if id
= Items
.bricks
then name
:= 'bricks'
3068 else if id
= Items
.snowBlock
then name
:= 'snowBlock'
3069 else if id
= Items
.ice
then name
:= 'ice'
3070 else if id
= Items
.snowLayer
then name
:= 'snowLayer'
3071 else if id
= Items
.clayBlock
then name
:= 'clayBlock'
3072 else if id
= Items
.sugarCane
then name
:= 'sugarCane'
3073 else if id
= Items
.pumpkin
then name
:= 'pumpkin'
3074 else if id
= Items
.jackLantern
then name
:= 'jackLantern'
3075 else if id
= Items
.stoneBricks
then name
:= 'stoneBricks'
3076 else if id
= Items
.mossyStoneBricks
then name
:= 'mossyStoneBricks'
3077 else if id
= Items
.crackedStoneBricks
then name
:= 'crackedStoneBricks'
3078 else if id
= Items
.chiseledStokeBricks
then name
:= 'chiseledStokeBricks'
3079 else if id
= Items
.ironBras
then name
:= 'ironBras'
3080 else if id
= Items
.melonBlock
then name
:= 'melonBlock'
3081 else if id
= Items
.mycelium
then name
:= 'mycelium'
3082 else if id
= Items
.backgroundOakWood
then name
:= 'backgroundOakWood'
3083 else if id
= Items
.spawner
then name
:= 'spawner'
3084 else if id
= Items
.bed1
then name
:= 'bed1'
3085 else if id
= Items
.bed2
then name
:= 'bed2'
3086 else if id
= Items
.openWoodenDoor1
then name
:= 'openWoodenDoor1'
3087 else if id
= Items
.openWoodenDoor2
then name
:= 'openWoodenDoor2'
3088 else if id
= Items
.closedWoodenDoor1
then name
:= 'closedWoodenDoor1'
3089 else if id
= Items
.closedWoodenDoor2
then name
:= 'closedWoodenDoor2'
3090 else if id
= Items
.birchWood
then name
:= 'birchWood'
3091 else if id
= Items
.backgroundBirchWood
then name
:= 'backgroundBirchWood'
3092 else if id
= Items
.spruceWood
then name
:= 'spruceWood'
3093 else if id
= Items
.backgroundSpruceWood
then name
:= 'backgroundSpruceWood'
3094 else if id
= Items
.spruceLeaves
then name
:= 'spruceLeaves'
3095 else if id
= Items
.redMushroomBlock1
then name
:= 'redMushroomBlock1'
3096 else if id
= Items
.redMushroomBlock2
then name
:= 'redMushroomBlock2'
3097 else if id
= Items
.brownMushroomBlock1
then name
:= 'brownMushroomBlock1'
3098 else if id
= Items
.brownMushroomBlock2
then name
:= 'brownMushroomBlock2'
3099 else if id
= Items
.oakFence
then name
:= 'oakFence'
3100 else if id
= Items
.backgroundOakFence
then name
:= 'backgroundOakFence'
3101 else if id
= Items
.backgroundOakWoodPlanks
then name
:= 'backgroundOakWoodPlanks'
3102 else if id
= Items
.painting1
then name
:= 'painting1'
3103 else if id
= Items
.painting2
then name
:= 'painting2'
3104 else if id
= Items
.painting3
then name
:= 'painting3'
3105 else if id
= Items
.painting4
then name
:= 'painting4'
3106 else if id
= Items
.painting5
then name
:= 'painting5'
3107 else if id
= Items
.painting6
then name
:= 'painting6'
3108 else if id
= Items
.painting7
then name
:= 'painting7'
3109 else if id
= Items
.reservedBlockItem1
then name
:= 'reservedBlockItem1'
3110 else if id
= Items
.vines
then name
:= 'vines'
3111 else if id
= Items
.sign
then name
:= 'sign'
3112 else if id
= Items
.redstoneTorch
then name
:= 'redstoneTorch'
3113 else if id
= Items
.furnace
then name
:= 'furnace'
3114 else if id
= Items
.closedWoodenTrapdoor
then name
:= 'closedWoodenTrapdoor'
3115 else if id
= Items
.openWoodenTrapdoor
then name
:= 'openWoodenTrapdoor'
3116 else if id
= Items
.netherrack
then name
:= 'netherrack'
3117 else if id
= Items
.netherPortal
then name
:= 'netherPortal'
3118 else if id
= Items
.glowstone
then name
:= 'glowstone'
3119 else if id
= Items
.birchLeaves
then name
:= 'birchLeaves'
3120 else if id
= Items
.soulSand
then name
:= 'soulSand'
3121 else if id
= Items
.birchSapling
then name
:= 'birchSapling'
3122 else if id
= Items
.spruceSapling
then name
:= 'spruceSapling'
3123 else if id
= Items
.redstoneLampOff
then name
:= 'redstoneLampOff'
3124 else if id
= Items
.redstoneLampOn
then name
:= 'redstoneLampOn'
3125 else if id
= Items
.backgroundObsidian
then name
:= 'backgroundObsidian'
3126 else if id
= Items
.glassPlane
then name
:= 'glassPlane'
3127 else if id
= Items
.farmland
then name
:= 'farmland'
3128 else if id
= Items
.cake
then name
:= 'cake'
3129 else if id
= Items
.reservedBlockItem2
then name
:= 'reservedBlockItem2'
3130 else if id
= Items
.reservedBlockItem3
then name
:= 'reservedBlockItem3'
3131 else if id
= Items
.reservedBlockItem4
then name
:= 'reservedBlockItem4'
3132 else if id
= Items
.reservedBlockItem5
then name
:= 'reservedBlockItem5'
3133 else if id
= Items
.reservedBlockItem6
then name
:= 'reservedBlockItem6'
3134 else if id
= Items
.stick
then name
:= 'stick'
3135 else if id
= Items
.dandelionYellow
then name
:= 'dandelionYellow'
3136 else if id
= Items
.roseRed
then name
:= 'roseRed'
3137 else if id
= Items
.superSpecialUnneededTool
then name
:= 'superSpecialUnneededTool'
3138 else if id
= Items
.pickaxe1
then name
:= 'pickaxe1'
3139 else if id
= Items
.pickaxe2
then name
:= 'pickaxe2'
3140 else if id
= Items
.pickaxe3
then name
:= 'pickaxe3'
3141 else if id
= Items
.pickaxe4
then name
:= 'pickaxe4'
3142 else if id
= Items
.pickaxe5
then name
:= 'pickaxe5'
3143 else if id
= Items
.shovel1
then name
:= 'shovel1'
3144 else if id
= Items
.shovel2
then name
:= 'shovel2'
3145 else if id
= Items
.shovel3
then name
:= 'shovel3'
3146 else if id
= Items
.shovel4
then name
:= 'shovel4'
3147 else if id
= Items
.shovel5
then name
:= 'shovel5'
3148 else if id
= Items
.axe1
then name
:= 'axe1'
3149 else if id
= Items
.axe2
then name
:= 'axe2'
3150 else if id
= Items
.axe3
then name
:= 'axe3'
3151 else if id
= Items
.axe4
then name
:= 'axe4'
3152 else if id
= Items
.axe5
then name
:= 'axe5'
3153 else if id
= Items
.shears
then name
:= 'shears'
3154 else if id
= Items
.sword1
then name
:= 'sword1'
3155 else if id
= Items
.sword2
then name
:= 'sword2'
3156 else if id
= Items
.sword3
then name
:= 'sword3'
3157 else if id
= Items
.sword4
then name
:= 'sword4'
3158 else if id
= Items
.sword5
then name
:= 'sword5'
3159 else if id
= Items
.fishingRod
then name
:= 'fishingRod'
3160 else if id
= Items
.lighter
then name
:= 'lighter'
3161 else if id
= Items
.hoe1
then name
:= 'hoe1'
3162 else if id
= Items
.hoe2
then name
:= 'hoe2'
3163 else if id
= Items
.hoe3
then name
:= 'hoe3'
3164 else if id
= Items
.hoe4
then name
:= 'hoe4'
3165 else if id
= Items
.hoe5
then name
:= 'hoe5'
3166 else if id
= Items
.reservedToolItem
then name
:= 'reservedToolItem'
3167 else if id
= Items
.coal
then name
:= 'coal'
3168 else if id
= Items
.redstone
then name
:= 'redstone'
3169 else if id
= Items
.diamond
then name
:= 'diamond'
3170 else if id
= Items
.brick
then name
:= 'brick'
3171 else if id
= Items
.ironIngot
then name
:= 'ironIngot'
3172 else if id
= Items
.goldIngot
then name
:= 'goldIngot'
3173 else if id
= Items
.lapisLazuli
then name
:= 'lapisLazuli'
3174 else if id
= Items
.strand
then name
:= 'strand'
3175 else if id
= Items
.snowball
then name
:= 'snowball'
3176 else if id
= Items
.clay
then name
:= 'clay'
3177 else if id
= Items
.book
then name
:= 'book'
3178 else if id
= Items
.bucket
then name
:= 'bucket'
3179 else if id
= Items
.waterBucket
then name
:= 'waterBucket'
3180 else if id
= Items
.lavaBucket
then name
:= 'lavaBucket'
3181 else if id
= Items
.milkBucket
then name
:= 'milkBucket'
3182 else if id
= Items
.paper
then name
:= 'paper'
3183 else if id
= Items
.melon
then name
:= 'melon'
3184 else if id
= Items
.egg
then name
:= 'egg'
3185 else if id
= Items
.door
then name
:= 'door'
3186 else if id
= Items
.bed
then name
:= 'bed'
3187 else if id
= Items
.spawnEggZombie
then name
:= 'spawnEggZombie'
3188 else if id
= Items
.spawnEggSheep
then name
:= 'spawnEggSheep'
3189 else if id
= Items
.spawnEggPig
then name
:= 'spawnEggPig'
3190 else if id
= Items
.gunpowder
then name
:= 'gunpowder'
3191 else if id
= Items
.bowl
then name
:= 'bowl'
3192 else if id
= Items
.mushroomStew
then name
:= 'mushroomStew'
3193 else if id
= Items
.map
then name
:= 'map'
3194 else if id
= Items
.painting
then name
:= 'painting'
3195 else if id
= Items
.rawPorkchop
then name
:= 'rawPorkchop'
3196 else if id
= Items
.cookedPorkchop
then name
:= 'cookedPorkchop'
3197 else if id
= Items
.rottenFlesh
then name
:= 'rottenFlesh'
3198 else if id
= Items
.camera1
then name
:= 'camera1'
3199 else if id
= Items
.camera2
then name
:= 'camera2'
3200 else if id
= Items
.camera3
then name
:= 'camera3'
3201 else if id
= Items
.goldNugget
then name
:= 'goldNugget'
3202 else if id
= Items
.sugar
then name
:= 'sugar'
3203 else if id
= Items
.spiderEye
then name
:= 'spiderEye'
3204 else if id
= Items
.feather
then name
:= 'feather'
3205 else if id
= Items
.leather
then name
:= 'leather'
3206 else if id
= Items
.rawBeef
then name
:= 'rawBeef'
3207 else if id
= Items
.steak
then name
:= 'steak'
3208 else if id
= Items
.apple
then name
:= 'apple'
3209 else if id
= Items
.goldenApple
then name
:= 'goldenApple'
3210 else if id
= Items
.rawChicken
then name
:= 'rawChicken'
3211 else if id
= Items
.cookedChicken
then name
:= 'cookedChicken'
3212 else if id
= Items
.spawnEggChicken
then name
:= 'spawnEggChicken'
3213 else if id
= Items
.spawnEggCreeper
then name
:= 'spawnEggCreeper'
3214 else if id
= Items
.flint
then name
:= 'flint'
3215 else if id
= Items
.spawnEggCow
then name
:= 'spawnEggCow'
3216 else if id
= Items
.spawnEggMooshroom
then name
:= 'spawnEggMooshroom'
3217 else if id
= Items
.rawFish
then name
:= 'rawFish'
3218 else if id
= Items
.cookedFish
then name
:= 'cookedFish'
3219 else if id
= Items
.spawnEggPigman
then name
:= 'spawnEggPigman'
3220 else if id
= Items
.spawnEggSpider
then name
:= 'spawnEggSpider'
3221 else if id
= Items
.glowstoneDust
then name
:= 'glowstoneDust'
3222 else if id
= Items
.clock
then name
:= 'clock'
3223 else if id
= Items
.compass
then name
:= 'compass'
3224 else if id
= Items
.seeds
then name
:= 'seeds'
3225 else if id
= Items
.wheat
then name
:= 'wheat'
3226 else if id
= Items
.bread
then name
:= 'bread'
3227 else if id
= Items
.boneMeal
then name
:= 'boneMeal'
3228 else if id
= Items
.melonSeeds
then name
:= 'melonSeeds'
3229 else if id
= Items
.pumpkinSeeds
then name
:= 'pumpkinSeeds'
3230 else name
:= '' + id
;
3234 procedure PrintItem(id
, typ
, tex
, max
, info
, texsource
, indicator
: integer; dividable
: boolean);
3236 name
, tname
, indname
: string;
3238 name
:= ItemToString(id
);
3240 if typ
= Items
.block
then tname
:= 'block'
3241 else if typ
= Items
.tool
then tname
:= 'tool'
3242 else if typ
= Items
.reserved
then tname
:= 'reserved'
3243 else if typ
= Items
.orditem
then tname
:= 'orditem'
3244 else tname
:= '' + typ
;
3246 if indicator
= Items
.noindicator
then indname
:= 'noindicator'
3247 else if indicator
= Items
.numeric
then indname
:= 'numeric'
3248 else if indicator
= Items
.line
then indname
:= 'line'
3249 else indname
:= '' + indicator
;
3251 Debug(' InitItem(' + name
+ ', ' + tname
+ ', ' + tex
+ ', ' + max
+ ', ' + info
+ ', ' + texsource
+ ', ' + indname
+ ', ' + dividable
+ ');');
3254 procedure PrintItemTable
;
3258 for id
:= 0 to 222 do begin
3262 Items
.GetTexture(id
),
3263 Items
.GetMaximum(id
),
3265 Items
.GetTextureSource(id
),
3266 Items
.GetIndicatorType(id
),
3267 Items
.IsDividable(id
)
3271 for id
:= 0 to 194 do begin
3272 Debug(' InitOrdItem(' + ItemToString(Items
.GetOrdinary(id
)) + ');');
3278 hung_time
:=getrelativetimems
;
3279 hp_time
:=getrelativetimems
;
3280 air_time
:=getrelativetimems
;
3281 portal_time
:=getrelativetimems
;
3291 drawfonttext(version
,getWidth
-(length(version
)*8),getHeight
-8);
3292 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;