There are two programs posted here. 'MazeConnect.txt' is the game. 'MazeDesign.txt' is the maze designer you can use if you want to make your own mazes for the game.
- Dav
MazeConnect.txt v1.4 is below... (The game)
New for v1.4: Game board now only updates buttons that have been changed, greatly increasing screen updates on large grids and slower devices.
Code: Select all
'MazeConnect.txt v1.4 (ipad only)
'A Maze puzzle game prototype.
'Coded by Dav, OCT/2017
'You touch pieces to rotate them and connect them.
'Object is to make maze all connected and colorized.
'Top left is the first color one. Build from there.
'New for v1.4: New method of updating board pieces.
'              Only redraws buttons that have been
'              changed, not the whole board. This
'              makes gmae play MUCH faster on large
'              grids and on older devices.
if lowstr$(device_type$())<>"ipad" then
  print "Sorry, game for iPad only."
  end
end if
option base 1
graphics
graphics clear .3,.3,.3
set orientation top
set toolbar off
get screen size sw,sh
top:
grid=6'default to grid 6 (its level 1)
maxgrid=15 'last grid level so far (10 levels)
gosub titlemenu
'angle characters, right up, left up, etc
LD=9491!LU=9499!RD=9487!RU=9495!HZ=9473!VT=9475!BM=9724
'goto newlevel 'testing...
'load previous state if file exists
loaded=0 ! fil$="mazeconnect.dat"
if file_exists(fil$) then
  loaded=1
  file fil$ setpos 0
  file fil$ readline gr$
  grid=val(gr$)
end if
newlevel:
dim bv(grid*grid),bx(grid*grid),by(grid*grid),bc(grid*grid)
dim bc2(grid*grid)
size=sw/grid
mov =0
drawbackground
shadow on
draw color .8,.8,.8
t$="level="&(grid-5)
draw text t$ at sw/2-(text_width(t$)/2),sh/2-text_height(t$)
shadow off
pause 2
set buttons custom
set buttons font size size/2 'just for these buttons
draw color 0,0,0
fill color 1,.5,.5
button "quit" text "Quit" at 1,1
button "menu" text "Menu" at 1+text_width("Menu")-20,1
button "restart" text "Redo" at text_width("Redo")*2+20,1
set buttons font size size-2
'set button values, and x/y values...
bb=1
for r= 1 to grid
   for c = 1 to grid
     x=(r*size) ! y=(c*size)
     if rnd(grid*2)=grid then br =0
     bx(bb)=x-size!by(bb)=y
     if loaded=1 then
        file fil$ readline z$
        bv(bb)=val(z$)
     else
        bv(bb)=RD
     end if
     bc(bb)=0
     bc2(bb)=0
     bb=bb+1
   next c
next r
bc(1)=1 'turn on top left leader button
bc2(1)=1
if loaded=0 then
   setmaze 'set maze data, it's already scrambled up
end if
loaded=0
firstdraw=1
gosub updatebuttons
do 
   for b = 1 to (grid*grid)
    if button_pressed(str$(b)) then
       b2=bv(b) 'see what button it is
       'rotate right angles buttons
       if b2=RD then bv(b)=LD
       if b2=LD then bv(b)=LU
       if b2=LU then bv(b)=RU
       if b2=RU then bv(b)=RD
       'rotate horiz/vert lines
       if b2=HZ then bv(b)=VT
       if b2=VT then bv(b)=HZ
       'just redraw this button
        'fill color 1,1,1
        'button str$(b) text chr$(bv(b)) at bx(b),by(b) size size,size
       gosub updatebuttons
'now got to handle button we rotated in main loop
if bc(b)=1 then
   fill color .1,1,.3
else
   fill color 1,1,1
end if
button str$(b) text chr$(bv(b)) at bx(b),by(b) size size,size
       gosub checkforwin
    end if
   next b
   if button_pressed("quit") then
      gosub savestate
      end
   end if
   if button_pressed("menu") then
      button "quit" delete
      button "menu" delete
      button "restart" delete
      for e = 1 to grid*grid
        button str$(e) delete
      next e
      gosub savestate
      goto top
   end if
   if button_pressed("restart") then
     setmaze
     gosub updatebuttons
   end if
until 0
end
'============
updatebuttons:
'============
'first button always on
draw color 0,0,0
fill color .1,1,.3
button str$(1) text chr$(bv(1)) at bx(1),by(1) size size,size
'turn all off first,except 1st
for g=2 to grid*grid
  bc(g)=0
