Doom Fire in PICO-8
Figure 1: Doom Fire from PSX implemented in PICO-8
PICO-8 was recently updated and that inspired me to get back into it. I wanted to port my favorite 2D graphics effects, the fire effect from the title screen of the PSX version of DOOM. Of course, I need to mention the very helpful guide to this effect written by Fabien Sanglard. You can checked out the HTML export of this PICO-8 port here.
It had been a year since I had written any Lua and the process of porting this effect from my C implementation was a little tricky. Many early iterations of this performed quite terribly. The limitations of PICO-8 requirement me to change the height of the effect as well as the color depth. That being said, I am happy with how it turned out.
pico-8 cartridge // http://www.pico-8.com version 27 __lua__ -- DOOMFIRE -- by Adam Richardson function _init() fw = 128 fh = 48 psize = 5 pixels = {} for x=0,fw do for y=0,fh do pixels[idx_xy(x,y)]=0 end end for x=0,fw-1 do pixels[idx_xy(x,fh-1)]=psize end colors = { 0, 8, 9, 10, 7, } print("doom fire", 44, 40) end function idx_xy(x,y) return y*fw+x end function spread(src) local p = pixels[src] if(p==0) then pixels[src-fw]=0 else local r = band(rnd(3),3) local dst = src - r + 1 pixels[dst-fw] = p-band(r,1) end end function _update() for x=0,fw-1 do for y=1,fh-1 do spread(idx_xy(x,y)) end end end function _draw() local offset=128-fh for x=0,fw-1 do for y=0,fh-1 do pset(x,y+offset,colors[pixels[idx_xy(x,y)]]) end end rectfill(0,0,128,10,0) print(stat(1),0,2,7) end