From 14e37ba9dd4877f2348bf6a8ea4bb71e5536c71e Mon Sep 17 00:00:00 2001 From: Nyeogmi Date: Sun, 18 Dec 2022 18:41:17 -0800 Subject: [PATCH] Prevent highlight flicker for rope --- chameleonic.p8 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index e21d16a..022ce99 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -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={}