next g
'set leader button flow direction
if bv(1)=HZ then direction=1 'going right
if bv(1)=VT then direction=2 'going down
cur=1 'start with 1st button always
'do until can't flow anymore (direction blocked)
do 
  if direction=1 then 'heading right
    'see if already on the right edge of board
    'if so, it can't go right anymore, so end flow...
    for j=(.grid*.grid)-.grid+1 to .grid*.grid
       if cur=j then goto flowdone
    next j
    'now see if one to the right can connect with it.
    'if not connectable, end flow here.
    con=0 'default is not connectable
    nv=bv(cur+grid)
    if nv=HZ then con=1
    if nv=LU then con=1
    if nv=LD then con=1
    'if not, end flow here
    if con=0 then goto flowdone
    'looks like it is connectable, so turn it on
    bc(cur+grid)=1 'turn piece to the right on.
    'Make new pieve the new current flow position
    tc=(cur+grid)!cur=tc
    'find/set new direction based on that character
    if nv=HZ then direction=1 'right
    if nv=LU then direction=4 'up
    if nv=LD then direction=2 'down
  end if
  if direction=2 then 'heading down
    'see if this one is on the bottom edge
    for j=.grid to (.grid*.grid) step .grid
     if cur=j then goto flowdone
    next j
    'now see if new one can connect with this one.
    'if not, end flow here.
    con=0 'default is not connectable
    nv=bv(cur+1)
    if nv=VT then con=1
    if nv=LU then con=1
    if nv=RU then con=1
    'if not, end flow here
    if con=0 then goto flowdone
    'looks like it must be connectable
     bc(cur+1)=1 'turn the next piece on too
     'Make it the new current char position
     tc=(cur+1)!cur=tc
     'find/set new direction based on character
     if nv=LU then direction=3 'left
     if nv=RU then direction=1 'right
     if nv=VT then direction=2 'down
  end if
  if direction=3 then 'heading left
    'see if this one is on the bottom edge
    for j=1 to grid
     if cur=j then goto flowdone
    next j
    'now see if new one can connect with this one.
    'if not, end flow here.
    con=0 'default is not connectable
    nv=bv(cur-grid)
    if nv=HZ then con=1
    if nv=RU then con=1
    if nv=RD then con=1
    'if not, end flow here
    if con=0 then goto flowdone
    'looks like it must be connectable
     bc(cur-grid)=1 'turn the next piece on too
     'Make it the new current char position
     tc=(cur-grid)!cur=tc
     'find/set new direction based on character
     if nv=HZ then direction=3 'left
     if nv=RU then direction=4 'up
     if nv=RD then direction=2 'down
  end if
  if direction=4 then 'going up
    'see if this one is on the edge of board
    'if so, it can't go up, so end flow...
    for j = 1 to (.grid*.grid) step .grid
     if cur=j then goto flowdone
    next j
    'now see if new one can connect with this one.
    'if not, end flow here.
    con=0 'default is not connectable
    nv=bv(cur-1)
    if nv=VT then con=1
    if nv=LD then con=1
    if nv=RD then con=1
    'if not, end flow here
    if con=0 then goto flowdone
    'looks like it must be connectable
     bc(cur-1)=1 'turn the next piece on too
     'Make it the new current char position
     tc=(cur-1)!cur=tc
     'find/set new direction based on character
     if nv=VT then direction=4 'up
     if nv=LD then direction=3 'left
     if nv=RD then direction=1 'right
  end if
  
until 0
flowdone:
if firstdraw=0 then
'draw/colorize board
for t=2 to (grid*grid)
   if bc(t)=1 and bc2(t)=0 then
        fill color .1,1,.3
        button str$(t) text chr$(bv(t)) at bx(t),by(t) size size,size
   end if
   if bc(t)=0 and bc2(t)=1 then
        fill color 1,1,1
        button str$(t) text chr$(bv(t)) at bx(t),by(t) size size,size
   end if
next t
else
'draw/colorize board
for t=2 to (grid*grid)
   if bc(t)=1 then
     fill color .1,1,.3
   else
     fill color 1,1,1
   end if
   button str$(t) text chr$(bv(t)) at bx(t),by(t) size size,size
   'bc2(t)=bc(t)
next t
firstdraw=0
end if
'copy current color values
for t=1 to grid*grid
  bc2(t)=bc(t)
