Log In  

A cart that allows you to make sprites compatible with ESPR()

Cart #espr_maker-0 | 2021-07-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4


So basically I made a function to add sprites beyond PICO-8's 128 by 128 sprite sheet. Feel free to use this function with credit.

function espr(data,x,y,w,h,flp_x,flp_y)
 --[[
 data is a list of all the
 pixels that make a sprite

 the sprites are 8 by 8 pixels

 this function can be used
 for easily adding new sprites
 into the game
 ]]

 list=split(tostr(data))

 w=w or 8
 h=h or (count(list)/8)

 x=x or 0
 y=y or 0

 local val=0

 local backup={}

 repeat
  add(backup,sget(val%w,val/w))
  val+=1
 until val==h*w
 for pnum,p in pairs(list) do
  pnum-=1
  if (pnum/w)<h then
   if p~=16 then sset(pnum%w,pnum/w,p) end
  end
 end
 sspr(0,0,w,h,x,y,w,h,flp_x,flp_y)
 for pnum,p in pairs(backup) do
  pnum-=1
  if pnum<=w*h then
   sset(pnum%w,pnum/w,p)
  end
 end
end

So, for example, if I do this:

espr("12,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,12",0,0,17,2)

It will output this:

P#94122 2021-06-27 03:06 ( Edited 2021-08-06 15:13)

Can you explain more how to use this? Where does the function "add" or "output" sprites?

If you’re open for some optimization ideas:

  • use hex notation for colours rather than decimal
  • pack two pixels in one byte
P#94178 2021-06-28 14:35

alright, so basically it's just spr() except, instead of there being a sprite number, it's just a string of values that make up the sprite. the values are separated by commas and go from left to right, and up to down.

P#94230 2021-06-30 01:22 ( Edited 2021-06-30 01:25)

Ah I see! You’re copying the value to spritesheet then restoring the original. Thanks for the reply.

One could make a small sprite editor that prints out data as hex numbers + a poke4 call (more efficient than sset), and the restore step could also be a simple 'reload'.

P#94234 2021-06-30 03:49

I made a cart that allows you to make Extra Sprites @merwok

P#94314 2021-07-01 21:23

I don’t get how that message replies or addresses the ideas in my last message.

P#96179 2021-08-18 13:42

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 06:31:52 | 0.021s | Q:21