-- Bloxorz by Purobaz -- 48h CPC #4 -- Planete-Casio.fr -- Thanks to Vebveb for LuaFX -- useful functions local prt=graydraw.text local sub=string.sub local tonb=base.tonumber local tostr=misc.tostring2 local wait=misc.wait -- variables local level=1 local loop,choice local nb local i,j,k -- map local map local map_info={} -- width, height, x, y local map_end={} -- block local block={} -- x, y, position (1~3) local block_move={ -- depend on keys { {0,-1,1}, {2,0,3}, {0,1,1}, {-1,0,3} }, { {0,-2,3}, {1,0,2}, {0,1,3}, {-1,0,2} }, { {0,-1,2}, {1,0,1}, {0,2,2}, {-2,0,1} } } local block_pst={ {1,0}, {0,-1}, {0,0} } local block_size={ {0,-6}, {-3,-6}, {0,-8} } -- sprites local sprite_map={ " .>€ÿ€¾€€]E:((", " .>€ÿ€þ€€}E:8(", " .>€ÿ€¿€€]A>((", " .>€ÿ€ÿ€€}A>8 " } local sprite_block={ "@@@à  °P@x¸ \ èjØuPXרë \ ¨®XõPEXݨº€\"°ªpÝUÀÝÀª k_<,", " 6:*ëÕU€õ€ª€*Àº@Õ@U`Ý ª *°®PÕxWèj \ ¨+Ø5Pب ¨\ Ø\ @ð°ÀÀ€€", " 6:*kUU€Õ€ª*€ª€Õ€×€ë\ €®€õE€Ý€º\"€ª€ÝU€Ý€ª\"€ª€ÝU€Ý€ª\"€ª€Ý_k,<" } --functions function load_map() if level==1 then map="111114352333350511111233" map_info={8,3,25,30} block={1,2,3} elseif level==2 then map="111114511455555555435335555404114555233112333" map_info={9,5,25,30} block={6,1,1} elseif level==3 then map="111111111143555455111111145533404533333333311233311111111111" map_info={15,4,25,42} block={12,2,2} elseif level==4 then map="1145511455435334043123311" map_info={5,5,25,30} block={5,2,3} elseif level==5 then map="45555433334111141111411112553512504112333" map_info={5,8,25,30} block={5,2,2} elseif level==6 then map="1455514043143311411123333" map_info={5,5,25,30} block={5,5,3} elseif level==7 then map="455111111145555511112555555551123335535511111250431111112331" map_info={10,6,25,30} block={2,2,3} elseif level==8 then map="111111455335511455511455114511455533333114555455511111114504233311111112555111111111111233" map_info={15,6,25,40} block={2,3,3} elseif level==9 then map="1411111114111111455114554553350423311233" map_info={8,5,25,30} block={2,1,3} end end function draw_map() for j=1,map_info[2],1 do for i=1,map_info[1],1 do nb=tonb(sub(map,((j-1)*map_info[1]+i),((j-1)*map_info[1]+i))) if nb==0 then map_end={i,j} elseif nb>1 then spritexy map_info[3]+4*i+4*j,map_info[4]+4*j-3*i,sprite_map[nb-1] refresh wait(1) end end end end function intro() local stage="?ÁÁã?ã?Á?Á?888888 À?Ààà/\ à ààà€ `@@   @@?@ >€Àüü?þ?þ?ü?ü8p8p8p8p8p8p?p?p?p?p?p?p@p80( ( PPP( (` 0P8p8p  þÁþÁÿãÿãþãþã€ã€ã€ã€ã€ã€ã€ã€ãŸãŸã¿ã¿ãŸáŸã€ŽâáaŽâ¨£® VCÔC@ê£øüAððøøðð€€ÀÀ€�€�\ \ \ €°p\ PP¨àð" local number={ "\ ÀÀà?à?à?à?à8à8à8à8à8à8à8à8à8à8à8à8àà8(à(ààà(€:à\ `5@=@ >€À", "\ €€ÀÀÀÀÀÀÀÀÀÀÀ À ÀÀÀÀÀÀ€€@@@€€€@ÀÀ€€", "\ ÀÀà?à?à?à?à8à8à8à8ààààààÀÀ€€\ €:à\ `5P=P >  À", "\ ÀÀà?à?àààààààààààààààààààà€à\ `@=@ >€À", "\ €€€€<<€;€;à?à? à/ààà €€€€€", "\ ÀÀà?à?À?À?888888À?À?à?à?àààààààà€à\ `@=@ >€À", "\ ÀÀà?à?À?À?888888À?À?à?à?à?à?àà8(à(ààà(€:à\ `5@=@ >€À", "\ ÀÀà?à?ààÀÀÀÀÀÀ€€€€€€\  ", "\ ÀÀà?à?à?à?à8à8à8à8à8à8à?à?à?à?à?à?àà8(à(ààà(€:à\ `5@=@ >€À", "\ ÀÀà?à?à?à?à8à8à8à8à8à8à?à?à?à?àààààààà€à\ `@=@ >€À" } clear nil spritexy 14, 20, stage spritexy 87, 20, number[int(level/10)+1] spritexy 100, 20, number[int(level%10)+1] refresh wait(30) end function menu() local menu="?l \ ðøø?¸:ð?88888(888888p8øø8à;ð?À@€?à;ð?øø888p888888(8888¸:ð?ðà?€\ À8888888888888888888888€:À?Àà?€\ À€*ÀÀàÿàêàÿ@@àààààà@@àààààà@@àààààà@@àààààà@@àààààà@@àààààà@@àààêàÿÀàÿ€*Àçççç$$àààà````ààÁÁÀÀ������������‰‰ùùøøœœ˜˜˜˜˜˜øøøø˜˜˜˜œœœœ@@@@àààààà@@ààÀqÀqÀq@Q€ €;€;€;€;€;€;Àq@Q€ ÀqÀq@@àààààà@@àà@@ðøðøøùøù˜É˜É˜Á˜ÁøÁøÁøÁøÁ˜Á˜Á˜Á˜Á˜Á˜ÁœãœãxðxðüøüøÌ˜Ì˜Ì˜Ì˜ü˜ü˜ü˜ü˜Ì˜Ì˜Ì˜Ì˜ÌøÌøÎñÎñà}à}ÀüÀüÀÄÀÄÀÀÀÀÀðÀðÀðÀðÀÀÀÀÄÄÄÄüüüüü|ü|€*ÀÀàÿàêàÿ@@àààààà@@àààààà@@àààààà@@àààààà@@àààààà@@àààààà@@àààêàÿÀàÿ€*Àÿxÿxÿüÿü™Ì™ÌÌÌüüøøØØØØÌÌ<î<î||~~ffffffffffff~~||xxüüÌÌÌÌüüøøÀÀÀÀÀÀàà€*ÀÀàÿàêàÿ@@àààààà@@ààààààÀAààÀëÀÿ€ÿëÿA€ã€ã€ãÀA@€àÀáÀá@@àààààà@`àà@@€*€À@€ÿÀ+À€€€888pppP €ÿ€\ õÀ@€ÿ€€*U" local cursor=" \ 00ÀÀððÀÀ00" clear nil spritexy 10, 2, menu state(false) choice=0 i=1 repeat clear nil state(true) spritexy 33, 13+13*i, cursor refresh repeat wait(5) until key(5) or key(39) or key(38) or key(36) or key(44) if key(39) and i>1 then i=i-1 elseif key(38) and i<3 then i=i+1 elseif key(5) then choice=i elseif key(36) or key(44) then choice=4 end until choice~=0 -- end of the menu end -- game function game() repeat intro() load_map() clear nil draw_map() state(false) loop=0 repeat clear nil state(true) spritexy map_info[3]+4*block[1]+4*block[2]+block_size[block[3]][1],map_info[4]+4*block[2]-3*block[1]+block_size[block[3]][2],sprite_block[block[3]] refresh repeat wait(5) until key(39) or key(40) or key(38) or key(37) or key(36) or key(44) or key(1) if key(1) then level=level+1 loop=1 elseif key(36) or key(44) then -- exit or menu loop=3 else if key(39) then k=1 elseif key(40) then k=2 elseif key(38) then k=3 elseif key(37) then k=4 end block={block[1]+block_move[block[3]][k][1],block[2]+block_move[block[3]][k][2],block_move[block[3]][k][3]} -- move the block if block[1]==map_end[1] and block[2]==map_end[2] and block[3]==3 then -- winner level=level+1 loop=1 if level>9 then loop=3 end elseif ((block[2]-1)*map_info[1]+block[1])>=1 and ((block[2]-1)*map_info[1]+block[1])<=#map -- looser and ((block[2]-1+block_pst[block[3]][2])*map_info[1]+block[1]+block_pst[block[3]][1])>=1 and ((block[2]-1+block_pst[block[3]][2])*map_info[1]+block[1]+block_pst[block[3]][1])<=#map then if tonb(sub(map,((block[2]-1)*map_info[1]+block[1]),((block[2]-1)*map_info[1]+block[1])))==1 or tonb(sub(map,((block[2]+block_pst[block[3]][2]-1)*map_info[1]+block[1]+block_pst[block[3]][1]),((block[2]+block_pst[block[3]][2]-1)*map_info[1]+block[1]+block_pst[block[3]][1])))==1 then loop=2 end else loop=2 end end until loop~=0 -- end of the stage clear nil state(true) spritexy map_info[3]+4*block[1]+4*block[2]+block_size[block[3]][1],map_info[4]+4*block[2]-3*block[1]+block_size[block[3]][2],sprite_block[block[3]] refresh wait(10) until loop==3 -- end of the game end -- main graydraw.setcolor(true) repeat menu() wait(5) if choice==1 then level=1 game() --elseif choice==2 then --elseif choice==3 then end until choice==4 graydraw.setcolor(false)