next t
'save state to file
savestate:
fil$="mazeconnect.dat"
if file_exists(fil$) then file fil$ delete
file fil$ print
file fil$ setpos 0
file fil$ writeline str$(grid)
for h=1 to grid*grid
   file fil$ writeline str$(bv(h))
next h
return
checkforwin:
all=0
for w=1 to (grid*grid)
  if bc(w)=1 then all=all+1
  if bv(w)=BM then all=all+1 'add blocks
next w
if all=(grid*grid) then
    
    'play song
     notes set "7:s(c3eg)(e4cg3)(g4ec)(c5g4e)"
     notes play
    pause 2
    button "quit" delete
    button "restart" delete
    button "menu" delete
    drawbackground
    t$="Good Job!"
    draw color .8,.8,.8
    draw text "Good Job!" at sw/2-(text_width(t$)/2),sh/2-text_height(t$)
    for h=1 to grid*grid
       button str$(h) delete
    next h
    pause 1.5
    grid=grid+1
    if grid>maxgrid then
      grid=maxgrid
    end if
    goto newlevel
end if
return
titlemenu:
graphics clear .3,.3,.3
drawbackground
shadow on
draw color .8,.8,.8
t$="MazeConnect"
draw font size 76
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)/2
t$="A puzzle game by Dav"
draw font size 36
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*3
shadow off
draw color 1,1,.5
t$="HOW TO PLAY:"
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*6
draw color .8,.8,.8
t$="Touch maze pieces to rotate."
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*7
t$="Top left piece is always on."
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*8
t$="When others connect they will"
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*9
t$="turn on too.  Try to get the"
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*10
t$="whole maze on and connected."
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*11
'show current level
fil$="mazeconnect.dat"
if file_exists(fil$) then
   file fil$ setpos 0
   file fil$ readline f$
   ff=val(f$)-5
   t$="Current level: "&ff
else
   t$="Current level: "&str$(grid-5)
end if
draw color 1,1,1
draw text t$ at sw/2-(text_width(t$)/2),text_height(t$)*13
set buttons custom
set buttons font size 50
draw color 0,0,0
fill color 1,1,0
button "start" text "Start" at sw/2-90,sh/2+100
button "quit" text "Quit" at sw/2-80,sh/2+200
fill color .5,.5,.5
draw color 1,1,1
button "reset" text "Reset Game" at sw/2-180,sh/2+400
do
  if button_pressed("reset") then
   if file_exists(fil$) then file fil$ delete
   goto titlemenu
  end if
  if button_pressed("quit") then end
until button_pressed("start")
button "start" delete
button "reset" delete
button "quit" delete
return
def setmaze
if .grid=3 then
a$="" '3x3 MazeConnect grid
a$=a$&"hzrdru"
a$=a$&"hzhzhz"
a$=a$&"ldluld"
end if
if .grid=4 then
a$="" '4x4 MazeConnect grid
a$=a$&"vtvtruru"
a$=a$&"rdvtluhz"
a$=a$&"hzrdruhz"
a$=a$&"ldluldlu"
end if
 if .grid=5 then
   a$="" '5x5 MazeConnect grid
   a$=a$&"hzrdvtvtld"
   a$=a$&"hzhzrdrdhz"
   a$=a$&"hzhzldhzhz"
   a$=a$&"hzldvtluhz"
   a$=a$&"ldvtvtvtlu"
 end if
if .grid=6 then
a$="" '6x6 MazeConnect grid
a$=a$&"hzrdrurdvtru"
a$=a$&"hzhzhzhzrdlu"
a$=a$&"ldluhzhzldru"
a$=a$&"rdvtluhzbmhz"
a$=a$&"hzrdruldruhz"
a$=a$&"ldluldvtlulu"
end if
 if .grid=7 then
    a$=""'7x7 MazeConnect grid
    a$="vtruvtvtrurdru"
    a$=a$&"rdlurdruldluhz"
    a$=a$&"ldvtluldrurdlu"
    a$=a$&"rdvtrurdluldru"
    a$=a$&"ldruldlurdvtlu"
    a$=a$&"rdlurdruldvtru"
    a$=a$&"ldvtluldvtvtlu"
  end if
