forked from pyrex/chameleonic
Compare commits
3 Commits
rope_golf
...
39efcdc1d5
Author | SHA1 | Date | |
---|---|---|---|
39efcdc1d5
|
|||
24954c1145
|
|||
49aa2833fd
|
133
chameleonic.p8
133
chameleonic.p8
@ -633,12 +633,10 @@ end
|
|||||||
|
|
||||||
ropecheck=split"-0.6,0.4,0.4"
|
ropecheck=split"-0.6,0.4,0.4"
|
||||||
|
|
||||||
-- argument "o" is a rope operation:
|
|
||||||
-- array of [mx0,my0,dmx,dmy]
|
|
||||||
function level:can_move(
|
function level:can_move(
|
||||||
is_player,o,exclude_src,exclude_dst
|
is_player,
|
||||||
|
mx0,my0,dmx,dmy,exclude_src,exclude_dst
|
||||||
)
|
)
|
||||||
local mx0,my0,dmx,dmy=unpack(o)
|
|
||||||
local mx1,my1=mx0+dmx,my0+dmy
|
local mx1,my1=mx0+dmx,my0+dmy
|
||||||
if (is_player and self:win_at(mx1,my1)) return true
|
if (is_player and self:win_at(mx1,my1)) return true
|
||||||
if (is_player and self:get_open_pit(mx1,my1)) return wrongbleep:adequately_warned()
|
if (is_player and self:get_open_pit(mx1,my1)) return wrongbleep:adequately_warned()
|
||||||
@ -654,12 +652,7 @@ function level:can_move(
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- argument is a rope operation:
|
function level:tug_crate(mx0,my0,dmx,dmy)
|
||||||
-- array of [mx0,my0,dmx,dmy]
|
|
||||||
-- must be a free function
|
|
||||||
-- to use as a foreach target
|
|
||||||
function level_tug_crate(t)
|
|
||||||
local self,mx0,my0,dmx,dmy=level,unpack(t)
|
|
||||||
local mxy0=_mix{mx0,my0}
|
local mxy0=_mix{mx0,my0}
|
||||||
local existing=self._crates[mxy0]
|
local existing=self._crates[mxy0]
|
||||||
if (not existing) return
|
if (not existing) return
|
||||||
@ -741,7 +734,7 @@ function player:update()
|
|||||||
else
|
else
|
||||||
local x,y=self.x,self.y
|
local x,y=self.x,self.y
|
||||||
local function try_move(dx,dy,f)
|
local function try_move(dx,dy,f)
|
||||||
if level:can_move(true,{x,y,dx,dy},0,2) then
|
if level:can_move(true,x,y,dx,dy,0,2) then
|
||||||
self.todo=f
|
self.todo=f
|
||||||
self.cooldown=3
|
self.cooldown=3
|
||||||
local t=f[#f]
|
local t=f[#f]
|
||||||
@ -1001,7 +994,7 @@ function rope:affected_src_xy(artificial_px,artificial_py)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function rope:draw(artificial_px,artificial_py)
|
function rope:draw(artificial_px,artificial_py)
|
||||||
local points,highlight,hypo_ops,hypo_blocks=self:_tug(true)
|
local points,highlight,hypo_ops=self:_tug(true)
|
||||||
local n,perc_to_show,from_end = self.state.name,1.0
|
local n,perc_to_show,from_end = self.state.name,1.0
|
||||||
if (n=="done") return
|
if (n=="done") return
|
||||||
if (n=="cast") perc_to_show=self.state.frame/2
|
if (n=="cast") perc_to_show=self.state.frame/2
|
||||||
@ -1073,17 +1066,11 @@ function rope:draw(artificial_px,artificial_py)
|
|||||||
|
|
||||||
-- hypothetical
|
-- hypothetical
|
||||||
local time=t()-self.flicker_t
|
local time=t()-self.flicker_t
|
||||||
if n=="latched" and time>0 and not level:busy() then
|
if n=="latched" and time>0 and time%0.5>0.25 and not level:busy() then
|
||||||
if time%0.5>0.25 then
|
for o in all(hypo_ops) do
|
||||||
for o in all(hypo_ops) do
|
local mx0,my0,dmx,dmy=unpack(o)
|
||||||
local mx0,my0,dmx,dmy=unpack(o)
|
local px1,py1=(mx0+dmx)*8,(my0+dmy)*8
|
||||||
local px1,py1=(mx0+dmx)*8,(my0+dmy)*8
|
spr(14,px1,py1)
|
||||||
spr(14,px1,py1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for o in all(hypo_blocks) do
|
|
||||||
local x,y,dx,dy=unpack(o)
|
|
||||||
spr(53,8*x+4*dx,8*y+4*dy,1,1,time%0.5>0.25)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1544,29 +1531,29 @@ function rope:_tug(hypothetically)
|
|||||||
local ancs=self:_anchors_simplified()
|
local ancs=self:_anchors_simplified()
|
||||||
local touched={}
|
local touched={}
|
||||||
|
|
||||||
local blocks = {}
|
|
||||||
for i=#ancs-1,2,-1 do
|
for i=#ancs-1,2,-1 do
|
||||||
local ops_before_trash,blocks_before_trash=self:_calc_push(ancs[i+1],ancs[i],ancs[i-1],ancs[i-2])
|
local ops_before_trash=self:_calc_push(ancs[i+1],ancs[i],ancs[i-1],ancs[i-2])
|
||||||
local ops = {}
|
local ops_to_do,corners={}
|
||||||
for b in all(blocks_before_trash) do add(blocks, b) end
|
|
||||||
if #ops_before_trash>0 then
|
if #ops_before_trash>0 then
|
||||||
ops=ops_before_trash
|
ops_to_do=ops_before_trash
|
||||||
else
|
else
|
||||||
local ops_after_trash,blocks_after_trash=self:_calc_push(ancs[i-2],ancs[i-1],ancs[i],ancs[i+1])
|
local ops_after_trash=self:_calc_push(ancs[i-2],ancs[i-1],ancs[i],ancs[i+1])
|
||||||
ops=ops_after_trash
|
ops_to_do=ops_after_trash
|
||||||
for b in all(blocks_after_trash) do add(blocks,b) end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ops=ops_to_do
|
||||||
|
|
||||||
if #ops>0 then
|
if #ops>0 then
|
||||||
if (hypothetically) return ancs,i-1,ops,blocks
|
if (hypothetically) return ancs,i-1,ops
|
||||||
foreach(ops, level_tug_crate)
|
|
||||||
|
for o in all(ops) do level:tug_crate(unpack(o)) end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local latch=self.latch
|
local latch=self.latch
|
||||||
if latch and latch.el=="eyehook" then
|
if latch and latch.el=="eyehook" then
|
||||||
if (hypothetically) return ancs,0,{},blocks
|
if (hypothetically) return ancs,0,{}
|
||||||
player.todo={{
|
player.todo={{
|
||||||
update=function(s)
|
update=function(s)
|
||||||
if not s.rope or s.rope:done() then
|
if not s.rope or s.rope:done() then
|
||||||
@ -1607,20 +1594,17 @@ function rope:_tug(hypothetically)
|
|||||||
invalid_move=true
|
invalid_move=true
|
||||||
end
|
end
|
||||||
|
|
||||||
if not invalid_move then
|
if not invalid_move and
|
||||||
local mv = {mx0,my0,dmx,dmy}
|
level:can_move(false,mx0,my0,dmx,dmy,1,0)
|
||||||
if level:can_move(false,mv,1,0) then
|
then
|
||||||
if (hypothetically) return ancs,0,{mv},blocks
|
if (hypothetically) return ancs,0,{{mx0,my0,dmx,dmy}}
|
||||||
|
|
||||||
level_tug_crate(mv)
|
level:tug_crate(mx0,my0,dmx,dmy)
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
add(blocks, mv)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (hypothetically) return ancs,0,{},blocks
|
if (hypothetically) return ancs
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1645,16 +1629,21 @@ function rope:_calc_push(
|
|||||||
smy=-smy
|
smy=-smy
|
||||||
end
|
end
|
||||||
|
|
||||||
local dmx=1 -- maybe push right?
|
local mx,dmx
|
||||||
if anch.adx==-1 and a0.x>an.x+7 then
|
if anch.adx==-1 and a0.x>an.x+7 then
|
||||||
-- push left
|
-- push left
|
||||||
ax0, dmx=ax0-1,-1
|
mx=ax0-1
|
||||||
elseif anch.adx!=1 or a0.x>=an.x-7 then
|
dmx=-1
|
||||||
|
elseif anch.adx==1 and a0.x<an.x-7 then
|
||||||
|
-- push right
|
||||||
|
mx=ax0
|
||||||
|
dmx=1
|
||||||
|
else
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
for my=my0,my1,smy do
|
for my=my0,my1,smy do
|
||||||
add(ops,{ax0,my,dmx,0})
|
add(ops,{mx,my,dmx,0})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1666,32 +1655,43 @@ function rope:_calc_push(
|
|||||||
smx=-smx
|
smx=-smx
|
||||||
end
|
end
|
||||||
|
|
||||||
local dmy=1 -- maybe push down?
|
local my,dmy
|
||||||
if anch.ady==-1 and a0.y>an.y+6 then
|
if anch.ady==-1 and a0.y>an.y+6 then
|
||||||
-- push up
|
-- push up
|
||||||
ay0,dmy=ay0-1,-1
|
my=ay0-1
|
||||||
elseif anch.ady!=1 or a0.y>=an.y-6 then
|
dmy=-1
|
||||||
|
|
||||||
|
elseif anch.ady==1 and a0.y<an.y-6 then
|
||||||
|
-- push down
|
||||||
|
my=ay0
|
||||||
|
dmy=1
|
||||||
|
else
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
for mx=mx0,mx1,smx do
|
for mx=mx0,mx1,smx do
|
||||||
add(ops,{mx,ay0,0,dmy})
|
add(ops,{mx,my,0,dmy})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ops2,blocked={},{}
|
local ops2={}
|
||||||
for o in all(ops) do
|
for o in all(ops) do
|
||||||
local mx,my=unpack(o)
|
local mx,my,dmx,dmy=unpack(o)
|
||||||
if level:mcoll(mx,my) then
|
if not level:mcoll(mx,my) then
|
||||||
if (not level:get_crate(mx, my)) break
|
-- great!
|
||||||
if not level:can_move(false,o,0,0) then
|
else
|
||||||
add(blocked,o)
|
local crate=level:get_crate(mx,my)
|
||||||
|
if crate then
|
||||||
|
if not level:can_move(false,mx,my,dmx,dmy,0,0) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
add(ops2,o)
|
add(ops2,o)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ops2,blocked
|
return ops2
|
||||||
end
|
end
|
||||||
|
|
||||||
function rope:_anchors_simplified()
|
function rope:_anchors_simplified()
|
||||||
@ -1915,23 +1915,24 @@ function persist:init0()
|
|||||||
cartdata("ulimate_lizard_total_destruction_0_1")
|
cartdata("ulimate_lizard_total_destruction_0_1")
|
||||||
self.init0 = self.read
|
self.init0 = self.read
|
||||||
self:read()
|
self:read()
|
||||||
|
self.ready=true
|
||||||
end
|
end
|
||||||
|
|
||||||
function persist:read()
|
function persist:read()
|
||||||
self.ready=false
|
|
||||||
local m = dget(0) == 0
|
local m = dget(0) == 0
|
||||||
self.music = m
|
self.music = m
|
||||||
if m then music_on() else music_off() end
|
if m then music_on() else music_off() end
|
||||||
self.max_level = dget(1)
|
self.max_level = dget(1)
|
||||||
self.recent_level = dget(2)
|
self.recent_level = dget(2)
|
||||||
self.ready=true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function persist:wipe()
|
function persist:wipe()
|
||||||
|
self.ready=false
|
||||||
for i=0,64 do
|
for i=0,64 do
|
||||||
dset(i,0)
|
dset(i,0)
|
||||||
end
|
end
|
||||||
self:read()
|
self:read()
|
||||||
|
self.ready=true
|
||||||
end
|
end
|
||||||
|
|
||||||
function persist:lvlstart()
|
function persist:lvlstart()
|
||||||
@ -1973,10 +1974,10 @@ eeee0000cc04405500444400efeeee5e11111111e5eeeefeeeeeeeeeeeeeeeeeffffffffffffffff
|
|||||||
000aa111991111103bbbbbb3eeeeeeeeeeeeeeeeeeeeeeeeff1ff1ffffffffffffffffff00000000000000000000000000000000000000000000000000000000
|
000aa111991111103bbbbbb3eeeeeeeeeeeeeeeeeeeeeeeeff1ff1ffffffffffffffffff00000000000000000000000000000000000000000000000000000000
|
||||||
0000000099100000f765000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111999999111111111
|
0000000099100000f765000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111999999111111111
|
||||||
00000000990000007700000000000000000000000000000000000000000000000000000000000000000000000000000019911991999999911999999119999999
|
00000000990000007700000000000000000000000000000000000000000000000000000000000000000000000000000019911991999999911999999119999999
|
||||||
00000000990000006060000000000000000bc0000090020000000000000000000000000000000000000000000000000019977991999999911999999119999999
|
00000000990000006060000000000000000000000000000000000000000000000000000000000000000000000000000019977991999999911999999119999999
|
||||||
00000000090000005005000000bbcc00000bc0000009200000000000000000000000000000000000000000000000000019911991999117111991199111711999
|
00000000090000005005000000000000000000000000000000000000000000000000000000000000000000000000000019911991999117111991199111711999
|
||||||
00000000aa0000000000000000ccbb00000cb0000002900000000000000000000000000000000000000000000000000019911991999117111991199111711999
|
00000000aa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000019911991999117111991199111711999
|
||||||
0000000077a000000000000000000000000cb0000020090000000000000000000000000000000000000000000000000019999991999999911997799119999999
|
0000000077a000000000000000000000000000000000000000000000000000000000000000000000000000000000000019999991999999911997799119999999
|
||||||
00000007777a00000000000000000000000000000000000000000000000000000000000000000000000000000000000019999991999999911991199119999999
|
00000007777a00000000000000000000000000000000000000000000000000000000000000000000000000000000000019999991999999911991199119999999
|
||||||
00044444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000019999991111111111111111111111111
|
00044444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000019999991111111111111111111111111
|
||||||
44444444444004444444444444400444444444444440044444444444444004444444444444400444444444444440044444444444444004444444444444400444
|
44444444444004444444444444400444444444444440044444444444444004444444444444400444444444444440044444444444444004444444444444400444
|
||||||
@ -2206,7 +2207,7 @@ __label__
|
|||||||
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
|
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
|
||||||
|
|
||||||
__gff__
|
__gff__
|
||||||
000000c0c0c0c0c0c0c0c0c0c0c00000000000c0c0c0c0c0c0c0c0c0202020200040c0c0c0c0c0c0c008080800000000404000000000080808080808c0c0c0c000000000080808080808080800000008000000000808080808080808000000000008080808080808080808080000000000080808080808080808080800000000
|
000000c0c0c0c0c0c0c0c0c0c0c00000000000c0c0c0c0c0c0c0c0c0202020200040c0c0c0c0c0c0c008080800000000404000000808080808080808c0c0c0c000000000080808080808080800000008000000000808080808080808000000000008080808080808080808080000000000080808080808080808080800000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
__map__
|
__map__
|
||||||
0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d1203040404050d0d0d0d010d0d0d0d0d0d0d0d0d0d0d0d0d0d120d0d0d0d0d0d0d0d0d0d0d0d0d03043e0a040404050d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d
|
0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d1203040404050d0d0d0d010d0d0d0d0d0d0d0d0d0d0d0d0d0d120d0d0d0d0d0d0d0d0d0d0d0d0d03043e0a040404050d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d
|
||||||
|
Reference in New Issue
Block a user