'user's function that actually draw cells of the world '(in) l,t = left and top position in world-cell-coords '(in) (w,h) = with and height dimension in world-cell-coords 'it will ask to draw horizontal or vertical lines from the world sub inf_world(l,t,w,h) if w=0 or h=0 then exit sub bg 3 pal 0 'drawing an horizontal line if w>h then world_y=t for i=0 to w-1 world_x=l+i randomize world_x*21 + world_y*17 gosub inf_world_draw next i exit sub 'drawing a vertical line else world_x=l for i=0 to h-1 world_y=t+i randomize world_x*21 + world_y*17 gosub inf_world_draw next i exit sub end if inf_world_draw: world_tile=rnd(15) meta_x=(world_tile mod 2)*8 meta_y=(world_tile\2)*8 bg copy meta_x,meta_y,8,8 to world_x*8,world_y*8 return end sub 'user's function to scroll the background sub inf_scroll(x,y) scroll 3,x,y end sub 'rectangle of the whole world map 'a.k.a.: world boundaries in world-cell-coords infl=0 inft=0 infr=63 infb=63 'camera dimension, a.k.a.: view dimension in pixel-coords 'camera view start of the top-left corner of the device, if you want to change it, do it yourself. infw=shown.w infh=shown.h 'world cell size in pixel-coord, a.k.a.: pixel to cell conversion 'use single size cell infs=64 'number of cells to draw out of the view to make then already drawn when the camera is panned. 'note if the number is too big it can lead to overwrite wrapped cells the are visible. 'max value=7 with infs=8 infco=3 'compute space occupied by the whole world in pixel-coords infpw=(infr-infl+1)*infs infph=(infb-inft+1)*infs 'camera position in the world in pixel-coords 'initial position point to the center of the world infx=-(infw-infpw)/2 infy=-(infh-infph)/2 gosub inf_prepare 'rectangle of what portion of the world is drawn 'a.k.a.: view drawing cursor in world-cell-coords 'initial rectangel start from the center of the view infcl=(infpl+infpr)\2 infct=(infpt+infpb)\2 infcr=infcl-1 infcb=infct-1 'need recompute position infnl=-1 do if touch and touch.change and not touch.drag and not touch.long then 'save original pan position of the world infxs=infx infys=infy else if touch.drag then 'pan the camera view onto the world infx=infxs-(touch.x-touch.px) infy=infys-(touch.y-touch.py) infnl=-1 end if if infnl then gosub inf_position gosub inf_draw 'if you want to draw faster ' gosub inf_draw ' gosub inf_draw bg 0 pal 1 number 3,3,infpl,4 number 3,4,infpt,4 number 3,5,infpr,4 number 3,6,infpb,4 wait vbl loop 'make sure the camera position allow to see the world and some of the out-of-bound characters around it. inf_position: infnl=0 'in x axis if infpw>infw then 'world is bigger than the view l=infl*infs r=(infr+1)*infs-infw 'prevent to past beyond if infxr then infx=r else 'world is small than the view, center it infx=-(infw-infpw)/2 end if 'in y axis if infph>infh then 'world is bigger than the view t=inft*infs b=(infb+1)*infs-infh if infyb then infy=b else 'world is small than the view, center it infy=-(infh-infph)/2 end if call inf_scroll(infx,infy) goto inf_prepare inf_prepare: 'rectangle of the view, the portion of the visible world 'a.k.a.: view position in world-cell-coords infpl=int(infx/infs)-infco infpt=int(infy/infs)-infco infpr=int((infx+infw)/infs)+infco infpb=int((infy+infh)/infs)+infco return inf_draw: 'render missing world cells at left if infplinfl then dec infcl if infcr-infcl>=64 then dec infcr call inf_world(infcl,infct,1,infcb-infct+1) end if 'render missing cells at right if infpr>infcr and infcr=64 then inc infcl call inf_world(infcr,infct,1,infcb-infct+1) end if 'render missing cells at top if infptinft then dec infct if infcb-infct>=64 then dec infcb call inf_world(infcl,infct,infcr-infcl+1,1) end if 'render missing cells at bottom if infpb>infcb and infcb=64 then inc infct call inf_world(infcl,infcb,infcr-infcl+1,1) end if return #1:MAIN PALETTES 040A0908000202000000000000000000 00000000000000000000000000000000 #2:DEFAULT CHARACTERS 00000000000000000000000000000000 FFFFFFFFFFFFFFFF0000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000003070F1F180000000304081017 000007FFFBFBFB3B000007FC040404E4 0000E0FFDFDFDFDF0000E03F20202020 000003FFFDFDFDFD000003FE02020202 0000E0FFDFDFDFD80000E03F20202027 000000C020908868000000C0E07078F8 1F1F1F1F1F1F1F181010101010101017 888888888888886878787878787878F8 00000000000000070000000000000007 00000000000000E000000000000000E0 18171F3F3834232717181020272B3C3B 68D8C8C42434FCFCF838383CFCDC3CDC 000003070D0D0D09000003060E0A0A0E 1817E8F7CFCFC0C71718F73830303F38 088807EFF1F121D1F878FF1E0E0EFE3E 0000C0FFB0B0B0B00000C07F50505050 171F3F38372F2F2F1810202728303030 D7CCC464148F8C8C3C3F3FFFFF7F7C7C E02020203FE000003FFFFFFFFFE00000 03020202FE030000FEFFFFFFFF030000 EF3F3F3837EF2F2F38F0E0E7E8F03030 D8C8C464148C8C8C38383CFCFC7C7C7C 171F3F38372F2F2F1810202728303030 D8C8C464148C8C8C38383CFCFC7C7C7C 0F1F3F38372F2F2F0810202728303030 D0C8C464148C8C8C30383CFCFC7C7C7C 36160B07000000002B1B0C0700000000 3438F0E000000000DCD830E000000000 0F0A0A0E060300000A0F0F0F07030000 DF3F38372FEF2F1F30E0E7E8F0F03010 CBC666168E8F8C883E3FFFFF7F7F7C78 F77040407FC0000048FFFFFFFFC00000 1F1F1F1F1F1F1713101010101010181C 88888BCFFDFDFDFD78787B3E02020202 1F1FFFFFDFDFDFDE1010F03020202021 8888888888880808787878787878F8F8 1F1F1F1F1F1F1F1F1010101010101010 88888888888888887878787878787878 0000E0FFCFCFC0C70000E03F30303F38 000003FFF1F121D1000003FE0E0EFE3E 1817E8F7CFCFCFCC1718F73830303033 088807EFF1F1F131F878FF1E0E0E0ECE 181738372F3F38371718272830202728 088807EFF1F121D1F878FF1E0E0EFE3E 1817E8F7CFCFC0C71718F73830303F38 088804ECF4F424D4F878FC1C0C0CFC3C 000000FFFFFFFFFF000000FF00000000 00000000000000000000000000000000 08080403000000000F0F070300000000 03020202FE030000FEFFFFFFFF030000 E02020203FE000003FFFFFFFFFE00000 101020C000000000F0F0E0C000000000 000000000F0F0205000000000F000F0F 00000000F0F0F0F000000000F000F0F0 DF3F38372FEF2F1F30E0E7E8F0F03010 CBC666168E8F8C883E3FFFFF7F7F7C78 E02020203FE000003FFFFFFFFFE00000 03020202FE030000FEFFFFFFFF030000 2F3F38372F2F2F1F3020272830303010 CBC666168E8F8C883E3FFFFF7F7F7C78 DF3F38372FEF2F1F30E0E7E8F0F03010 CCC464148C8C8C883C3CFCFC7C7C7C78 00000000FF000000FFFFFFFFFF000000 #3:BACKGROUND 000010401D001E0012003E003E003E00 3E0013001D001E001400150000000000 100011002D002E0022004E004E004E00 4E0023002D002E002400250000000000 20002100340035000000000000000000 000000001A001B003400350000000000 34003500340035000000000000000000 000000002A002B003400350000000000 34003500340035000000000000000000 00000000000000003400350000000000 34003500340035000000000000000000 00000000000000003400350000000000 34003500340035000000000000000000 00000000100011003800390012001300 32003300340035000000000000000000 00000000200021004800490022002300 420043001D001E001200130014001500 100011001D001E0012003E0013001200 3E0013002D002E002200230024002500 200021002D002E0022004E0023002200 4E002300300031001400150030003100 32003300340035000000000000000000 00000000400041002400250040004100 420043001A001B000000000000000000 00000000000000003000310012001300 140015002A002B000000000000000000 00000000000000004000410022002300 24002500180019000000000000000000 000000001000110012003E003E001300 32003300280029000000000000000000 000000002000210022004E004E002300 42004300340035000000000000000000 000000001D001E001200130036003700 120013001D001E001C08000000000000 100011002D002E002200230046004700 220023002D002E002C08000000000000 200021003A003B00120013003C003D00 000000001A001B000000000000000000 340035004A004B00220023004C004D00 000000002A002B000000000000000000 340035003A003B00120013003C003D00 000000000000000000001C0012001300 3C003D004A004B00220023004C004D00 000000000000000000002C0022002300 4C004D003A003B001200130032003300 000000001000110012003E003E001300 320033004A004B002200230042004300 000000002000210022004E004E002300 420043001D001E0012003E003E003E00 3E0013001D001E001200130014001500 1C0013002D002E0022004E004E004E00 4E0023002D002E002200230024002500 2C002300300031003600370014001500 00000000160017000000000016001700 00000000400041002D002E0024002500 00000000260027000000000026002700 00000000000000003000310038003900 14001500160017000000000016001700 00000000000000004000410048004900 24002500260027000000000026002700 000000001000110012003E003E001300 3200330016001700000000001A001B00 000000002000210022004E004E002300 4200430026002700000000002A002B00 000000001D003D001C0012003E003E00 3E0013001D001E001C08100011001200 3E0013002D004D002C0022004E004E00 4E0023002D002E002C08200021002200 4E002300340035000000000000000000 000000001A001B001C00320033000000 000000003000310012003E0013001400 150000002A002B002C00420043000000 000000004000410022004E0023002400 25000000100011001C08000000000000 000000001000110012003E0013003200 33000000200021002C08000000000000 000000002000210022004E0023004200 43000000340035000000000000000000 00000000340035000000000000000000 00000000340035000000000000000000 000000001D001E0012003E003E003E00 3E0013001D001E0012003E003E003E00 3E0013002D002E0022004E004E004E00 4E0023002D002E0022004E004E004E00 4E002300340035000000000000000000 00000000340035001000110014001500 00000000340035000000100011001400 15000000340035002000210024002500 00000000340035000000200021002400 250000003A003B003C003D003A003B00 13001C08340035000000300031003200 330000004A004B004C004D004A004B00 23002C08340035000000400041004200 43000000340035003000310032003300 00000000340035000000000000000000 00000000340035004000410042004300 000000001D001E001400150010001100 120013001D001E003600370036003700 360037002D002E002400250020002100 220023002D002E004600470046004700 46004700300031003200330034003500 000000003A003B003200330016001700 16001700400041004200430034003500 000000004A004B004200430026002700 26002700100011001200130032003300 000000003A003B001200130032003300 16001700200021002200230042004300 000000004A004B002200230042004300 26002700340035000000000000000000 000000003A003B0012003E003E001300 32003300340035000000000000000000 000000004A004B0022004E004E002300 42004300320033000000000000000000 10001100320033000000000000000000 00001C00420043000000000000000000 20002100420043000000000000000000 00002C00000000000000000000000000 34003500000000000000000000000000 00000000000000000000000000000000 34003500000000000000000000000000 00000000000000000000000000000000 34003500000000000000000000000000 00000000000000000000000000000000 34003500000000000000000000000000 000000001000110012003E003E001300 32003300180019000000000000000000 000000002000210022004E004E002300 42004300280029000000000000000000 00000000