if .grid=8 then
  a$=""'8x8 MazeConnect grid
  a$=a$&"hzvtrurdrurdrubm"
  a$=a$&"hzbmldluhzhzldru"
  a$=a$&"ldvtrurdluhzrdlu"
  a$=a$&"rdvtluldvtluldru"
  a$=a$&"ldrurdvtrurdvtlu"
  a$=a$&"bmhzhzbmldlurdru"
  a$=a$&"rdluldvtvtvtluhz"
  a$=a$&"ldvtvtvtvtvtvtlu"
end if
if .grid=9 then
a$="" '9x9 MazeConnect grid
a$=a$&"hzrdvtvtrurdrurdru"
a$=a$&"hzldvtruldluldluhz"
a$=a$&"ldvtruldrubmrdvtlu"
a$=a$&"rdruldruldruldrubm"
a$=a$&"hzldruldruldruldru"
a$=a$&"ldruhzbmldruhzbmhz"
a$=a$&"rdluldvtvtluldruhz"
a$=a$&"hzrdrurdvtrurdluhz"
a$=a$&"ldluldlubmldluvtlu"
end if
if .grid=10 then
a$="" '10x10 MazeConnect grid
a$=a$&"vtvtvtrurdrurdvtrubm"
a$=a$&"hzrdvtluhzhzldruldru"
a$=a$&"hzldvtvtluldruhzrdlu"
a$=a$&"hzbmrdvtvtruldluldru"
a$=a$&"hzrdlurdruhzrdvtvtlu"
a$=a$&"hzhzrdluhzldlurdrubm"
a$=a$&"hzhzhzbmldrubmhzldru"
a$=a$&"hzldlurdruldvtlurdlu"
a$=a$&"hzrdruhzldrurdruldru"
a$=a$&"ldluldlubmldluldvtlu"
end if
if .grid=11 then
a$="" '11x11 MazeConnect grid
a$=a$&"hzvtrubmrdvtrubmrdvtru"
a$=a$&"ldruldruldruldruldruhz"
a$=a$&"bmldruldruldruldruhzhz"
a$=a$&"rdruldruldruldruldluhz"
a$=a$&"hzldruldruldruldrurdlu"
a$=a$&"ldruldruldruldruhzldru"
a$=a$&"bmldruldruldruldlurdlu"
a$=a$&"rdruldruldruldrurdlubm"
a$=a$&"hzldruldruldvtluldvtru"
a$=a$&"ldruldvtlurdrurdrurdlu"
a$=a$&"bmldvtvtvtluldluldlubm"
end if
if .grid=12 then
a$="" '12x12 MazeConnect grid
a$=a$&"vtvtrubmbmrdrurdrurdvtru"
a$=a$&"bmbmhzbmrdluldluhzhzrdlu"
a$=a$&"bmrdlurdlurdrurdluhzldru"
a$=a$&"rdlurdlurdluhzhzrdlurdlu"
a$=a$&"ldruldvtlurdluhzhzbmldru"
a$=a$&"bmldvtvtruhzbmldlurdvtlu"
a$=a$&"rdvtvtvtluhzrdvtvtlurdru"
a$=a$&"ldrurdvtvtluhzrdvtvtluhz"
a$=a$&"rdluhzbmbmbmldlurdrurdlu"
a$=a$&"hzrdlurdrurdrubmhzhzhzbm"
a$=a$&"ldlurdluhzhzhzrdluhzldru"
a$=a$&"vtvtlubmldluldlubmldvtlu"
end if
if .grid=13 then
a$="" '13x13 MazeConnect grid
a$=a$&"hzvtvtvtvtvtrurdrurdrurdru"
a$=a$&"hzrdrurdvtruldluhzhzldluhz"
a$=a$&"hzhzhzhzspldvtruhzhzrdruhz"
a$=a$&"hzhzhzldrubmrdluldluhzhzhz"
a$=a$&"hzhzldvtlurdlurdvtvtluldlu"
a$=a$&"hzldrubmrdlubmldvtvtrurdru"
a$=a$&"ldruldruhzbmbmbmrdruhzhzhz"
a$=a$&"rdlurdluldrubmrdluhzldluhz"
a$=a$&"hzrdlurdruldvtlurdlubmrdlu"
a$=a$&"hzldruhzldrurdvtlurdruldru"
a$=a$&"hzrdluhzbmldlurdvtluhzrdlu"
a$=a$&"hzhzrdlurdvtruhzrdvtluldru"
a$=a$&"ldluldvtlubmldluldvtvtvtlu"
end if
if .grid=14 then
a$="" '14x14 MazeConnect grid
a$=a$&"hzrdrurdvtvtrurdrurdvtvtrubm"
a$=a$&"hzhzhzldvtruhzhzhzhzrdruhzbm"
a$=a$&"ldluhzrdruhzldluldluhzhzhzbm"
a$=a$&"rdruhzhzhzldvtvtvtruhzldlubm"
a$=a$&"hzhzhzhzhzrdrurdruhzldvtrubm"
a$=a$&"hzhzhzhzhzhzhzhzhzhzrdruldru"
a$=a$&"hzhzldluhzhzhzhzhzhzhzldvtlu"
a$=a$&"hzldvtruhzhzhzhzhzhzldrurdru"
a$=a$&"hzrdruhzldluhzhzhzhzbmldluhz"
a$=a$&"ldluhzldvtruhzhzhzhzrdrurdlu"
a$=a$&"rdruhzrdvtluhzhzldluhzhzhzbm"
a$=a$&"hzldluldvtvtluhzrdvtluhzhzbm"
a$=a$&"hzvtvtvtvtvtvtluldrurdluhzbm"
a$=a$&"ldvtvtvtvtvtvtvtvtluldvtlubm"
end if
if .grid=15 then
  a$="" '15x15 MazeConnect grid
  a$=a$&"vtvtrurdrurdrurdrubmrdvtvtvtru"
  a$=a$&"vtruldluhzhzldluldvtlurdvtruhz"
  a$=a$&"rdlubmbmhzldvtvtrurdvtlubmldlu"
  a$=a$&"ldrurdruhzbmrdruhzldrurdvtvtru"
  a$=a$&"bmhzhzldlurdluhzldruldlurdvtlu"
  a$=a$&"rdluldrurdlubmhzrdlurdruldrubm"
  a$=a$&"ldrubmldlurdruldlubmhzhzbmldru"
  a$=a$&"rdlurdvtvtluldrurdruhzhzrdvtlu"
  a$=a$&"ldvtlurdvtvtvtluhzldluhzldvtru"
  a$=a$&"rdvtvtlurdvtvtruldrurdlurdruhz"
  a$=a$&"ldvtrurdlubmrdlurdluhzrdluldlu"
  a$=a$&"rdvtluldrurdlurdlurdluhzbmrdru"
  a$=a$&"ldvtrurdluhzbmldruldruldvtluhz"
  a$=a$&"rdvtluldruhzrdruldruldvtrurdlu"
  a$=a$&"ldvtvtvtluldluldvtlubmbmldlubm"
end if
  dd=1
  for s=1 to len(a$) step 2
    b$=mid$(a$,s,2)
    if b$="vt" then rotate(dd,1)
    if b$="hz" then rotate(dd,1) 
    if b$="ld" then rotate(dd,2) 
    if b$="lu" then rotate(dd,2) 
    if b$="rd" then rotate(dd,2) 
    if b$="ru" then rotate(dd,2) 
    if b$="bm" then .bv(dd)=.BM
    if b$="sp" then .bv(dd)=32
    dd=dd+1
  next s
end def
def rotate(num,type)
  'there are only two types of rotating characters,
  'straight lines, or right angles...
  'randomly rotate straight character
  if type=1 then
    if rnd(2) =0 then
       .bv(num)=.VT
    else
       .bv(num)=.HZ
    end if
  end if
  
  'randomly rotate right angles...
  if type=2 then
    rn=int(rnd(4))+1
    if rn=1 then .bv(num)=.LD
    if rn=2 then .bv(num)=.LU
    if rn=3 then .bv(num)=.RD
    if rn=4 then .bv(num)=.RU
  end if
end def
def drawbackground
graphics clear .3,.3,.3
draw alpha .3
draw font size 100
draw color 0,0,0
'a litte background
for x=1 to .sw step 61
   for y =1 to .sh step 102
      draw text chr$(9619) at x,y
   next y
