Log In  

Two functions to draw outlined sprites (with some help from kreyk29!)

Regular version that does smooth outlines:

function outspr(sp,x,y,w,h,flpx,flpy,out)
 for c=0,15 do
  pal(c,out)
 end
 spr(sp,x+1,y,w,h,flpx,flpy)
 spr(sp,x-1,y,w,h,flpx,flpy)
 spr(sp,x,y+1,w,h,flpx,flpy)
 spr(sp,x,y-1,w,h,flpx,flpy)
 pal()
 spr(sp,x,y,w,h,flpx,flpy)
end

Another version that does square outlines:

function outspr(sp,x,y,w,h,flpx,flpy,out)
 for c=0,15 do
  pal(c,out)
 end
 spr(sp,x-1,y,w,h,flpx,flpy)
 spr(sp,x+1,y,w,h,flpx,flpy)
 spr(sp,x,y+1,w,h,flpx,flpy)
 spr(sp,x,y-1,w,h,flpx,flpy)
 spr(sp,x-1,y-1,w,h,flpx,flpy)
 spr(sp,x+1,y-1,w,h,flpx,flpy)
 spr(sp,x-1,y+1,w,h,flpx,flpy)
 spr(sp,x+1,y+1,w,h,flpx,flpy)
 pal()
 spr(sp,x,y,w,h,flpx,flpy)
end

Example carts:

Cart #watermellon-0 | 2021-06-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Cart #watermellonsquare-0 | 2021-06-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#93545 2021-06-15 15:53 ( Edited 2021-06-17 18:48)

ok

P#108648 2022-03-15 09:48

Yes. This is how people do outlined text, usually. Or you can just use one of those extra renders for a shadow.

Question. Why use all these tokens if you can just add the outline to the sprite itself, or just have a second sprite that's just the outline that you can render on top? Choice highlighting? Status effects?

P#108670 2022-03-15 15:39

@UnitVector using outline function because sprite can fully cover the sprite cell or all of the sprite cells are used

P#108865 2022-03-18 21:52

It works, @Czarlo. What you wrote is one good way to do it. I wrote something recently that could be used in effect for future code if you like:

https://www.lexaloffle.com/bbs/?tid=47010

Actually it would be great if P8SCII had the ability to draw sprites and outlines + shadows additionally. @zep, this would be excellent and help in Tweetcarts. :)

P#108869 2022-03-19 00:32 ( Edited 2022-03-19 02:56)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 18:13:57 | 0.040s | Q:23