diff --git a/chameleonic.p8 b/chameleonic.p8 index 0a70acc..a16ebe9 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -2,6 +2,7 @@ pico-8 cartridge // http://www.pico-8.com version 38 __lua__ modules={} +real_modules={} frame=0 function _init() @@ -109,9 +110,56 @@ function _mnmx(x,y) if (x>y)return y,x return x,y end + +-->8 +kbd={} +add(real_modules,kbd) +function kbd:init() + self.prev_real=btn() + self.down=0 +end + +function kbd:update() + local now=btn() + local pressed=now&~self.prev_real + self.down&=now + self.down|=pressed + self.prev_real=now +end + +function kbd:btn(i) + return self.down&(1<8 +title={} +add(modules,title) + +function title:init() +end + +function title:draw() + cls(0) + -- this is right for 72x32 + spr(3,28,48,9,4) + print("pyrex",28,81,7) + print("[nyeogmi]",65,81,7) + print("kistaro",28,87,7) +end + +function title:update() + if btn()!=0 then + modules=real_modules + _init() + end +end -->8 level={} -add(modules,level) +add(real_modules,level) function level:init() level:reinit(0) @@ -473,7 +521,7 @@ function level:tug_crate(mx0,my0,dmx,dmy) end -->8 player={} -add(modules,player) +add(real_modules,player) function player:init() --self:reinit(8,14) @@ -534,33 +582,33 @@ function player:update() return end - if btn(⬅️) then + if kbd:btn(0) then if level:can_move(true,self.x,self.y,-1,0,0,2) then self.todo=f4({{orientx=-1,orienty=0,px=-2},{px=-7},{x=self.x-1}}) else self.orientx=-1 self.orienty=0 end - elseif btn(➡️) then + elseif kbd:btn(1) then if level:can_move(true,self.x,self.y,1,0,0,2) then self.todo=f4({{orientx=1,orienty=0,px=2},{px=7},{x=self.x+1}}) else self.orientx=1 self.orienty=0 end - elseif btn(⬆️) then + elseif kbd:btn(2) then if level:can_move(true,self.x,self.y,0,-1,0,2) then self.todo=f4({{orienty=-1,py=-2},{py=-7},{y=self.y-1}}) else self.orienty=-1 end - elseif btn(⬇️) then + elseif kbd:btn(3) then if level:can_move(true,self.x,self.y,0,1,0,2) then self.todo=f4({{orienty=1,py=2},{py=7},{y=self.y+1}}) else self.orienty=1 end - elseif btn(🅾️) then + elseif kbd:btn(4) then if self.rope==nil then local rx,ry,rx2,ry2=self:_rope_pos() local dx,dy=12*self.orientx,12*self.orienty @@ -576,7 +624,7 @@ function player:update() self.rope:tug() self.todo={{},{},{}} end - elseif btn(❎) then + elseif kbd:btn(5) then if self.rope!=nil then self.rope:destroy() end @@ -604,21 +652,13 @@ function player:update() end function player:_vanish_if_requested() - local bvan=btn(❎) - if self.bvan and not bvan then - self.vanishing=false - elseif not self.bvan and bvan then - self.vanishing=true - end - self.bvan=bvan - - if self.vanishing then + if kbd:btn(5) then self.vanish_frame+=1 if (self.fall_frame>0 or self.vanish_frame>20) then level:restart() + kbd:release(5) self.vanish_frame=20 - self.vanishing=false end else self.vanish_frame-=1 @@ -648,7 +688,7 @@ function player:draw() local px=self.x*8+self.px local py=self.y*8+self.py - local head=2-self.orienty + local head=1-self.orienty local vanish_level=self.vanish_frame/20 local invis_level=max(self.fall_frame/10,4*(vanish_level-0.75)) @@ -706,7 +746,6 @@ function player:draw() end -->8 - rope={} rope.__index=rope @@ -1467,38 +1506,38 @@ end __gfx__ -000000000000300000000022000030000000000000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -000000000033333000003322003333300aa00aa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -000000000993339900399320093333390aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -0000000009a333a9033a9320093333390aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -000000000233333233333200002222200099990000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -0000000000222220000022000022222000aaaa0000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -00000000000222c002222c0000022200000aa00000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -0000000000000cc00000cc0000000cc00044440000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 -0000ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -000f00f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00d0000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00d0d00f00c040500000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00dd00ee00c445500000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00000ee00c4445550000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00eeee000c0040050000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -eeee0000cc0440550000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 -00000000000a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000aaaaaaa91000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0000aaaaaa1a91100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0aaaaaaaaa1a91110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0aaaaaaaa41a91a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0a000aa4441a91a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00a0044449a110a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000aa111991111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000991000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777 -00000000990000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777 -00000000990000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777 -00000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777 -00000000aa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777 -0000000077a000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777 -00000007777a00000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777 -00044444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777 +000030000000002200003000777777777777777777777777777777777777777777777777777777777777777777777777dddddddd000000000000000000000000 +003333300000332200333330700000000000000000000000000000000000000000000000000000000000000000000007dddddddd000000000000000000000000 +099333990039932009333339707770700077707770777070700770700077707770777000000000000000000000000007dddddddd000000000000000000000000 +09a333a9033a932009333339707070700070707000700070707070700070707000707000000000000000000000000007dddddddd000000000000000000000000 +023333323333320000222220707770700077707000770077707070700070707700770000000000000000000000000007dddddddd000000000000000000000000 +002222200000220000222220707000700070707000700070707070700070707000707000000000000000000000000007dddddddd000000000000000000000000 +000222c002222c0000022200707000777070707770777070707700777077007770707000000000000000000000000007dddddddd000000000000000000000000 +00000cc00000cc0000000cc0700000000000000000000000000000000000000000000000000000000000000000000007dddddddd000000000000000000000000 +0000ff00000000000000000070777077707070777000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +000f00f0000000000aa00aa070070070007070070000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00d0000f000000000aaaaaa070070077000700070000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00d0d00f00c040500aaaaaa070070070007070070000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00dd00ee00c445500099990070070077707070070000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00000ee00c44455500aaaa0070000000000000000000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00eeee000c004005000aa00070000000000000000000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +eeee0000cc0440550044440070000000000000000000000000000000000000000000000000000000000000000000000711111111000000000000000000000000 +00000000000a90000000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +00000aaaaaaa91000000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +0000aaaaaa1a91100000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +0aaaaaaaaa1a91110000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +0aaaaaaaa41a91a10000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +0a000aa4441a91a10000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +00a0044449a110a10000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +000aa111991111100000000070000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000 +00000000991000000000000070000000000000000000000000000000000000000000000000000000000000000000000777700777777777777777777777777777 +00000000990000000000000070000000000000000000000000000000000000000000000000000000000000000000000777700777777777777777777777777777 +00000000990000000000000070000000000000000000000000000000000000000000000000000000000000000000000777777777777777777777777777777777 +00000000090000000000000070000000000000000000000000000000000000000000000000000000000000000000000777700777777007007770077700700777 +00000000aa0000000000000070000000000000000000000000000000000000000000000000000000000000000000000777700777777007007770077700700777 +0000000077a000000000000070000000000000000000000000000000000000000000000000000000000000000000000777777777777777777777777777777777 +00000007777a00000000000070000000000000000000000000000000000000000000000000000000000000000000000777777777777777777770077777777777 +00044444444444000000000077777777777777777777777777777777777777777777777777777777777777777777777777777777777777777770077777777777 77077077777007777707707777700777770770777770077777077077777007777707707777700777770770777770077777077077777007777707707777700777 77777777777007777777777777700777777777777770077777777777777007777777777777700777777777777770077777777777777007777777777777700777 07777770077777700777777707777777077777700777777007777777077777777777777077777770777777777777777777777770777777707777777777777777 @@ -1651,7 +1690,7 @@ __map__ 0c000000000000000c0c0c0c0c0c0c0c0c00000000000020210000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c000000000000000000000c0c0c0c0c0c00000000000030310000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0c0c0c0c0c0c0c0000000c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0c0c0c0c0c0c0c0c00000000000000040100000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0c0c0c0c0c0c0c0c00000000000000120100000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000