next x
draw alpha 1
end def
MazeDesign.txt v1.0 is below....Use this to design your own mazes for game. it will output code to a file called MazeDesign.output.txt. These mazes are for v1.2 of the game or higher, not older version posted.
Code: Select all
'MazeDesign.txt v1.0
'Design/Save mazes for the MazeConnect puzzle.
'Coded by Dav, SEP/2017
'NOTE: The top left piece must be a straight line,
'either horizonal or vertical piece....for now.
'HOT TO USE: Touch a piece to use for drawing, then
'touch on the board to place it there. When you 
'want to save your design, click the save button
'and the maze code will be saved to a file called:
'mazedesign.output.txt. You can copy that code to
'the mazeconnect program to use.
'===========================================
grid=8 '<<<< set the grid size you want here.
'===========================================
option base 1
graphics
graphics clear .3,.3,.3
set orientation top
get screen size sw,sh
'angle characters, right up, left up, etc
LD=9491!LU=9499!RD=9487!RU=9495!HZ=9473!VT=9475!BM=9724
dim bv(grid*grid),bx(grid*grid),by(grid*grid),bc(grid*grid)
size=sw/grid
mov =0
set buttons custom
set buttons font size size
'draw drawing buttons
draw color 0,0,0
fill color 1,.5,.5
button "hz" text chr$(hz) at 1,1 size size,size
button "vt" text chr$(vt) at 1+size,1 size size,size
button "ld" text chr$(ld) at 1+size*2,1 size size,size
button "lu" text chr$(lu) at 1+size*3,1 size size,size
button "rd" text chr$(rd) at 1+size*4,1 size size,size
button "ru" text chr$(ru) at 1+size*5,1 size size,size
button "bm" text chr$(bm) at 1+size*6,1 size size,size
button "clr" text chr$(0) at 1+size*7,1 size size,size
button "cls" text "clear" at 1, grid*size+size
button "sav" text "save" at sw/2+size,grid*size+size 
selected=1 
clear:
'set button values, and x/y values...
bb=1
for r= 1 to grid
   for c = 1 to grid
     x=(r*size) ! y=(c*size)
     if rnd(grid*2)=grid then br =0
     bx(bb)=x-size!by(bb)=y!bv(bb)=0!bc(bb)=0
     bb=bb+1
   next c
next r
gosub updatebuttons
do 
   for b = 1 to (grid*grid)
    if button_pressed(str$(b)) then
       if selected=1 then bv(b)= HZ
       if selected=2 then bv(b)= VT
       if selected=3 then bv(b)= LD
       if selected=4 then bv(b)= LU
       if selected=5 then bv(b)= RD
       if selected=6 then bv(b)= RU
       if selected=7 then bv(b)= BM
       if selected=8 then bv(b)= 32
       gosub updatebuttons
       'gosub checkforwin
    end if
   next b
   if button_pressed("hz") then selected =1
   if button_pressed("vt") then selected =2
   if button_pressed("ld") then selected =3
   if button_pressed("lu") then selected =4
   if button_pressed("rd") then selected =5
   if button_pressed("ru") then selected =6
   if button_pressed("bm") then selected =7
   if button_pressed("clr") then selected =8
   if button_pressed("cls") then goto clear
   if button_pressed("sav") then gosub save
until 0
end
'============
updatebuttons:
'============
draw color 0,0,0
fill color 1,1,1
'draw/colorize board
for t=1 to (grid*grid)
   button str$(t) text chr$(bv(t)) at bx(t),by(t) size size,size
next t
return
'====
save:
'====
fil$="mazedesign.output.txt"
if file_exists(fil$) then file fil$ delete
s$=s$&"a$="&chr$(34)&chr$(34)&" '"&grid&"x"&grid
s$=s$&" MazeConnect grid"&chr$(10)
s$=s$&"a$=a$&"""
gc=1
for t = 1 to grid*grid
     if bv(t)=0 then s$=s$&"sp"
     if bv(t)=32 then s$=s$&"sp"
     if bv(t)=BM then s$=s$&"bm" 'block/bomb
     if bv(t)=HZ then s$=s$&"hz"
     if bv(t)=VT then s$=s$&"vt"
     if bv(t)=LD then s$=s$&"ld"
     if bv(t)=LU then s$=s$&"lu"
     if bv(t)=RD then s$=s$&"rd"
     if bv(t)=RU then s$=s$&"ru"
     's$=s$&chr$(bv(t))
     gc=gc+1
     if gc>grid then
        if t=grid*grid then break
        s$=s$&chr$(34)&chr$(10)
        s$=s$&"a$=a$&"""
        gc=1
     end if
next t
s$=s$&chr$(34)
'delete buttons
button "hz" delete
button "vt" delete
button "lu" delete
button "ld" delete
button "ru" delete
button "rd" delete
button "bm" delete
button "clr" delete
for t=1 to (grid*grid)
   button str$(t) delete
next t
text
print s$
file fil$ writeline s$
print
print "This maze has been saved to "&fil$
end
return


