main #21

Closed
kistaro wants to merge 76 commits from main into some_level
Showing only changes of commit 15a9ac5c2e - Show all commits

View File

@ -910,17 +910,12 @@ function rope:update()
if (not self.latch) wrongbleep:bleep(5) self:destroy() return if (not self.latch) wrongbleep:bleep(5) self:destroy() return
if self.latch.rec then if self.latch.rec then
self:drag_src{
self.latch.rec.mx+0.5+self.latch.ax_offset,
self.latch.rec.my+0.5+self.latch.ay_offset
}
if self.latch.rec.dead==true then if self.latch.rec.dead==true then
self:destroy() self:destroy()
end end
end end
if (not self:_check_sane()) self:destroy() if (not self:_check_pinch()) self:destroy()
elseif self.state.name=="destroy" then -- destroy elseif self.state.name=="destroy" then -- destroy
self.state.frame+=1 self.state.frame+=1
@ -1047,27 +1042,24 @@ function rope:draw(artificial_px,artificial_py)
while true do while true do
if (n1==nil) break if (n1==nil) break
local anch=level:anchor_at(n1) local anch=level:anchor_at(n1)
local x=n1.ax*8 local ax,ay=_anch_unpack(n1)
local y=n1.ay*8 local x=ax*8
local y=ay*8
if anch then if anch then
if (anch.adx>0) x-=1 if (anch.adx>0) x-=1
if (anch.ady>0) y-=1 if (anch.ady>0) y-=1
end end
rectfill(x-1,y-1,x+1,y+1,12) rectfill(x-1,y-1,x+1,y+1,12)
print("ax="..n1.ax..",ay="..n1.ay,72,sy) print("ax="..ax..",ay="..ay,72,sy)
sy+=7 sy+=7
local n0=n1.prev local n0=n1.prev
local n2=n1.next local n2=n1.next
if n0!=nil and n2!=nil then if n0!=nil and n2!=nil then
if anch then if anch then
local _,_,_=would_stick(anch,n0.ax,n0.ay,n1.ax,n1.ay,n2.ax,n2.ay) rectfill(x+2,y+2,x+4,y+4,3)
local c=3
if (anch.dropped) c=4
rectfill(x+2,y+2,x+4,y+4,c)
else else
rectfill(x+2,y+2,x+4,y+4,2) rectfill(x+2,y+2,x+4,y+4,2)
end end
else else
rectfill(x+2,y+2,x+4,y+4,4) rectfill(x+2,y+2,x+4,y+4,4)
@ -1077,24 +1069,21 @@ function rope:draw(artificial_px,artificial_py)
end end
for _,p in pairs(level._anch) do for _,p in pairs(level._anch) do
local x,y=p.ax*8,p.ay*8 local ax,ay=_anch_unpack(p)
local x,y=ax*8,ay*8
if (p.adx>0) x-=1 if (p.adx>0) x-=1
if (p.ady>0) y-=1 if (p.ady>0) y-=1
pset(x,y,11) pset(x,y,11)
pset(x+p.adx,y,11) pset(x+p.adx,y,11)
pset(x,y+p.ady,11) pset(x,y+p.ady,11)
end end
]] ]]
end end
function rope:drag_dst(xy) function rope:drag_dst(xy)
self:drag(self.dst,xy) self:drag(self.dst,xy)
end end
function rope:drag_src(xy)
self:drag(self.src,xy)
end
function rope:drag(n1,axy) function rope:drag(n1,axy)
self:relax() self:relax()
self:_drag(n1,{axy[1],n1[2]}) self:_drag(n1,{axy[1],n1[2]})
@ -1131,7 +1120,7 @@ function rope:relax()
end end
end end
function rope:_check_sane() function rope:_check_pinch()
if (not self:latched()) return true if (not self:latched()) return true
if (level:busy()) return true if (level:busy()) return true
@ -1233,8 +1222,18 @@ function would_stick(anchor,xy0,xy1,xy2)
end end
function rope:experience_anchor_moves(moves) function rope:experience_anchor_moves(moves)
local latch=self.latch
self:_be_dragged_by(moves) self:_be_dragged_by(moves)
self:_be_pushed_by(moves) self:_be_pushed_by(moves)
if latch.rec then
self:_drag(self.src,{
latch.rec.mx+0.5+latch.ax_offset,
latch.rec.my+0.5+latch.ay_offset
})
end
self:relax() self:relax()
end end