From 2422c8c8f39a6aac0b76945bb0c7aa4b6a2ab031 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Mon, 20 Apr 2026 16:39:10 -0600 Subject: Bruh --- dyl.p8 | 63 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 26 deletions(-) (limited to 'dyl.p8') diff --git a/dyl.p8 b/dyl.p8 index 671661c..3c20be7 100644 --- a/dyl.p8 +++ b/dyl.p8 @@ -121,36 +121,48 @@ end -- prevent cobblestoning during -- non-manhattan movement --- if only one axis crossed a --- pixel boundary and we're moving --- diagonally enough to notice, --- hold it for a frame so both axes --- can step together. +-- by "lagging" the sprite +-- behind the physical position +-- function update_spritepos(entity) - tx=flr(entity.pos.x) - ty=flr(entity.pos.y) - dx=tx-entity.spritepos.x - dy=ty-entity.spritepos.y - - if dx==0 and dy==0 then return end - - if dx!=0 and dy!=0 then - entity.spritepos.x+=mid(-1,dx,1) - entity.spritepos.y+=mid(-1,dy,1) + --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. + if entity.vel.y==0 or entity.vel.x==0 then + entity.spritepos.x=entity.pos.x + entity.spritepos.y=entity.pos.y return end - vx=abs(entity.vel.x) - vy=abs(entity.vel.y) - ratio=min(vx,vy)/max(vx,vy,0.001) - if ratio>0.4 - and abs(dx)<=1 - and abs(dy)<=1 then - return + nv=normalize(entity.vel) + dx,dy=abs(entity.pos.x-entity.spritepos.x),abs(entity.pos.y-entity.spritepos.y) + + yslow=abs(entity.vel.y)=jerkdelta and xslow + and dy>=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 + pushy=true + elseif yslow and dx>=1 then + pushx=true end - entity.spritepos.x+=mid(-1,dx,1) - entity.spritepos.y+=mid(-1,dy,1) + if pushx then + entity.spritepos.x=entity.pos.x + end + if pushy then + entity.spritepos.y=entity.pos.y + end end suffixes={"ny","","py"} @@ -158,7 +170,6 @@ function update(entity) if entity.vel != nil then integral_vel=vec_scale(entity.vel,step_dt) entity.pos=vec_add(entity.pos,integral_vel) - update_spritepos(entity) dx,dy=entity.vel.x,entity.vel.y @@ -252,7 +263,7 @@ function _init() end -function _update60() +function _update() cls(0) old_step=step_t step_t=time() -- cgit v1.3