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.

P#13797 2015-09-07 18:20 ( Edited 2016-06-27 20:03)

this function is actually slightly incorrect

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

sx = 8
sy
= 8

P#14059 2015-09-12 13:45 ( Edited 2015-09-12 17:45)

thanks for the fix!

P#21106 2016-05-22 17:45 ( Edited 2016-05-22 21:45)

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

P#23750 2016-06-27 12:14 ( Edited 2016-06-27 16:14)

Nice!

P#23758 2016-06-27 16:03 ( Edited 2016-06-27 20:03)

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
P#71526 2019-12-30 12:23
1

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

P#71528 2019-12-30 13:55

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.

P#71534 2019-12-30 17:12 ( Edited 2019-12-30 18:26)
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
P#71544 2019-12-30 18:23

Thank you so much for this. Its amazing.

P#77215 2020-05-26 03:06

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 21:59:20 | 0.012s | Q:26