"24#3"C4D#2C34"2"C#""C#""C#""24"ޝޙݞٞޙޝ=33>33>3333=ffffVUUeVUUeVUUeVUUeVUUeVUUeffffDDDDDDDDLLLLLLLL""C33#2DD4"33C#""24""24""24"""C#"""""33#223#2#3#232#23##233"""""""!!"!"!"!!"!""!""""!ޝީݞٞީޝ=C4>DD>DDC4=~~nm^]"24#3"C4D#2C34"2"C#""C#""C#""24"""""""""ݙ3333DDDDDDDD3333ffffUUUUUUUUffff"C3"#2D34"3DC#"324""24""24"""C#"!!!!!!!!ީީީީީީީC4C4C4C4C4C4C4C4VeVeVeVeVeVeVeVe        { """"""""""! """"""""!A  "B""","""!! """"$"""!! Z YZ @DD@DD@DD@DD@DD@DDDD@DD@L@A@!@!@$BDD@@L@DDAD A "A BD@DD@@DD@D@!@"@D$DD ""," ," ," ," ," DDLD LD LD LD LD      ))))))'''     HG   ((( HG    HGH ''' H H         ****** I JJ*** JIH  I *** J JJJJ J IH J I JJ******JJ J JIH JJJJJ ***J J*********JJJJJ 55567:????????????????????????q (/PUZ_ 00000???p?p?p0p0p0p0p0p?p?p?????????????0p0p0p0p0p?????00000???????????????     000000000000000000000013579;=?q049? $)/  01356775302@2P1`1`2`2p3p4p5p6p7p8p9p:`:`;P<@<0= >?u00000000000000000000000000000?u 5556?555??????????????????????q  0000000000  {SD4 ffffVUUeVUUeVUUeVUUe VUUe VUUe ffff DDLD N ."YZM"""$ݞDD"""ޚND!ݞN! !ޚN" -ڭND$ ڭDD  <-- title: Color Critters -- author: Altrix Studios -- desc: Guide the critters through 15 puzzling levels! -- script: lua red={} blue={} yellow={} intro=true playing=false clear=false level=0 ctrl=1 offset={x=0,y=0} cursor=0 map_anim=0 ic=0 levels={ --Level 1 {start={x=48,y=64},offset={x=0,y=0}}, --Level 2 {start={x=416,y=104},offset={x=240,y=0}, crates={ {x=416,y=56} } }, --Level 3 {start={x=536,y=64},offset={x=480,y=0}, crates={ {x=568,y=64} } }, --Level 4 {start={x=912,y=96},offset={x=720,y=0}, switches={ {x=896,y=40,type=0} } }, --Level 5 {start={x=1024,y=96},offset={x=960,y=0}, switches={ {x=984,y=88,type=3}, {x=984,y=96,type=2}, {x=984,y=104,type=1} } }, --Level 6 {start={x=1408,y=64},offset={x=1200,y=0}, crates={ {x=1408,y=32}, {x=1408,y=96} }, switches={ {x=1408,y=16,type=1}, {x=1408,y=112,type=2} } }, --Level 7 {start={x=1488,y=80},offset={x=1440,y=0}, crates={ {x=1488,y=72}, {x=1488,y=64} }, switches={ {x=1464,y=104,type=3}, {x=1512,y=104,type=1} } }, --Level 8 {start={x=1800,y=48},offset={x=1680,y=0}, crates={ {x=1760,y=56}, {x=1768,y=56}, {x=1776,y=48}, {x=1776,y=40} }, switches={ {x=1760,y=40,type=2}, {x=1768,y=80,type=0} } }, --Level 9 {start={x=160,y=200},offset={x=0,y=136}, crates={ {x=120,y=200}, {x=128,y=200} }, switches={ {x=48,y=200,type=3} } }, --Level 10 {start={x=432,y=224},offset={x=240,y=136}, levers={ {x=432,y=240, controls={ {x=408,y=200}, {x=416,y=200}, {x=424,y=200}, {x=408,y=184,invert=true}, {x=416,y=184,invert=true}, {x=424,y=184,invert=true} } } } }, --Level 11 {start={x=544,y=200},offset={x=480,y=136}, levers={ {x=528,y=184, controls={ {x=536,y=224}, {x=544,y=224}, {x=552,y=224} } }, {x=560,y=184, controls={ {x=536,y=176}, {x=544,y=176}, {x=552,y=176} } }, {x=528,y=216, controls={ {x=520,y=192}, {x=520,y=200}, {x=520,y=208} } }, {x=560,y=216, controls={ {x=568,y=192}, {x=568,y=200}, {x=568,y=208} } }, } }, --Level 12 {start={x=1320,y=200},offset={x=1200,y=136}, switches={ {x=1320,y=232,type=3} }, crates={ {x=1320,y=168}, {x=1328,y=168} }, levers={ {x=1352,y=200, controls={ {x=1304,y=192}, {x=1304,y=200}, {x=1304,y=208} } } } }, --Level 13 {start={x=832,y=224},offset={x=720,y=136}, switches={ {x=792,y=192,type=0} }, crates={ {x=800,y=224}, {x=872,y=200} }, levers={ {x=832,y=240, controls={ {x=856,y=216}, {x=856,y=224}, {x=856,y=232}, {x=808,y=216,invert=true}, {x=808,y=224,invert=true}, {x=808,y=232,invert=true} } }, {x=880,y=224, controls={ {x=800,y=208}, {x=792,y=208}, {x=784,y=208} } }, {x=784,y=224, controls={ {x=880,y=208}, {x=872,y=208}, {x=864,y=208} } } } }, --Level 14 {start={x=1576,y=200},offset={x=1440,y=136}, crates={ {x=1544,y=192}, {x=1544,y=200}, {x=1544,y=208} }, switches={ {x=1576,y=176,type=2}, {x=1576,y=224,type=0} }, levers={ {x=1504,y=200, controls={ {x=1584,y=200} } } }, }, --Level 15 {start={x=1080,y=208},offset={x=960,y=136}, crates={ {x=1048,y=208}, {x=1112,y=240}, {x=1144,y=240} }, levers={ {x=1016,y=208, controls={ {x=1040,y=224}, {x=1048,y=224}, {x=1056,y=224}, {x=1128,y=232,invert=true}, {x=1128,y=240,invert=true}, {x=1128,y=248,invert=true} } }, {x=1048,y=240, controls={ {x=1032,y=200,invert=true}, {x=1032,y=208,invert=true}, {x=1032,y=216,invert=true}, {x=1120,y=224}, {x=1112,y=224}, {x=1104,y=224} } }, {x=1080,y=240, controls={ {x=1096,y=200}, {x=1096,y=208}, {x=1096,y=216}, {x=1072,y=192,invert=true}, {x=1080,y=192,invert=true}, {x=1088,y=192,invert=true} } }, {x=1112,y=208, controls={ {x=1064,y=200}, {x=1064,y=208}, {x=1064,y=216}, {x=1072,y=224,invert=true}, {x=1080,y=224,invert=true}, {x=1088,y=224,invert=true} } } } }, } crates={} switches={} level_text={ {{"Welcome to Color Critters!", "", "Guide the critters to the exit!", "Use the arrow keys to move.", "", "You control one critter at a", "time. Use X to cycle between", "them. The indicator shows which", "critter you're controlling."}, 125,20 }, {{"Each critter has a unique ability.", "Roart, for example, can withstand", "extreme temperatures.", "", "Crates can withstand extreme", "temperatures as well. Push one into", "a lava pit to have it act as a", "bridge!"}, 8,25 }, {{"Blute can swim. As with lava,", "you can push crates into water", "to create bridges."}, 132,50 }, {{"Yowler is immune to electricity.", "Electric fields can't be blocked", "by crates; you have to shut off", "the power by finding and", "pressing the white switch."}, 8,42 }, {{"Coloured barriers can be lowered by", "pressing the corresponding coloured", "switch.", "", "Unlike white switches, coloured", "switches can only be pressed by", "the critter of the corresponding", "colour."}, 105,25 }, {{"That's all you need to know for now.", "Use everything you've learned so far", "to guide the critters through this", "level. Good luck!"}, 5,46 }, {{"A few quick notes:", "", "- The critters, being tiny, can only", " push one crate at a time.", "- Crates can't weight down switches", " and can't be pulled, only pushed.", "- If you get stuck on a level, you", " can press S to restart it."}, 105,25 }, nil, nil, {{"Since you've made it this far,", "let's add in some levers.", "", "Levers control green barriers,", "but they don't work in the", "same way as switches.", "", "Play around with this one and", "see if you can figure it out."}, 8,24, }, {{"Levels can also have multiple", "levers at once, controlling", "different barriers.", "", "Which is which?"}, 128,45, }, } function BOOT() --disable cursor poke(0x7FC3F,1,1) sfx(15) end function next_level() if level==#levels then clear=true else level=level+1 clear=false reset_level() end end function TIC() if clear then clear_draw() elseif playing then game_draw() game_ctrl() animation() elseif intro then logo() end end function game_ctrl() if btnp(0) then try_move(0,ctrl) elseif btnp(1) then try_move(1,ctrl) elseif btnp(2) then try_move(2,ctrl) elseif btnp(3) then try_move(3,ctrl) end if btnp(5) then sfx(13) next_char() end if btnp(7) then sfx(2) reset_level() end end function animation() cursor=cursor+1 if cursor==32 then cursor=0 end map_anim=map_anim+1 end function next_char() repeat ctrl=ctrl+1 if ctrl==4 then ctrl=1 end sel=red if ctrl==2 then sel=blue elseif ctrl==3 then sel=yellow end until sel.goal==false end function game_draw() cls(0) map(offset.x/8,offset.y/8,30,17,0,0,0,1,remap) --draw stuck crates for k,v in pairs(crates) do if v.stuck then spr(20,v.x-offset.x,v.y-offset.y) end end --draw unstuck crates for k,v in pairs(crates) do if not v.stuck then spr(19,v.x-offset.x,v.y-offset.y) end end spr(304+yellow.dir,yellow.x,yellow.y,0) spr(288+blue.dir,blue.x,blue.y,0) spr(272+red.dir,red.x,red.y,0) --show cursor and force selected critter to the front if ctrl==1 then spr(320+math.floor(cursor/8),red.x,red.y-8,0) spr(272+red.dir,red.x,red.y,0) elseif ctrl==2 then spr(336+math.floor(cursor/8),blue.x,blue.y-8,0) spr(288+blue.dir,blue.x,blue.y,0) elseif ctrl==3 then spr(352+math.floor(cursor/8),yellow.x,yellow.y-8,0) spr(304+yellow.dir,yellow.x,yellow.y,0) end if level_text[level]~=nil then local txt=level_text[level] for k,v in pairs(txt[1]) do print(v,txt[2],txt[3]+k*8,12,false,1,true) end end end function clear_draw() cls(0) print_center("CONGRATULATIONS!",60) print_center("You guided the critters to safety!",76,1) end function print_center(txt,y,smol) local x=120-(string_length(txt,smol)/2) print(txt,x,y,12,false,1,smol) end function string_length(txt,smol) return print(txt,0,-9,0,false,1,smol) end function try_move(dir,char) local canMove=false local c=red if char==2 then c=blue elseif char==3 then c=yellow end c.dir=dir local xy={x=(c.x+offset.x)/8,y=(c.y+offset.y)/8} if dir==0 then --up xy.y=xy.y-1 elseif dir==1 then --down xy.y=xy.y+1 elseif dir==2 then --left xy.x=xy.x-1 elseif dir==3 then --right xy.x=xy.x+1 end local t=mget(xy.x,xy.y) if fget(t,0) then canMove=is_solid(t,xy.x,xy.y) elseif fget(t,1) then --lava if char==1 then canMove=true else --check if there's a crate bridge for k,v in pairs(crates) do if v.x/8==xy.x and v.y/8==xy.y and v.stuck then canMove=true end end if not canMove then sfx(8) reset_level() end end elseif fget(t,2) then --water if char==2 then canMove=true else --check if there's a crate bridge for k,v in pairs(crates) do if v.x/8==xy.x and v.y/8==xy.y and v.stuck then canMove=true end end if not canMove then sfx(10) reset_level() end end elseif fget(t,3) then --electricity if char==3 then canMove=true else --I wish the remap() function would take care of this --sadly it seems I have to do it manually for k,v in pairs(switches) do if v.type==0 and v.pressed then --electricity is off: proceed canMove=true end end if not canMove then sfx(11) reset_level() end end else canMove=true end local crateId=nil local crateMov=nil local getStuck=false if canMove then --check crates for k,v in pairs(crates) do if v.x/8==xy.x and v.y/8==xy.y and not v.stuck then --check if we can move the crate local cr={x=xy.x,y=xy.y} if dir==0 then --up cr.y=cr.y-1 elseif dir==1 then --down cr.y=cr.y+1 elseif dir==2 then --left cr.x=cr.x-1 elseif dir==3 then --right cr.x=cr.x+1 end --check if there's another crate in the way for j,w in pairs(crates) do if w.x/8==cr.x and w.y/8==cr.y and not w.stuck then canMove=false end end --if not, check if there's a block in the way if canMove then local ct=mget(cr.x,cr.y) if fget(ct,0) then canMove=is_solid(ct,cr.x,cr.y) if canMove then crateId=k crateMov=cr end elseif fget(ct,1) or fget(ct,2) then --check if there's already a crate stuck there getStuck=true canMove=true crateId=k crateMov=cr for j,w in pairs(crates) do if w.x/8==cr.x and w.y/8==cr.y and w.stuck then getStuck=false end end else canMove=true crateId=k crateMov=cr end end end end end if canMove then c.x=xy.x*8-offset.x c.y=xy.y*8-offset.y --move crates if crateId~=nil then local cr=crates[crateId] cr.x=crateMov.x*8 cr.y=crateMov.y*8 cr.stuck=getStuck if getStuck then sfx(12) else sfx(1) end else sfx(0) end --check for end goal if fget(t,7) then c.goal=true if red.goal and blue.goal and yellow.goal then sfx(7) next_level() else sfx(6) next_char() end end --check for switches for k,v in pairs(switches) do if v.x/8==xy.x and v.y/8==xy.y and not v.pressed then if v.type==0 or v.type==ctrl then sfx(5) v.pressed=true end end end --check for levers for k,v in pairs(levers) do if v.x/8==xy.x and v.y/8==xy.y then if v.active then sfx(4) else sfx(3) end v.active=not v.active end end else sfx(14) end end function reset_level() crates={} switches={} levers={} local lvl_data=levels[level] local start=lvl_data.start offset=lvl_data.offset local s={x=start.x-offset.x,y=start.y-offset.y} red= {x=s.x,y=s.y,dir=3,goal=false} blue= {x=s.x,y=s.y,dir=3,goal=false} yellow={x=s.x,y=s.y,dir=3,goal=false} ctrl=1 if lvl_data.crates~=nil then for k,v in pairs(lvl_data.crates) do table.insert(crates,{ x=v.x,y=v.y,stuck=false }) end end if lvl_data.switches~=nil then for k,v in pairs(lvl_data.switches) do table.insert(switches,{ x=v.x,y=v.y,type=v.type,pressed=false }) end end if lvl_data.levers~=nil then for k,v in pairs(lvl_data.levers) do table.insert(levers,{ x=v.x,y=v.y,active=false,controls=v.controls }) end end end function is_solid(t,x,y) if t==39 or t==71 then for k,v in pairs(switches) do if v.pressed and v.type==1 then return true end end elseif t==40 or t==72 then for k,v in pairs(switches) do if v.pressed and v.type==2 then return true end end elseif t==41 or t==73 then for k,v in pairs(switches) do if v.pressed and v.type==3 then return true end end elseif t==42 or t==74 then for k,v in pairs(levers) do for j,w in pairs(v.controls) do if w.x/8==x and w.y/8==y then return (v.active and not w.invert) or (w.invert and not v.active) end end end end return false end function remap(tile,x,y) local outTile=tile if tile==1 then --lava outTile=1+(math.floor((map_anim%120)/30)*16) elseif tile==2 then --water outTile=2+(math.floor((map_anim%72)/12)*16) elseif tile==12 or tile==14 then --electricity outTile=tile+math.floor((map_anim%16)/8) for k,v in pairs(switches) do if v.type==0 and v.pressed then outTile=3 end end elseif tile==39 or tile==71 then --red barriers for k,v in pairs(switches) do if v.type==1 and v.pressed then outTile=tile+16 end end elseif tile==40 or tile==72 then --blue barriers for k,v in pairs(switches) do if v.type==2 and v.pressed then outTile=tile+16 end end elseif tile==41 or tile==73 then --yellow barriers for k,v in pairs(switches) do if v.type==3 and v.pressed then outTile=tile+16 end end elseif tile==42 or tile==74 then --green barriers for k,v in pairs(levers) do for j,w in pairs(v.controls) do if w.x/8==x and w.y/8==y then if v.active and not w.invert then outTile=tile+16 elseif w.invert and not v.active then outTile=tile+16 end end end end elseif tile>=22 and tile<=25 then --switches for k,v in pairs(switches) do if v.x/8==x and v.y/8==y and v.pressed then outTile=tile-16 end end elseif tile==26 then --switches for k,v in pairs(levers) do if v.x/8==x and v.y/8==y and v.active then outTile=tile+2 end end end return outTile end function logo() cls(0) ic=ic+1 local l=0 if (ic>=10 and ic<20) or (ic>=220 and ic<230) then l=204 elseif (ic>=20 and ic<30) or (ic>=210 and ic<220) then l=200 elseif (ic>=30 and ic<40) or (ic>=200 and ic<210) then l=196 elseif ic>=40 and ic<200 then l=192 end if ic==270 then intro=false playing=true next_level() end if l>0 then spr(l,104,50,0,1,0,0,4,4) end end