0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3000000000000000000000000000000­<»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»™™™™™™™™™™™™™™™™™™™™™™™™™™ªªªª™™™™ªªªª™™™™ªªªª™™™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªª™™™™™™ªªªªªª™™ªªªª™™™™™™ªªªªªª™™ªªªª™™™™™™ªªªªªª™™ªªªª™™™™™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™™™ªªªªªª™™ªªªª™™ªªªªªª™™™™™™ªªªªªª™™ªªªª™™ªªªªªª™™™™™™ªªªªªª™™ªªªª™™ªªªªªª™™™™™™ªªªªªª™™ªªªª™™ªªªªªª™™™™™™ªª™™ªªªªªª™™ªªªª™™ªªªª™™ªª™™ªªªªªª™™ªªªª™™ªªªª™™ªª™™ªªªªªª™™ªªªª™™ªªªª™™ªª™™ªªªªªª™™ªªªª™™ªªªª™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªªªª™™™™ªªªª™™ªªªªªª™™ªª™™™™ªªªª™™ªªªªªª™™ªª™™™™ªªªª™™ªªªªªª™™ªª™™™™ªªªª™™ªªªªªª™™ªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªªªª™™ªªªªªª™™ªª™™ªªªª™™ªªªªªª™™ªªªª™™ªªªª™™ªªªªªª™™ªªªª™™ªªªªªª™™ªªªª™™ªªªªªª™™ªªªª™™ªª™™™™ªªªª™™ªªªª™™™™™™ªªªª™™ªªªª™™™™™™ªªªª™™ªªªª™™™™™™ªªªª™™ªªªª™™™™™™™™™™™™™™™™™™™™™™™™™™»»°»»»° ° » »»°»°» °» » »» ° » » »» »» °»»»» » » »° » » » » ° »»» ° ° » » » »»»» » » »» » °» » » ° ° » » »»°»»»»»» » ° »»°»» » °»» °»f``f`ff``f````ff```f`f`fff`f`f`fff```f```f`f`f`f```f`f`f``f``````ff``f``f`ff```f`ff`ff`f`fff`f`f`fff•-- title: Boink -- author: Feral Goat -- desc: Fend off riot police and gather more student protestors -- site: website link -- license: MIT License -- version: 0.1 -- script: lua -- Prints text where x is the center of text -- https://github.com/nesbox/TIC-80/wiki/print function printc(s,x,y,c,scale) local scale=scale or 1 w=print(s,0,-50,15,false,scale) print(s,x-(w/2),y,c or 15,false,scale) end -- Code examples and snippets · nesbox/TIC-80 Wiki · GitHub -- https://github.com/nesbox/TIC-80/wiki/code-examples-and-snippets#palette-swapping -- swap c0 and c1 colors, call pal() to reset function palswap(c0,c1) if(c0==nil and c1==nil)then for i=0,15 do poke4(0x3FF0*2+i,i)end else poke4(0x3FF0*2+c0,c1)end end function init() mode="title" displayWait=30 wave=1 protestors= { l={116,128,140,104,92,80,152,68}, -- X locations h={1,2,6,10,8,10,11,12}, -- Hair colors s={14,15,12,11,10,9,8,6}, -- Skin colors c=5, -- Count d={}, -- Definitions } t=0 w=0 levels= { -- Width, Height, Protestors, Delay {w=3,h=2,p=5,d=30},-- 1 {w=4,h=2,p=4,d=30},-- 2 {w=3,h=3,p=3,d=30},-- 3 {w=4,h=3,p=2,d=20},-- 4 {w=5,h=3,p=1,d=10},-- 5 } screen= { w=240, h=136, } end init() function addP() local l=table.remove(protestors.l,math.random(1,#protestors.l)) local h=table.remove(protestors.h,math.random(1,#protestors.h)) local s,i=-1,-1 repeat i=math.random(1,#protestors.s) s=protestors.s[i] until (s~=h) table.remove(protestors.s,i) table.insert(protestors.d,{l=l,h=h,s=s}) end function removeP() local d=table.remove(protestors.d) table.insert(protestors.l,d.l) table.insert(protestors.h,d.h) table.insert(protestors.s,d.s) end function loadLevel() t=0 w=0 level=levels[wave] protestors.c=level.p screen.xoffset=screen.w/(level.w+1) screen.yoffset=screen.h/(level.h+1) score=0 f=0 -- Flashing text counter state= { n="", -- State Name w=30, -- Wait s={}, -- Active Spot c=0, -- Count q="", -- The next status } update=0 addTotal=0 nx=level.w//2 ny=level.h//2 b=0 shake=0 max=level.w*level.h board={} run=0 for i=1,level.h do r={} for j=1,level.w do -- w=window, h=head table.insert(r,{w=0,h=0,hit=0,point=false,counted=false}) end table.insert(board,r) end delay=60 for i=1,#protestors.d do removeP() end for i=1,protestors.c do addP() end end function TIC() if mode=="title" then if displayWait>0 then displayWait=displayWait-1 elseif btn(0) or btn(1) or btn(2) or btn(3) or btn(4) or btn(5) or btn(6) or btn(7) then mode="wave" loadLevel() end cls() print("BOINK",(screen.w-116)/2,8,11,false,4) -- spr(id x y colorkey=-1 scale=1 flip=0 rotate=0 w=1 h=1) spr(102, (screen.w-64)/2,30,-1,4,1,0,2,2) if t%75==0 then f=10 end if f>0 then f=f-1 else print("- Press Any Button -",(screen.w-108)//2,106,11) end printc("v0.1 By Feral Goat",screen.w//2,screen.h-12,6) elseif mode=="wave" then cls() printc("Wave "..wave,screen.w/2,screen.h/2,11,2) if delay>0 then delay=delay-1 else mode="level" delay=30 end elseif mode=="wave-over" then printc("Wave Complete",screen.w/2,screen.h/2,0,2) if displayWait>0 then displayWait=displayWait-1 elseif btn(0) or btn(1) or btn(2) or btn(3) or btn(4) or btn(5) or btn(6) or btn(7) then wave=wave+1 if wave>#levels then mode="win" displayWait=30 else loadLevel() mode="wave" delay=30 end end elseif mode=="game-over" then printc("Game Over",screen.w/2,screen.h/2,0,2) if displayWait>0 then displayWait=displayWait-1 elseif btn(0) or btn(1) or btn(2) or btn(3) or btn(4) or btn(5) or btn(6) or btn(7) then mode="title" displayWait=30 wave=1 end elseif mode=="win" then cls() printc("You Win!",screen.w/2,screen.h/2,11,2) if displayWait>0 then displayWait=displayWait-1 elseif btn(0) or btn(1) or btn(2) or btn(3) or btn(4) or btn(5) or btn(6) or btn(7) then mode="title" displayWait=30 wave=1 end elseif mode=="level" then cls(7) local s=board[ny][nx] -- Wait for state changes then handle those changes if delay>0 then delay=delay-1 elseif state.w>0 then state.w=state.w-1 elseif state.n=="" then local r=math.random(1, max-1) state.s=board[r//level.w+1][r%level.w+1] state.n="open" state.w=15 elseif state.n=="open" then state.n="up" state.w=30 elseif state.n=="up" then state.n="wait" state.q="down" state.w=level.d if math.random(1,3)==1 then state.w=state.w*2 end elseif state.n=="wait" then state.n=state.q state.q="" state.w=30 elseif state.n=="down" then state.n="close" state.w=15 if state.s.point==false then run=0 protestors.c=protestors.c-1 removeP() shake=10 sfx(2, 1, 10, 0) else state.s.point=false end state.s.counted=false elseif state.n=="close" then local choice=math.random(1,3) if choice==1 then state.n="wait" state.q="" state.w=30 else state.n="" end end if state.n=="open" then state.s.w=state.s.w+1 if state.s.w>6 then state.s.w=6 end elseif state.n=="close" then state.s.w=state.s.w-1 if state.s.w<0 then state.s.w=0 end elseif state.n=="up" then state.s.h=state.s.h+1 if state.s.h>10 then state.s.h=10 end elseif state.n=="down" then state.s.h=state.s.h-1 if state.s.h<0 then state.s.h=0 end if state.s.point==true and state.s.counted==false then run=run+1 state.s.counted=true end end if w>0 then w=w-1 elseif btn(0) then -- Up w=5 ny=ny-1 if ny<1 then ny=1 end elseif btn(1) then -- Down w=5 ny=ny+1 if ny>level.h then ny=level.h end elseif btn(2) then -- Left w=5 nx=nx-1 if nx<1 then nx=1 end elseif btn(3) then -- Right w=5 nx=nx+1 if nx>level.w then nx=level.w end end if delay==0 and btn(4) or btn(5) then w=30 b=40 end if b>0 then b=b-2 end for i,v in ipairs(board) do for j,k in ipairs(v) do -- spr(id x y colorkey=-1 scale=1 flip=0 rotate=0 w=1 h=1)` -- Render half of the window spr(32+k.w,(screen.xoffset*j)-16,(screen.yoffset*i)-16,-1,2,0,0,1,2) -- Render again mirrored spr(32+k.w,(screen.xoffset*j),(screen.yoffset*i)-16,-1,2,1,0,1,2) if k.h > 0 then -- Render half of the head spr(64+k.h-1,(screen.xoffset*j)-8,(screen.yoffset*i)-1,5,1,0,0,1,2) -- Render again mirrored spr(64+k.h-1,(screen.xoffset*j),(screen.yoffset*i)-1,5,1,1,0,1,2) end -- Jug if s==k then local o=0 if b>30 then o=2 elseif b>20 then o=4 if k.h>5 and k.hit==0 then k.hit=30 k.point=true addTotal=250*(run+1) score=score+addTotal sfx(1, 14+(run>7 and 14 or run), 10, 0) update=60 if run>7 and protestors.c<8 then protestors.c=protestors.c+1 addP() end end elseif b>10 then o=2 else o=0 end spr(98+o,(screen.xoffset*j),(screen.yoffset*i)-1,0,1,0,0,2,2) end if k.hit>0 then print("BOINK",(screen.xoffset*j)-14,(screen.yoffset*i)-8) k.hit=k.hit-1 end end end print(score,10,10) if run>1 then local text="x"..run if update>0 then text=text.." = +"..addTotal end print(text,80,10) end if shake>0 then poke(0x3FF9+1,math.random(-1,1)) shake=shake-1 if shake==0 then memset(0x3FF9,0,2) end end if update>0 then if update>30 then print("+250",50,10) elseif run==0 then update=0 end update=update-1 end for i=1,protestors.c do palswap(9,protestors.d[i].h) palswap(4,protestors.d[i].s) spr(160,protestors.d[i].l,screen.h-10,5) palswap() end if protestors.c==0 then mode="game-over" displayWait=30 elseif protestors.c>6 then mode="wave-over" displayWait=30 end end t=t+1 end