forked from pyrex/chameleonic
Compare commits
3 Commits
78f0a96529
...
49284d44a8
Author | SHA1 | Date | |
---|---|---|---|
49284d44a8 | |||
b2dbd9ec60 | |||
cb36faac23 |
@ -656,7 +656,10 @@ end
|
|||||||
|
|
||||||
-- argument is a rope operation:
|
-- argument is a rope operation:
|
||||||
-- array of [mx0,my0,dmx,dmy]
|
-- array of [mx0,my0,dmx,dmy]
|
||||||
function level:tug_crate(t)
|
-- must be a free function
|
||||||
|
-- to use as a foreach target
|
||||||
|
function level_tug_crate(t)
|
||||||
|
local self=level
|
||||||
local mx0,my0,dmx,dmy=unpack(t)
|
local mx0,my0,dmx,dmy=unpack(t)
|
||||||
local mxy0=_mix{mx0,my0}
|
local mxy0=_mix{mx0,my0}
|
||||||
local existing=self._crates[mxy0]
|
local existing=self._crates[mxy0]
|
||||||
@ -1557,7 +1560,7 @@ function rope:_tug(hypothetically)
|
|||||||
|
|
||||||
if #ops>0 then
|
if #ops>0 then
|
||||||
if (hypothetically) return ancs,i-1,ops,blocks
|
if (hypothetically) return ancs,i-1,ops,blocks
|
||||||
foreach(ops, level:tug_crate)
|
foreach(ops, level_tug_crate)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1610,7 +1613,7 @@ function rope:_tug(hypothetically)
|
|||||||
if level:can_move(false,mv,1,0) then
|
if level:can_move(false,mv,1,0) then
|
||||||
if (hypothetically) return ancs,0,{mv},blocks
|
if (hypothetically) return ancs,0,{mv},blocks
|
||||||
|
|
||||||
level:tug_crate(mv)
|
level_tug_crate(mv)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
add(blocks, mv)
|
add(blocks, mv)
|
||||||
@ -1643,21 +1646,16 @@ function rope:_calc_push(
|
|||||||
smy=-smy
|
smy=-smy
|
||||||
end
|
end
|
||||||
|
|
||||||
local mx,dmx
|
local dmx=1 -- maybe push right?
|
||||||
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
|
||||||
mx=ax0-1
|
ax0, dmx=ax0-1,-1
|
||||||
dmx=-1
|
elseif anch.adx!=1 or a0.x>=an.x-7 then
|
||||||
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,{mx,my,dmx,0})
|
add(ops,{ax0,my,dmx,0})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1669,30 +1667,24 @@ function rope:_calc_push(
|
|||||||
smx=-smx
|
smx=-smx
|
||||||
end
|
end
|
||||||
|
|
||||||
local my,dmy
|
local dmy=1 -- maybe push down?
|
||||||
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
|
||||||
my=ay0-1
|
ay0,dmy=ay0-1,-1
|
||||||
dmy=-1
|
elseif anch.ady!=1 or a0.y>=an.y-6 then
|
||||||
|
|
||||||
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,my,0,dmy})
|
add(ops,{mx,ay0,0,dmy})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ops2,blocked={},{}
|
local ops2,blocked={},{}
|
||||||
for o in all(ops) do
|
for o in all(ops) do
|
||||||
local mx,my=unpack(o)
|
local mx,my=unpack(o)
|
||||||
if level:mcoll(mx,my)
|
if level:mcoll(mx,my) then
|
||||||
if not (level:get_crate(mx, my)) break
|
if (not level:get_crate(mx, my)) break
|
||||||
if not level:can_move(false,o,0,0) then
|
if not level:can_move(false,o,0,0) then
|
||||||
add(blocked,o)
|
add(blocked,o)
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user