From 3555b9ff88c3872c8f2dd8a8ab02382e2a7d0cb2 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Tue, 21 Apr 2026 12:41:00 -0700 Subject: mov --- dyl.p8 | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'dyl.p8') diff --git a/dyl.p8 b/dyl.p8 index 3c20be7..95f2e59 100644 --- a/dyl.p8 +++ b/dyl.p8 @@ -40,7 +40,7 @@ sword={ player={ id=next_id(), typ=types.player, - pos={x=10,y=10}, + pos={x=50,y=50}, spritepos={x=10,y=10}, vel={x=0,y=0}, los={x=1,y=0}, -- lineofsight @@ -125,9 +125,6 @@ end -- behind the physical position -- function update_spritepos(entity) - --entity.spritepos.x=entity.pos.x - --entity.spritepos.y=entity.pos.y - -- step in only x or y. -- we can snap to the grid -- without cobblestoning. @@ -138,30 +135,35 @@ function update_spritepos(entity) end nv=normalize(entity.vel) - dx,dy=abs(entity.pos.x-entity.spritepos.x),abs(entity.pos.y-entity.spritepos.y) + dx,dy=entity.pos.x-entity.spritepos.x,entity.pos.y-entity.spritepos.y + adx,ady=abs(dx),abs(dy) yslow=abs(entity.vel.y)=jerkdelta and xslow - and dy>=1 then + jerkdelta=1 + if adx>=jerkdelta and xslow + and ady>=1 then + pushx,pushy=true,true + elseif ady>=jerkdelta and yslow + and adx>=1 then pushx,pushy=true,true - elseif dy>=jerkdelta and yslow - and dx>=1 then - pushx,pushy=true,true - elseif xslow and dy>=1 then + elseif xslow and ady>=1 then pushy=true - elseif yslow and dx>=1 then + elseif yslow and adx>=1 then pushx=true end if pushx then - entity.spritepos.x=entity.pos.x + func=flr + if dx<0 then func=ceil end + entity.spritepos.x=entity.spritepos.x+func(dx) end if pushy then - entity.spritepos.y=entity.pos.y + func=flr + if dy<0 then func=ceil end + entity.spritepos.y=entity.spritepos.y+func(dy) end end -- cgit v1.3