Log In  


I find the syntax of sspr involves too much work, so I wrote a wrapper function that requires less arguments and less thinking.

Ladies and gentlemen... zspr

Arguments:
--n: standard sprite number
--w: number of sprite blocks wide to grab
--h: number of sprite blocks high to grab
--dx: destination x coordinate
--dy: destination y coordinate
--dz: destination scale/zoom factor

function zspr(n,w,h,dx,dy,dz)
  sx = 8 * (n % 16)
  sy = 8 * flr(n / 16)
  sw = 8 * w
  sh = 8 * h
  dw = sw * dz
  dh = sh * dz

  sspr(sx,sy,sw,sh, dx,dy,dw,dh)
end

Please let me know if you find it useful.

11


this function is actually slightly incorrect

sx = (n % 16)
sy = flr(n/16)

sx = 8
sy
= 8


thanks for the fix!


Here's something for a flipping change!

--https://www.lexaloffle.com/bbs/?tid=2429
function zspr(n,w,h,dx,dy,dz,fx,fy)
local sx = 8 (n % 16)
local sy = 8
flr(n / 16)
local sw = 8 w
local sh = 8
h
local dw = sw dz
local dh = sh
dz
sspr(sx,sy,sw,sh,dx,dy,dw,dh,fx,fy)
end


Nice!


Re-posting @acepek's version in a code block, as otherwise the formatting breaks it! 😉

--https://www.lexaloffle.com/bbs/?tid=2429
function zspr(n,w,h,dx,dy,dz,fx,fy)
 local sx = 8 * (n % 16)
 local sy = 8 * flr(n / 16)
 local sw = 8 * w
 local sh = 8 * h
 local dw = sw * dz
 local dh = sh * dz
 sspr(sx,sy,sw,sh,dx,dy,dw,dh,fx,fy)
end

1

too slow/too many tokens! - suggest to remove all unnecessary variables!


Nice job, Matt ! That's a good way of addressing larger sprites with an 8x8 grid in mind. A whole lot easier. And the code is simpler to understand the way you wrote it. Clarity is always a fine thing to have. :)

Gold star for you.


2

Freds is right, just put it all inline!

function zspr(n,w,h,dx,dy,dz,fx,fy)
 sspr(8*(n%16),8*flr(n/16),8*w,8*h,dx,dy,8*w*dz,8*h*dz,fx,fy)
end

Thank you so much for this. Its amazing.



[Please log in to post a comment]