Compare commits

...

2 Commits

Author SHA1 Message Date
11e33d0109 Fix some tiny level transition bugs 2022-12-17 15:15:56 -08:00
671e4a5051 Map and art changes, level transition 2022-12-17 15:08:54 -08:00

View File

@ -128,19 +128,22 @@ end
function level:reinit(n)
self.ix=n
self.todo={}
self.bigx=n%16
self.bigy=n\16
self.bigx=(n%16)
self.bigy=(n\16)
-- collision map
self:load_dynobjs()
self:recollide()
self:reanchor()
player:reinit(6,14)
self:reanchor(true)
self:spawn_exit()
end
function level:advance()
self:reinit(self.ix+1)
end
function level:draw()
map(
self.bigx,self.bigy,
self.bigx*16,self.bigy*16,
0,0,16,16,
64 -- flag 6: visible
)
@ -220,6 +223,9 @@ function level:reanchor(remove)
end
end
function level:win_at(mx,my)
return self._wins[_mix(mx,my)]
end
function level:anchor_points()
return pairs(self._anch)
end
@ -241,6 +247,32 @@ function level:point_anchor(px,py)
return anc
end
function level:spawn_exit()
self._wins={}
local spawned=false
local spawn_at=function(x,y)
if (self:_mget(x,y)!=1) return
assert(not spawned,x..","..y)
spawned=true
player:reinit(x,y)
player.orientx=-1
if (x<8) player.orientx=1
end
local win_at=function(x,y)
if (self:_mget(x,y)!=4) return
for n in all(neighbors{x=x,y=y}) do
if n.x<0 or n.y<0 or n.x>15 or n.y>15 then
self._wins[_mix(n.x,n.y)]=true
end
end
end
for f in all{spawn_at,win_at} do
for x=1,14 do f(x,0) f(x,15) end
for y=0,15 do f(0,y) f(15,y) end
end
assert(spawned)
end
function level:p2a(px,py)
return px\4,py\4
end
@ -252,7 +284,7 @@ function level:a2p(ax,ay)
end
function level:mcoll(mx,my)
return self._coll[_mix(mx,my)]==true
return self._coll[_mix(mx,my)]!=false
end
function level:pcoll(px,py)
@ -333,8 +365,13 @@ function level:get_latch(dx,dy,px,py)
end
function level:can_move(
is_player,
mx0,my0,dmx,dmy,exclude_src,exclude_dst
)
if is_player and self:win_at(mx0+dmx,my0+dmy) then
return true
end
if self:mcoll(mx0+dmx,my0+dmy) then
return false
end
@ -426,28 +463,32 @@ function player:update()
end
if not self:any_busy() then
if level:win_at(self.x,self.y) then
level:advance()
return
end
if btn(⬅️) then
if level:can_move(self.x,self.y,-1,0,0,2) 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
if level:can_move(self.x,self.y,1,0,0,2) 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
if level:can_move(self.x,self.y,0,-1,0,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
if level:can_move(self.x,self.y,0,1,0,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
@ -1066,7 +1107,7 @@ function rope:_tug()
if crate==nil or touched[_mix(o.mx,o.my)] then
can_do=false
else
if not level:can_move(o.mx,o.my,o.dmx,o.dmy,0,0) then
if not level:can_move(false,o.mx,o.my,o.dmx,o.dmy,0,0) then
can_do=false
end
end
@ -1139,7 +1180,7 @@ function rope:_tug()
if not too_far and
not touched[_mix(mx0,my0)] and
level:can_move(mx0,my0,dmx,dmy,1,0)
level:can_move(false,mx0,my0,dmx,dmy,1,0)
then
level:tug_crate(
mx0,my0,
@ -1231,13 +1272,13 @@ end
__gfx__
00000000000300000000003300030000000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00000000033333000000333303333300000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00333300993339900039933093333390000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
003333009a333a90033a933093333390000c00000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00000000333333303333330003333300000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00333300033333000000330003333300000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0003300000333c0003333c0000333000000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000000000cc000000cc000000cc00000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000000333330000003333033333000aa00aa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000009933399000399330933333900aaaaaa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000009a333a90033a9330933333900aaaaaa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00000000333333303333330003333300009999000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000000003333300000033000333330000aaaa000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000000000333c0003333c0000333000000aa0000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000000000cc000000cc000000cc00004444000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00e0000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -1246,22 +1287,22 @@ __gfx__
00000ee00ccccccc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00eeee000c00c00c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
eeee0000cc0cc0cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
00000000000a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000aaaaaaa91000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000aaaaaa1a91100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0aaaaaaaaa1a91110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0aaaaaaaa41a91a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0a000aa4441a91a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00a0044449a110a10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000aa111991111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000991000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777
00000000990000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777777777777777777777777
00000000990000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777
00000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777
00000000aa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000077700777777007007770077700700777
0000000077a000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777
00000007777a00000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
00044444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
dd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddd
ddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00ddd
0dddddd00dddddd00ddddddd0ddddddd0dddddd00dddddd00ddddddd0dddddddddddddd0ddddddd0ddddddddddddddddddddddd0ddddddd0dddddddddddddddd
@ -1401,22 +1442,22 @@ __label__
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
__gff__
000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000c00000000000000000000000000000000000000040400000000000000000000000000000404000000000000000000000c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0c0c3e0c3e0c0c0c0c0c0c3e0c3e0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0000000000000c0c0000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000c00000000000000000c00000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000000000c00000c00000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3d00000000000000000000000000003f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000c000c0000000000000c000c000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0000000000000c0c0000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0000004600000c0c00004c0000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000c000000000c0c000000000c000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3d00000000000000000000000000003f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000000000c00000c00000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0000000000003c3c0000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c00000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c3c0c0c0c0c0c0c0c0c3c0c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
01000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000020210000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000000000c0c0c0c0c0c00000000000030310000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0000000c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c00000000000000040100000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000