forked from pyrex/chameleonic
Reorient head based on tongue angle
This commit is contained in:
parent
047f180632
commit
823b3edc30
@ -424,6 +424,10 @@ function level:can_move(
|
|||||||
if self:mcoll(mx0+dmx,my0+dmy) then
|
if self:mcoll(mx0+dmx,my0+dmy) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if player.x==mx0+dmx and player.y==my0+dmy then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- todo: check tongue collision
|
-- todo: check tongue collision
|
||||||
if player.rope then
|
if player.rope then
|
||||||
@ -588,6 +592,10 @@ function player:update()
|
|||||||
local rx,ry=self:_rope_pos()
|
local rx,ry=self:_rope_pos()
|
||||||
self.rope:drag_dst(rx,ry)
|
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
|
if self.rope:done() then
|
||||||
self.rope=nil
|
self.rope=nil
|
||||||
add(self.todo,{})
|
add(self.todo,{})
|
||||||
@ -1214,6 +1222,23 @@ end
|
|||||||
-->8
|
-->8
|
||||||
-- moved here because it's complicated
|
-- 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()
|
function rope:tug()
|
||||||
self:_make_consistent()
|
self:_make_consistent()
|
||||||
if (self.under_destruction) return
|
if (self.under_destruction) return
|
||||||
|
Loading…
Reference in New Issue
Block a user