From 142c01f516f839d48e292ff115203b3b8f0677c0 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sat, 25 May 2024 14:09:20 +0200 Subject: [PATCH] Update docs for interpLatch --- LUASTUFF.md | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index 96df6b5f8..79e2a2545 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -83,12 +83,37 @@ v.interpolate(false) ``` NOTE: The default tag for `true` is 0. -## v.interpString(true) +## v.interpLatch(true) -Enables string interpolation mode. The next call to a drawing function will have its interpolation offsets -latched and reused for all following draw calls. -Disable with `false` when done. +Enables interpolation offset latching. The next call to a drawing function will have its lerp offsets +saved and reused for all following draw calls. Disable with `false` when done. +Interpolation cannot easily "snap" between two points; latching can help overcome this by manually +setting the lerp offsets. +```lua +v.interpolate(true) +-- X coordinate for the HUD item +-- every so often, this will wrap around to zero +local x = (leveltime*4) % 256 + +-- draw an interpolated patch, but... when X rolls back to zero, +-- the patch will slide all the way across the screen! +v.draw(x, 100, ...) + +-- this is where interpLatch comes into play +-- enable latching, then draw an invisible patch, +-- moving at the same speed as the visible patch +-- the exact coordinates don't matter, it just has to move at the right speed +v.interpLatch(true) +v.draw(leveltime*4, 0, v.cachePatch("K_TRNULL")) + +-- now we can draw the patch again, and when X becomes zero, +-- it'll snap right back without sliding across the screen +v.draw(x, 150, ...) + +-- don't forget to turn off latching! +v.interpLatch(false) +``` When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes. ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields