FLipIt v1.1 - color flipping puzzle (all devices)
Posted: Tue Sep 26, 2017 9:04 pm
I was in a very boring gathering today, so I spent the time by making a little buttons game in smart basic. It is so easy to make little puzzles out of buttons!
This is like the "lights Out" puzzle game. Try to flip the colors on the board so the whole board is the same color. Touch a square to flip its color. It will also flip the neighboring squares too, so that makes it hard.
It's very bare bones right now, but should work on all devices as is. Enjoy.
- Dav
This is like the "lights Out" puzzle game. Try to flip the colors on the board so the whole board is the same color. Touch a square to flip its color. It will also flip the neighboring squares too, so that makes it hard.
It's very bare bones right now, but should work on all devices as is. Enjoy.
- Dav
Code: Select all
'FlipIt.txt v1.1. (All devices)
'Like the lights out color flip puzzle.
'Try to make all squares the same by flipping them.
'When you select a square, its color will flip, and
'its neighboring squares will also flip colors.
'Coded by Dav, SEP/2017
grid=7 '(7x7) set your grid size here
option base 1
set orientation top
graphics
graphics clear .3,.3,.3
get screen size sw,sh
set buttons custom
dim bv(grid*grid),bx(grid*grid),by(grid*grid)
size=sw/grid
'set button values, and x/y values...
bc=1
for r= 1 to grid
for c = 1 to grid
x=(r*size) ! y=(c*size)
'button str$(bc) text "" at x-size,y size size,size
bx(bc)=x-size!by(bc)=y!bv(bc)=0
bc=bc+1
next c
next r
m=int(grid*grid/2) !bv(m)=1 'set one button on
gosub updateboard
do
for b=1 to (grid*grid)
if button_pressed(str$(b)) then
'change the one clicked
if bv(b)=0 then bv(b)=1 else bv(b)=0
setbv("U",b) 'now change 1 up above b
setbv("D",b) 'now change 1 down b
setbv("L",b) 'now change the left
setbv("R",b) 'now change the right
gosub updateboard
end if
next b
until 0
'==========
updateboard:
for b=1 to (grid*grid)
if bv(b)=0 then
fill color .5,.5,.5
draw color .8,.8,.8
else
fill color .8,.8,.8
draw color .5,.5,.5
end if
button str$(b) text "" at bx(b),by(b) size size,size
next b
return
'==================
def setbv(way$,b)
'sets new button values.
if way$="U" then
for j = 1 to (.grid*.grid) step .grid
if b=j then return
next j
if .bv(b-1)=0 then .bv(b-1)=1 else .bv(b-1)=0
end if
if way$="D" then
for j=.grid to (.grid*.grid) step .grid
if b=j then return
next j
if .bv(b+1)=0 then .bv(b+1)=1 else .bv(b+1)=0
end if
if way$="L" then
for j=1 to .grid
if b=j then return
next j
if .bv(b-.grid)=0 then .bv(b-.grid)=1 else .bv(b-.grid)=0
end if
if way$="R" then
for j=(.grid*.grid)-.grid+1 to .grid*.grid
if b=j then return
next j
if .bv(b+.grid)=0 then .bv(b+.grid)=1 else .bv(b+.grid)=0
end if
end def