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