Skip to content

Instantly share code, notes, and snippets.

@omgmog
Last active February 5, 2019 19:51
Show Gist options
  • Save omgmog/5a2fe867a3f954e65ab16a9fa653a50c to your computer and use it in GitHub Desktop.
Save omgmog/5a2fe867a3f954e65ab16a9fa653a50c to your computer and use it in GitHub Desktop.
example of outline text and sprites, and also palette swapping...
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
function _init()
_t=0
sprites={1,2,3,4}
end
function _update()
_t+=1
end
function _draw()
cls(1)
outline("hello",64,48,12,8)
outline({sprites[flr(_t/8)%#sprites+1],6},64,64,10,8)
outline({sprites[flr(_t/8)%#sprites+1],6},72,72)
outline({sprites[flr(_t/8)%#sprites+1],6},80,80,12)
end
-- takes:
-- what = string | object
-- if it's an object:
-- {sprite_index, base_color}
function outline(what,x,y,f,b)
local f = f or 7 -- white
local b = b or 0 -- black
if type(what) == "string" then
-- string outline
for i=-1,1 do
for j=-1,1 do
print(what,x+i,y+j,b)
end
end
print(what,x,y,f)
else
-- sprite outline
pal(what[2],b)
for i=-1,1 do
for j=-1,1 do
spr(what[1],x+i,y+j)
end
end
pal(what[2],f)
spr(what[1],x,y)
pal()
end
end
__gfx__
00000000000000000006060000000000000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000606000066660000060600006666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700006666000006066600666600000606660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000606660006666600060666000666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000060666660060000000066666060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700660000000660660006600000660666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000660666060660660006606600660666060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000006006000006600000600600000660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@omgmog
Copy link
Author

omgmog commented Feb 5, 2019

2019-02-05_19-50-18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment