The classic Lights Out puzzle game for the TweetTweetJam. The PICO-8 source code fits in two tweets (560 characters).

Your goal is to turn all the lights off. However, each light toggles all four adjacent lights as well.

Game modes

  • Lights Out Classic: Lights toggle between off and on (red). Best solution is 15 moves.
  • Lights Out 2000: Lights toggle between off, red and green. Best solution is 18 moves.

Source code

z="lights out"poke(24364,3)::x::flip()cls()k=btnp()w={[0]="","▒","█"}f=flr
?z,12,18,stat(95)%4
?"z: classic\nx: 2000",12,32,7
if(k<9)goto x
if(k>16)w[3]="█"
b={}p=2m=0
for i=1,35 do
b[i]=i%7<2 and 0or 2
end::_::flip()cls()
?m,30,54
for i=1,35 do
j=b[i]
?w[j],i%7*8-2,6*f(i/7)+18,j*3+2
end
x=p%7*8-2y=6*f(p/7)+17rect(x-1,y,x+7,y+6,9)q=0k=btnp()h={-1,1,-7,0,7}if k>9then m+=1for i in all(h)do
o=b[p+i]
if(o and o>0)b[p+i]=o%#w+1
end
elseif k>0then q=h[f(k/2)+1]end
g=b[p+q]
if(g and g>0)p+=q
for i=1,35 do
if(b[i]>1)goto _ end
z="you win!"goto x

Download

Download NowName your own price

Click download now to get access to the following files:

lights-out.p8.png 2 kB

Leave a comment

Log in with itch.io to leave a comment.