Something went wrong. Try again.
an npmx inspired game for PICO-8 npicomx.vinnymac.dev
games pico-8 adventure npmx
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101-- hazards: flames, fireballs, bird, damage, particles
function hurt(cause) if bf.iv>0 then return end if cause then kill_cause=cause end bf.hp-=1 bf.iv=45 shake=8 dflash=3 frz=3 burst(bf.x,bf.y) sfx(5) if bf.carry then do_drop() endend
function burst(x,y) for i=0,7 do add(embers,{x=x,y=y,vx=cos(i/8)*1.5,vy=sin(i/8)*1.5,t=12}) endend
function poof(x,y) for i=0,5 do add(embers,{x=x,y=y,vx=cos(i/6)*1.1,vy=sin(i/6)*1.1-0.3,t=15,pf=true}) endend
function spawn_imp(x,y) add(embers,{x=x,y=y,vx=rnd(2)-1,vy=-1.8,t=22,imp=true})end
function spawn_bird() bird={on=true,x=min(max(bf.x+80,camx+136),lvw*8-8),y=18+rnd(24),vx=-1.5,vy=0}end
function update_bird() if not bird.on then return end local spd=0.34+diff*0.12 bird.vx=appr(bird.vx,sgn(bf.x-bird.x)*spd,0.04) bird.vy=appr(bird.vy,sgn(bf.y-bird.y)*spd,0.04) bird.x+=bird.vx bird.y+=bird.vy if bf.iv<=0 and ov(bf.x,bf.y,bird.x,bird.y,6,6) then hurt("flame war bird") endend
function draw_bird() if not bird.on then return end pset(bird.x-bird.vx*2.5,bird.y-bird.vy*2.5,9) -- fiery wake pset(bird.x-bird.vx*4,bird.y-bird.vy*4,8) spr(sin(t()*8)>0 and 48 or 49,bird.x-4,bird.y-4,1,1,bird.vx<0)end
function flame_ov(em,bx,by,bw,bh) local u,h=du[em.dir],em.h local x0=min(em.x,em.x+u[1]*h)-u[3]*4 local x1=max(em.x,em.x+u[1]*h)+u[3]*4 local y0=min(em.y,em.y+u[2]*h)-u[4]*4 local y1=max(em.y,em.y+u[2]*h)+u[4]*4 return bx+bw>x0 and bx-bw<x1 and by+bh>y0 and by-bh<y1end
function update_flames() for em in all(ems) do em.h=em.peak*max(0,sin(t()*flrate+em.ph)) if em.h>1 then em.h+=rnd(3) end if (em.douse or 0)>0 then em.h*=max(0,1-em.douse/16) em.douse-=1 end if em.h>7 and bf.iv<=0 and flame_ov(em,bf.x,bf.y,5,4) then hurt("bloat fire geyser") end end for i=1,#sprc do local px,py=fbpos(i) if bf.iv<=0 and ov(bf.x,bf.y,px,py,6,6) then hurt("malware fireball") end endend
function fbpos(i) local c,a=sprc[i],t()*0.5+i*0.3 return c[1]+cos(a)*13,c[2]+sin(a)*13,c,a end -- orbiting fireball pos
function draw_flame_nozzle(em) local x,y=em.x,em.y local d=em.dir if d==0 then -- floor vent, flame up gbox(x-3,y,x+3,y+5) rectfill(x-2,y,x+2,y+4,1) elseif d==1 then -- ceiling vent, flame down gbox(x-3,y-5,x+3,y) rectfill(x-2,y-4,x+2,y,1) end -- left/right nozzles (dir 2/3) removed for tokens. all emitters are up/down only. -- to restore side flames re-add (and du[2]/du[3] in data.lua): -- elseif d==2 then gbox(x,y-3,x+5,y+3) rectfill(x+1,y-2,x+5,y+2,1) -- right wall, flame left -- elseif d==3 then gbox(x-5,y-3,x,y+3) rectfill(x-5,y-2,x-1,y+2,1) -- left wall, flame rightend
function draw_flame(em) local h=em.h if h<2 then return end local cf=lvl==3 and bcol or fcol local u=du[em.dir] local ax,ay,px,py=u[1],u[2],u[3],u[4] -- fire-spark burst behind the flame (was a flat dithered glow circle): sparks fan out -- from the base on a looping cycle, shrinking + cooling hot->red as they fly. for i=1,7 do local p=(t()*1.09+i/7)%1 local a=i/7+em.ph -- ~915ms/cycle (~200ms slower than 1.4) circfill(em.x+ax*h*0.25+cos(a)*p*h*0.6,em.y+ay*h*0.25+sin(a)*p*h*0.6,2.5-p*2,cf(p)) end local sway=t()*2.2+em.ph*6 for d=0,h do local f=d/h local w=sqrt(max(0,1-f))*3+0.4+rnd(0.6) local cv=sin(sway+f)*f*3+rnd(1)-0.5 circfill(em.x+ax*(d+rnd(0.8))+px*cv,em.y+ay*d+py*cv,w,cf(f)) endend