Prevent highlight flicker for rope

This commit is contained in:
Pyrex 2022-12-18 18:41:17 -08:00
parent 8d37dbef80
commit 14e37ba9dd

View File

@ -579,6 +579,14 @@ function player:update()
-- todo: other anim stuff
xs[#xs].px=0
xs[#xs].py=0
xs[1].update=function(s)
if (s.rope) s.rope:prevent_highlight(true)
return true
end
xs[#xs].update=function(s)
if (s.rope) s.rope:prevent_highlight(false)
return true
end
return xs
end
@ -871,7 +879,7 @@ end
function rope:draw(artificial_dx,artificial_dy)
local points,highlight=self:_tug(true)
if (self:busy()) highlight=nil
if (self:busy() or self._prevent_highlight) highlight=nil
if (self.state.name=="done") return
local perc_to_show=1.0
if (self.state.name=="destroy") perc_to_show=(1.0-self.state.frame/5)^2
@ -1392,6 +1400,15 @@ function rope:tug()
self:_tidy_up_gen()
end
function rope:prevent_highlight(prevent)
if prevent then
local points,highlight=self:_tug(true)
if (self:busy() or highlight==nil) self._prevent_highlight=true
else
self._prevent_highlight=false
end
end
function rope:_tug(hypothetically)
local ancs=self:_anchors_simplified()
local touched={}