diff --git a/chameleonic.p8 b/chameleonic.p8 index 107b3ec..7f2c2a0 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -686,15 +686,10 @@ function player:_fall() end function player:_rope_pos() - local px=self.x*8+self.px - local px2=px+4 - if self.orientx==-1 then - px+=2 - else - px+=6 - end - local py=self.y*8+self.py+2 - local py2=py+1 + local px=self.x*8+self.px+4 + local px2=px + local py=self.y*8+self.py+3 + local py2=py return px,py,px2,py2 end @@ -747,13 +742,13 @@ function player:draw() setpal() spr(16,px+6,py-2,1,1) spr(17,px+1,py,1,1) - if (self.rope and invis_level<=0.25) pal() self.rope:draw() setpal() + if (self.rope and invis_level<=0.25) pal() self.rope:draw(-2,-1) setpal() spr(head,px-3,py-3,1,1) else setpal() spr(16,px-6,py-2,1,1,true) spr(17,px-1,py,1,1,true) - if (self.rope and invis_level<=0.25) pal() self.rope:draw() setpal() + if (self.rope and invis_level<=0.25) pal() self.rope:draw(2,-1) setpal() spr(head,px+3,py-3,1,1,true) end pal() @@ -874,13 +869,15 @@ function rope:_reindex() end end -function rope:draw() +function rope:draw(artificial_dx,artificial_dy) local points,highlight=self:_tug(true) if (self:busy()) 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 + points[#points]={x=points[#points].x+artificial_dx,y=points[#points].y+artificial_dy} + local len=0 for i=1,#points-1 do len+=distance(points[i],points[i+1]) @@ -1400,26 +1397,19 @@ function rope:_tug(hypothetically) local touched={} for i=#ancs-1,2,-1 do - local ops_before_trash=self:_calc_push(ancs[i+1],ancs[i],ancs[i-1],ancs[i-2]) - local ops_after_trash=self:_calc_push(ancs[i-2],ancs[i-1],ancs[i],ancs[i+1]) - local ops_to_do={} + local ops_before_trash,hit_end1=self:_calc_push(ancs[i+1],ancs[i],ancs[i-1],ancs[i-2]) + local ops_after_trash,hit_end2=self:_calc_push(ancs[i-2],ancs[i-1],ancs[i],ancs[i+1]) + local ops_to_do,corners={},{} if #ops_before_trash>0 then ops_to_do=ops_before_trash + corners[i-1]=true else ops_to_do=ops_after_trash - end - - local _is=function(x1,x2) - return x1.mx==x2.mx and x1.my==x2.my - end - - local _caps=function(x,lst) - return #lst>0 and (_is(x,lst[1]) or _is(x,lst[#lst])) + corners[i]=true end local corners={} - if (_caps(ops_to_do[1],ops_before_trash)) corners[i-1]=true - if (_caps(ops_to_do[#ops_to_do],ops_after_trash)) corners[i]=true + if (hit_end1 and hit_end2) corners[i-1],corners[i]=true,true local ops=ops_to_do @@ -1487,7 +1477,7 @@ function rope:_tug(hypothetically) (dmx!=0 and sgn0(pull_dx)!=dmx) or (dmy!=0 and sgn0(pull_dy)!=dmy) or - _vec_ang_diff(pull_anc.x\8-mx0,pull_anc.y\8-my0,dmx,dmy) >= 0.185 or + _vec_ang_diff(pull_anc.x\8-mx0,pull_anc.y\8-my0,dmx,dmy) >= 0.135 or sgn0(mx0-mxa)!= sgn0(mx0+dmx-mxa) or @@ -1538,14 +1528,14 @@ function rope:_calc_push( local mx,dmx if a0.x%8==0 and a0.x>an.x+7 then needs_good_pull=needs_good_pull or af.x>=a1.x - if (needs_good_pull and _ang_diff(pull_ang,0.0)>=0.185) return {} + if (needs_good_pull and _ang_diff(pull_ang,0.0)>=0.165) return {} -- push left mx=(a0.x-1)\8 dmx=-1 elseif a0.x%8==7 and a0.x=0.185) return {} + if (needs_good_pull and _ang_diff(pull_ang,0.5)>=0.165) return {} -- push right mx=(a0.x+1)\8 @@ -1570,7 +1560,7 @@ function rope:_calc_push( local my,dmy if a0.y%8==0 and a0.y>an.y+6 then needs_good_pull=needs_good_pull or af.y>=a1.y - if (needs_good_pull and _ang_diff(pull_ang,0.75)>=0.185) return {} + if (needs_good_pull and _ang_diff(pull_ang,0.75)>=0.135) return {} -- push up my=(a0.y-1)\8 @@ -1578,7 +1568,7 @@ function rope:_calc_push( elseif a0.y%8==7 and a0.y=0.185) return {} + if (needs_good_pull and _ang_diff(pull_ang,0.25)>=0.135) return {} -- push down my=(a0.y+1)\8 @@ -1592,6 +1582,7 @@ function rope:_calc_push( end end + local hit_end=true local ops2={} for o in all(ops) do if not level:mcoll(o.mx,o.my) then @@ -1599,16 +1590,18 @@ function rope:_calc_push( else local crate=level:get_crate(o.mx,o.my) if crate==nil then + hit_end=false break else if not level:can_move(false,o.mx,o.my,o.dmx,o.dmy,0,0) then + hit_end=false break end end add(ops2,o) end end - return ops2 + return ops2,hit_end end function rope:_anchors_simplified() @@ -1821,7 +1814,7 @@ __map__ 0c0000000000000000000000000000410000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c000000000000000c0c0c0c0c0c0c0c0c00000000000020210000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0c0c0c0c0c00000000000c0c0c0c0c0c00000000000030310000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0c00000000000c0c0000000c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0c00000000000c0c004f000c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c00000c4f00000c00000000000000120100000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 3d0000000000003f0c000c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0c0000000000000000000c0c0c0c0c0c0c00000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000