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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118-- win: game over, win & credits
function update_over() if frz>0 then frz-=1 return end upd_aemb() over_t+=1 if over_fade and over_fade<6 then over_fade+=0.08 end if over_t>20 and (btnp(4) or btnp(5)) then init_play() endend
function draw_over() cls(0) drw_aemb() poke(0x5f55,0) rectfill(0,120,37,126,0) print("game over",1,121,1) print("game over",0,120,8) poke(0x5f55,0x60) sspr(0,120,36,7,28,25,72,14) local lns=split(over_phrase,"|",false) for i=1,#lns do pr_c(lns[i],64,44+(i-1)*8,9) end local dy=(#lns-1)*8 if t_out then pr_c("the timer ran out!",64,58+dy,8) elseif kill_cause~="" then pr_c("killed by: "..kill_cause,64,58+dy,8) end pr_c("packages saved: \fb"..saved,68,70+dy,7) if purged>0 then pr_c("demons purged: "..purged,64,80+dy,9) end pr_c("press \151 to try again",64,102,6) if over_fade and over_fade<6 then fadeover(over_fade) endend
function flock(bs) for b in all(bs) do local cx,cy,vx,vy,n=0,0,0,0,0 for o in all(bs) do local dx,dy=o.x-b.x,o.y-b.y local d=dx*dx+dy*dy if o~=b and d<400 then cx+=o.x cy+=o.y vx+=o.vx vy+=o.vy n+=1 if d<144 then b.vx-=dx*0.025 b.vy-=dy*0.025 end end end if n>0 then b.vx+=(cx/n-b.x)*0.002+(vx/n-b.vx)*0.06 b.vy+=(cy/n-b.y)*0.002+(vy/n-b.vy)*0.06 end b.vx=mid(0.2,b.vx,1) b.vy=mid(-0.5,b.vy,0.5) b.x+=b.vx b.y+=b.vy b.y=mid(26,b.y,94) if b.x>134 then b.x=-6 b.y=40+rnd(30) end endend
function mk_birds() wbirds={} for _=1,6 do add(wbirds,{x=rnd(120),y=40+rnd(36),vx=0.3+rnd(0.3),vy=rnd(0.4)-0.2}) endend
function show_credits() mk_birds() cred_ret=scr wt=0 scr=4 music(4)end
function start_win() dset(1,dget(1)+saved) -- slot 1: lifetime packages rescued dset(2,dget(2)+purged) -- slot 2: lifetime demons cleansed dset(3,dget(3)+1) -- slot 3: total wins if dget(3)>=3 then menuitem(1,skin_label(),tog_skin) end if timed and (dget(0)==0 or playt<dget(0)) then dset(0,playt) end sfx(7) show_credits() cred_ret=nil -- a WIN returns to the title, NOT the play screen we won onend
function update_win() wt+=1 flock(wbirds) if wt>105 and (btnp(4) or btnp(5)) then -- skippable once the block has eased in local r=cred_ret or 1 cred_ret=nil scr=r music(r==2 and 0 or 9) -- back to title -> intro drone endend
function draw_win() cls(12) grad(0,30,7,12) -- sunrise: white→cyan at top grad(115,128,12,1) -- thin dark edge at screen bottom fire_sun(104,14) cloud((wt*0.1)%188-30,56) cloud((-wt*0.08+120)%188-30,92) for b in all(wbirds) do vbird(b.x,b.y,1) end -- balloon: slow rise, then a very gentle drift (its own path) local rx=64+sin(wt*0.0028)*34 local ry=lerp(150,54,eio(clmp(wt/300)))+sin(wt*0.006)*4 draw_balloon(rx,ry) -- butterfly: its OWN slow wandering path, decoupled from the balloon local bx=64+sin(wt*0.0042)*48 local by=64+sin(wt*0.0067+0.25)*26 pal2(1) sspr(bf_sx(6),0,16,16,bx-10,by-10,20,20) pal() -- butterfly-shaped halo pal2(1) spr(bf_idx(6),bx-7,by-7,2,2) pal() spr(bf_idx(6),bx-8,by-8,2,2) -- credits roll: ease up & hold ~10s, then scroll the block away, leaving press-x local app=eio(clmp((wt-45)/60)) -- ease in (1.5s..3.5s) local out=eio(clmp((wt-405)/75)) -- scroll out after a 10s hold (13.5s..16s) if app>0 then local yo=lerp(150,24,app)-out*150 -- block top: eases to y24, then scrolls up off ptc("congratulations!",64,yo,10,2) ptc("npicomx",64,yo+9,7) ptc("a butterfly rescue by vinnymac",64,yo+24,7) ptc("special thanks to the npmx team",64,yo+32,7) local cy=yo+47 pr_c("\0021you saved \fb"..dget(1).."\f7 packages",76,cy,7) cy+=9 if dget(2)>0 then pr_c("\0021\fb"..dget(2).."\f7 demons cleansed",76,cy,7) cy+=9 end if dget(0)>0 then pr_c("\0021best time \fb"..fmt_time(dget(0)\30).."\f7",76,cy,7) cy+=9 end pr_c("\0021\fb"..dget(3).."\f7 wins",76,cy,7) end local pin=eio(clmp((wt-450)/60)) -- press-x eases in as the block leaves if pin>0 then ptc("press \151 to play again",64,lerp(80,64,pin),7) endend