forked from pyrex/chameleonic
pull changes from upstream #4
@ -424,6 +424,10 @@ function level:can_move(
|
||||
if self:mcoll(mx0+dmx,my0+dmy) then
|
||||
return false
|
||||
end
|
||||
|
||||
if player.x==mx0+dmx and player.y==my0+dmy then
|
||||
return false
|
||||
end
|
||||
|
||||
-- todo: check tongue collision
|
||||
if player.rope then
|
||||
@ -588,6 +592,10 @@ function player:update()
|
||||
local rx,ry=self:_rope_pos()
|
||||
self.rope:drag_dst(rx,ry)
|
||||
|
||||
local tdx,tdy=self.rope:tug_orientxy()
|
||||
if (tdx!=0) self.orientx=tdx
|
||||
if (tdy!=0) self.orienty=tdy
|
||||
|
||||
if self.rope:done() then
|
||||
self.rope=nil
|
||||
add(self.todo,{})
|
||||
@ -1214,6 +1222,23 @@ end
|
||||
-->8
|
||||
-- moved here because it's complicated
|
||||
|
||||
function rope:tug_orientxy()
|
||||
local a1=self:_anc(#self.ancs+1)
|
||||
local a0=self:_anc(#self.ancs)
|
||||
local dx=a0.x-a1.x
|
||||
local tdx=0
|
||||
if (dx>3) tdx=1
|
||||
if (dx<-3) tdx=-1
|
||||
|
||||
local dy=a0.y-a1.y
|
||||
local tdy=0
|
||||
if abs(dy)>abs(dx)/2 then
|
||||
if (dy>3) tdy=1
|
||||
if (dy<-3) tdy=-1
|
||||
end
|
||||
return tdx,tdy
|
||||
end
|
||||
|
||||
function rope:tug()
|
||||
self:_make_consistent()
|
||||
if (self.under_destruction) return
|
||||
|
Loading…
Reference in New Issue
Block a user