From 4987e71debba80f63c8928a21c2c0f670341175b Mon Sep 17 00:00:00 2001 From: Nyeogmi Date: Fri, 30 Dec 2022 23:09:38 -0800 Subject: [PATCH] Shorten rope drawing code --- chameleonic.p8 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index eece9d8..a825aa9 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -958,16 +958,18 @@ function rope:draw(artificial_px,artificial_py) if from_end then x,y=x+dx-dx*coef,y+dy-dy*coef - dx,dy=dx*coef,dy*coef - else - dx,dy=dx*coef,dy*coef end + dx,dy=dx*coef,dy*coef colorh(i) - linefill(x,y,x+0.25*dx,y+0.25*dy,1.0) - linefill(x+0.25*dx,y+0.25*dy,x+1*dx,y+1*dy,0.5) - linefill(x+0.9*dx,y+0.9*dy,x+dx,y+dy,1.0) + local function lf(d0,d1,w) + linefill(x+d0*dx,y+d0*dy,x+d1*dx,y+d1*dy,w) + end + + lf(0,0.25,1.0) + lf(0.25,1,0.5) + lf(0.9,1,1.0) circfill(x+dx+0.5,y+dy+0.5,1.0) end end