Working pits

This commit is contained in:
Pyrex 2022-12-17 15:48:52 -08:00
parent 11e33d0109
commit 0ff3065585

View File

@ -142,14 +142,27 @@ function level:advance()
end
function level:draw()
cls(1)
pal(1,0)
map(
self.bigx*16,self.bigy*16,
0,0,16,16,
64 -- flag 6: visible
)
for _,pit in pairs(self._pits) do
spr(pit.s,pit.px,pit.py)
if pit.contents then
pal(7,0)
pal(0,1)
palt(0,false)
spr(pit.contents,pit.px,pit.py)
pal()
end
for _,crate in pairs(self._crates) do
spr(crate.s,crate.px,crate.py)
end
end
pal()
end
function level:busy()
@ -162,26 +175,55 @@ end
function level:update()
_apply(self, self.todo)
for _,crate in pairs(self._crates) do
local remove={}
for cix,crate in pairs(self._crates) do
_apply(crate, crate.todo)
if #crate.todo==0 then
local pit=self._pits[_mix(crate.mx,crate.my)]
if pit!=nil and pit.contents==nil then
add(remove,cix)
crate.dead=true
pit.contents=crate.s
end
end
end
for cix in all(remove) do
self._crates[cix]=nil
end
if #remove>0 then
self:recollide()
self:reanchor(true)
end
end
function level:load_dynobjs()
self._crates={}
self._pits={}
for mx=0,15,1 do
for my=0,15,1 do
local mxy=_mix(mx,my)
local px,py=mx*8,my*8
local s=self:_mget(mx,my)
local def=self:_get_cratedef(s)
if def!=nil then
self._crates[mxy]={
s=s,def=def,
mx=mx,my=my,
px=mx*8,py=my*8,
px=px,py=py,
todo={}
}
end
if s==28 then -- pit
self._pits[mxy]={
s=s,
mx=mx,my=my,
px=px,py=py,
contents=nil
}
end
end
end
end
@ -241,6 +283,11 @@ function level:anchors_in(px0,py0,px1,py1)
return ancs
end
function level:get_open_pit(mx,my)
local pit=self._pits[_mix(mx,my)]
if (pit and pit.contents==nil) return pit
end
function level:point_anchor(px,py)
local ax,ay=self:p2a(px,py)
local anc=self._anch[_amix(ax,ay)]
@ -435,6 +482,8 @@ function player:reinit(x,y)
self.py=0
self.todo={}
self.fall_frame=0
self.orientx=-1
self.orienty=0
@ -467,6 +516,11 @@ function player:update()
level:advance()
return
end
if level:get_open_pit(self.x,self.y) then
self.todo={{update=self._fall}}
return
end
if btn(⬅️) 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}})
@ -532,6 +586,12 @@ function player:update()
end
end
function player:_fall()
if self.fall_frame<10 then
self.fall_frame+=1
end
end
function player:_rope_pos()
local px=self.x*8+self.px
local px2=px+4
@ -551,20 +611,25 @@ function player:draw()
local head=2-self.orienty
if (self.fall_frame>5) return
if (self.fall_frame>0) then
for i=0,15 do pal(i,1) end
end
if self.orientx==-1 then
spr(16,px+6,py-2,1,1)
if (self.rope) self.rope:draw()
if (self.rope and self.fall_frame==0) self.rope:draw()
spr(17,px+1,py,1,1)
spr(head,px-3,py-3,1,1)
else
spr(16,px-6,py-2,1,1,true)
if (self.rope) self.rope:draw()
if (self.rope and self.fall_frame==0) self.rope:draw()
spr(17,px-1,py,1,1,true)
spr(head,px+3,py-3,1,1,true)
end
--spr(17,px+3,py)
--spr(17,px+6,py)
-- if spr(2,self.x*8+self.px)
pal()
end
-->8
@ -637,12 +702,16 @@ function rope:_make_consistent()
)
if #self.latch.rec.todo==0 then
if self.latch.rec.dead==true then
self.under_destruction=true
return
end
for i=0,#self.ancs do
local a0=self:_anc(i)
local a1=self:_anc(i+1)
if not self:_can_stretch(a0, a1) then
self.under_destruction=true
break
return
end
end
end
@ -1271,22 +1340,22 @@ end
__gfx__
00000000000300000000003300030000000000000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000000333330000003333033333000aa00aa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000009933399000399330933333900aaaaaa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000009a333a90033a9330933333900aaaaaa00000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
00000000333333303333330003333300009999000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000000003333300000033000333330000aaaa000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000000000333c0003333c0000333000000aa0000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
000000000000cc000000cc000000cc00004444000000000000000000000000000000000000000000000000000000000077777777000000000000000000000000
0000ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00e0000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00e0e00e00c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00ee00ee00ccccc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000ee00ccccccc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00eeee000c00c00c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
eeee0000cc0cc0cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000003000000000033000300000000000000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000000333330000003333033333000aa00aa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000009933399000399330933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000009a333a90033a9330933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000003333333033333300033333000099990000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000000003333300000033000333330000aaaa0000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000000000333c0003333c0000333000000aa00000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000000000cc000000cc000000cc000044440000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
000e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00e0000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00e0e00e00c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00ee00ee00ccccc00000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00000ee00ccccccc0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00eeee000c00c00c0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
eeee0000cc0cc0cc0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00000000000a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000aaaaaaa91000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000aaaaaa1a91100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -1303,14 +1372,14 @@ eeee0000cc0cc0cc0000000000000000000000000000000000000000000000000000000000000000
0000000077a000000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777777777777777777
00000007777a00000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
00044444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000077777777777777777770077777777777
dd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddddd0dd0ddddd00ddd
ddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00dddddddddddddd00ddd
0dddddd00dddddd00ddddddd0ddddddd0dddddd00dddddd00ddddddd0dddddddddddddd0ddddddd0ddddddddddddddddddddddd0ddddddd0dddddddddddddddd
ddd00dddddd00dddddd00d00ddd00d00ddd00dddddd00dddddd00d00ddd00d0000d00ddd00d00ddd00d00d0000d00d0000d00ddd00d00ddd00d00d0000d00d00
ddd00dddddd00dddddd00d00ddd00d00ddd00dddddd00dddddd00d00ddd00d0000d00ddd00d00ddd00d00d0000d00d0000d00ddd00d00ddd00d00d0000d00d00
0dddddd00dddddd00ddddddd0ddddddd0dddddd00dddddd00ddddddd0dddddddddddddd0ddddddd0ddddddddddddddddddddddd0ddddddd0dddddddddddddddd
ddddddddddddddddddddddddddddddddddd00dddddd00dddddd00dddddd00dddddddddddddddddddddddddddddddddddddd00dddddd00dddddd00dddddd00ddd
dd0dd0dddd0dd0dddd0dd0dddd0dd0ddddd00dddddd00dddddd00dddddd00ddddd0dd0dddd0dd0dddd0dd0dddd0dd0ddddd00dddddd00dddddd00dddddd00ddd
77077077777007777707707777700777770770777770077777077077777007777707707777700777770770777770077777077077777007777707707777700777
77777777777007777777777777700777777777777770077777777777777007777777777777700777777777777770077777777777777007777777777777700777
07777770077777700777777707777777077777700777777007777777077777777777777077777770777777777777777777777770777777707777777777777777
77700777777007777770070077700700777007777770077777700700777007000070077700700777007007000070070000700777007007770070070000700700
77700777777007777770070077700700777007777770077777700700777007000070077700700777007007000070070000700777007007770070070000700700
07777770077777700777777707777777077777700777777007777777077777777777777077777770777777777777777777777770777777707777777777777777
77777777777777777777777777777777777007777770077777700777777007777777777777777777777777777777777777700777777007777770077777700777
77077077770770777707707777077077777007777770077777700777777007777707707777077077770770777707707777700777777007777770077777700777
__label__
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
@ -1448,9 +1517,9 @@ __map__
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000044000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
01000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0100000000001c000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000c0c0c0c0c0c0c0c0c00000000000020210000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c000000000000000000000c0c0c0c0c0c00000000000030310000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000