Author Topic: Pipes Puzzle v1.0 (was MazeConnect Prototype)  (Read 7838 times)

0 Members and 1 Guest are viewing this topic.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Pipes Puzzle v1.0 (was MazeConnect Prototype)
« on: September 29, 2021, 10:06:19 pm »
This is a follow up of my MazeConnect Prototype posted last year. The graphics are changed to make it look like those water pipe connect puzzles found everywhere  - making it's easier to grasp what to do now.  Added title screen with instructions, current level and win notice.  The levels are the same as before - I haven't had time to make new levels.

To play you click on the pipes to rotate them and connect them to the flow, making the pipes all connected and one color. 

I'll try to post a new BAS code down the road, with 25 levels.

- Dav

  (105kb)
 
PipesPuzzle.jpg


Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #1 on: September 29, 2021, 10:56:49 pm »
Are you sewer you want to do that project, or is this just another one of your pipe dreams?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #2 on: September 29, 2021, 10:58:39 pm »
What's the black square, a septic tank :), was that in MazeConnect before?

Oh the "You did it!" sign is popping up too quick and blocking what I did. I was working on the puzzle of the screen shot and thought I was stuck, flipped a few corners and suddenly I did it, but did what?

BTW let me know if you want a puzzle generator, I think I can make one.

I really like this puzzle.
« Last Edit: September 29, 2021, 11:12:51 pm by bplus »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #3 on: September 29, 2021, 11:11:35 pm »
If the maze randomizer ever made a puzzle without any curved pipes, would that be a straight flush?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #4 on: September 30, 2021, 07:36:03 am »
well done Dav :-)

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #5 on: September 30, 2021, 08:04:14 am »
Thanks, @jack.  I’m going to rewrite this. @bplus, yes the “you did it” cover up bothers me too. I’ll figure about something else instead. The black square was a a barrier block in the original.  I have a level designer to post eventually. @Pete, lol...

 I’m off Saturday from working, and if my wife let’s me off at home too I’ll try to update this.

- Dav

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #6 on: September 30, 2021, 08:39:55 am »
All levels completed... Cool game!
Logic is the beginning of wisdom.

Offline AndyA

  • Newbie
  • Posts: 73
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #7 on: October 03, 2021, 09:23:43 pm »
Hi. Nice game.

I only had the patience to make it to level 6. Will probably finish it at a later date.

Here's a suggestion for when the level is completed.

Create  a screen the size of the  "You did it" message called 'msg" for instance. Just be sure to use an _Unsigned Long to declare the 'msg' variable. Then the "You did it" msg could be drawn at let's say 50% transparency. Use _RGBA(0,0,128,128) as that's a 50% transparent blue. Set _Dest to 'msg' (or _Source, forget which is which), then issue a Line (0,0)-(x, y), msg, BF. That creates a blue filled box in memory at alpha 50%. Do the same for the text at alpha 70%. (Int(0.7 * 255))

_PutImage (x, y), msg, 0 and Voila! A see through "You did it" message.




Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #8 on: October 03, 2021, 09:51:06 pm »
Yeah go from transparent to opaque.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #9 on: October 03, 2021, 10:25:52 pm »
Code: QB64: [Select]
  1. Screen _NewImage(320, 300, 32)
  2. YDI& = _NewImage(_Width, _Height, 32)
  3. snap& = _NewImage(_Width, _Height, 32)
  4. For i = 1 To 40
  5.     Line (Rnd * _Width, Rnd * _Height)-Step(Rnd * 50, Rnd * 50), _RGB32(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
  6. _PutImage , 0, snap&
  7.  
  8. For i = 1 To 255
  9.     YDI& = _NewImage(_Width, _Height, 32)
  10.     _Dest YDI&
  11.     _PutImage , snap&, 0
  12.     Color _RGB32(0, 0, 255, i), &HFF000000
  13.     Locate 9, 15
  14.     Print "You did it!"
  15.     _Dest 0
  16.     _PutImage , YDI&, 0
  17.     _Display
  18.     _Limit 5
  19.     _FreeImage YDI&
  20.  
  21.  
  22.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #10 on: October 03, 2021, 10:29:51 pm »
Actually when hear sound of applause, you know it's done, so fade in could be slow.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #11 on: October 03, 2021, 10:44:06 pm »
3 enhancements:
Code: QB64: [Select]
  1. Screen _NewImage(320, 300, 32)
  2. YDI& = _NewImage(_Width, _Height, 32)
  3. snap& = _NewImage(_Width, _Height, 32)
  4. For i = 1 To 40
  5.     Line (Rnd * _Width, Rnd * _Height)-Step(Rnd * 50, Rnd * 50), _RGB32(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
  6. _PutImage , 0, snap&
  7.  
  8. For i = 1 To 255
  9.     YDI& = _NewImage(_Width, _Height, 32)
  10.     _Dest YDI&
  11.     _PutImage , snap&, YDI&
  12.     Color &HFFFFFFFF
  13.     Locate 1, 1: Print i
  14.     Color _RGB32(0, 0, 255, i), &HFF000000
  15.     Locate 9, 15
  16.     Print "You did it!"
  17.     _Dest 0
  18.     _PutImage , YDI&, 0
  19.     _Display
  20.     _Limit 10
  21.     _FreeImage YDI&
  22.  
  23.  
  24.  

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #12 on: October 04, 2021, 12:37:58 pm »
Good suggestion.  Thanks for the code examples, @bplus

I'll try to put together a new version of this puzzle.

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #13 on: October 04, 2021, 12:47:26 pm »
Hi @Dav,

Getting some great suggestions for an image Fade in (or out) at Discussion Board.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipes Puzzle v1.0 (was MazeConnect Prototype)
« Reply #14 on: October 13, 2021, 01:51:52 am »
Hi Dav,

Here's three fixes for one of my favorites from you:
1. Gets icon loaded for my system from your zip package, the icon in the package is in same folder as source so the pipes path was messing things up.
2. I just have to have my games centered on screen when I play them. Curiously waiting for screen to exist does not help with _screenmove _middle but _delay .25 does!
3. The fade-in of the You did graphic is up and running!

Sorry I just couldn't wait for you to get around to it, your wife will thank me. ;-))

Code: QB64: [Select]
  1. '================
  2. 'PIPES.BAS v1.0
  3. '================
  4. 'Connect the pipes puzzle game
  5. 'Coded by Dav for QB64-GL 1.5 in SEP/2021
  6.  
  7. 'NOTE: Formally called MazeConnect Prototype on the forum.
  8.  
  9. '============
  10. 'HOW TO PLAY:
  11. '============
  12.  
  13. 'Click on pipes to rotate them and connect them as one.
  14. 'Object is to make all pipes on board connected to leader.
  15. 'Top left pipe is always on, the leader, so start from it.
  16. 'When pipes are all connected, you advance to next level.
  17. 'There are currently 20 levels.  ESC key exits game.
  18.  
  19. 'SPACE  = restarts level
  20. 'RIGHT ARROW = goto next level
  21. 'LEFT ARROW = go back a level
  22. 'ESC = Quits game
  23.  
  24. '         VVVVVVV     blus fixed next line to work from his downloaded zip
  25. $ExeIcon:'.\icon.ico'
  26.  
  27.  
  28.  
  29. Dim Shared GridSize, Level, MaxLevel, LD$, LU$, RD$, RU$, HZ$, VT$, BM$
  30.  
  31. Level = 1: MaxLevel = 13
  32.  
  33. GridSize = 3 'default starting GridSize is 3x3 (its level 1)
  34. MaxGridSize = 15 'The last GridSize level so far (13 levels right now)
  35.  
  36. 'Declare image names: angle characters, right up, left up, etc
  37. LD$ = "ld": LU$ = "lu"
  38. RD$ = "rd": RU$ = "ru"
  39. HZ$ = "hz": VT$ = "vt"
  40. BM$ = "bm"
  41.  
  42. 'Sound files
  43. new& = _SndOpen("sfx_magic.ogg")
  44. move& = _SndOpen("sfx_click1.mp3"):
  45. click& = _SndOpen("sfx_click2.mp3"):
  46. clap& = _SndOpen("sfx_clap.ogg")
  47.  
  48. 'image file
  49. Dim Shared Solved&
  50. Solved& = _LoadImage("solved.png", 32) '<  thank bplus for this
  51.  
  52. 'For game state saving...to be added later
  53. loaded = 0: fil$ = "pipe.dat"
  54.     loaded = 1
  55.  
  56. '=======
  57. newlevel:
  58. '=======
  59.  
  60. Screen _NewImage(640, 640, 32)
  61. 'Do: Loop Until _ScreenExists ' <<<<<<<<<< sorry Dav this aint working on my system
  62. _Delay .25 ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<< does this work for you?
  63. '            No? increase delay time really nice to have centered on screen
  64. _ScreenMove _Middle ' <  thank bplus for this , ahhhh that's better
  65. Cls ', _RGB(32, 32, 77)
  66.  
  67. If Level = 1 Then
  68.     back& = _LoadImage("hz-grn.png")
  69.     _PutImage (0, 0)-(640, 640), back&
  70.     _FreeImage back&
  71.     title& = _LoadImage("title.png")
  72.     _PutImage (84, 140), title&
  73.     _FreeImage title&
  74.     w$ = Input$(1)
  75.     For a = 0 To 64
  76.         Line (0, 0)-(640, 640), _RGBA(0, 0, 0, a), BF
  77.         _Delay .02
  78.     Next
  79.  
  80. PPRINT 100, 300, 30, _RGB(200, 200, 200), 0, "Level:" + Str$(Level) + " of" + Str$(MaxLevel)
  81.  
  82.  
  83. Title$ = "Pipes: Level " + Str$(Level) + " of" + Str$(MaxLevel)
  84. _Title Title$
  85.  
  86. 'Make space for variables
  87. ReDim Shared TileVal$(GridSize * GridSize)
  88. ReDim Shared TileX(GridSize * GridSize), TileY(GridSize * GridSize)
  89. ReDim Shared TileClr(GridSize * GridSize), TileClr2(GridSize * GridSize)
  90.  
  91. TileSize = Int(640 / GridSize) 'The width/height of tiles, in pixels
  92.  
  93. 'set tile values, and generate x/y values...
  94. bb = 1
  95. For r = 1 To GridSize
  96.     For c = 1 To GridSize
  97.         x = (r * TileSize): y = (c * TileSize)
  98.         If Rnd(GridSize * 2) = GridSize Then br = 0
  99.         TileX(bb) = x - TileSize: TileY(bb) = y - TileSize
  100.         TileVal$(bb) = RD$
  101.         TileClr(bb) = 0
  102.         TileClr2(bb) = 0
  103.         bb = bb + 1
  104.     Next c
  105.  
  106. TileClr(1) = 1 'turn on top left leader tile
  107. TileClr2(1) = 1 'make a copy
  108.  
  109. setmaze 'Load level maze data, it's already scrambled up
  110.  
  111. firstdraw = 1
  112. GoSub updatebuttons
  113.  
  114.  
  115.     _Limit 300
  116.  
  117.     'wait until mouse button up to continue
  118.     While _MouseButton(1) <> 0: n = _MouseInput: Wend
  119.  
  120.     trap = _MouseInput
  121.         mx = _MouseX: my = _MouseY
  122.  
  123.         For b = 1 To (GridSize * GridSize)
  124.  
  125.             tx = TileX(b): tx2 = TileX(b) + TileSize
  126.             ty = TileY(b): ty2 = TileY(b) + TileSize
  127.  
  128.             If mx >= tx And mx <= tx2 Then
  129.                 If my >= ty And my <= ty2 Then
  130.                     'skip any black blocks clicked on
  131.                     If TileVal$(b) = BM$ Then GoTo skip
  132.  
  133.                     _SndPlay move&
  134.  
  135.                     bv2$ = TileVal$(b) 'see what tile it is
  136.  
  137.                     'rotate right angle tiles
  138.                     If bv2$ = RD$ Then TileVal$(b) = LD$
  139.                     If bv2$ = LD$ Then TileVal$(b) = LU$
  140.                     If bv2$ = LU$ Then TileVal$(b) = RU$
  141.                     If bv2$ = RU$ Then TileVal$(b) = RD$
  142.  
  143.                     'rotate horiz/vert lines
  144.                     If bv2$ = HZ$ Then TileVal$(b) = VT$
  145.                     If bv2$ = VT$ Then TileVal$(b) = HZ$
  146.  
  147.                     'show tile
  148.                     If TileClr(b) = 1 Then
  149.                         tag$ = "-grn.png"
  150.                     Else
  151.                         tag$ = "-wht.png"
  152.                     End If
  153.  
  154.                     SHOW TileVal$(b) + tag$, TileX(b), TileY(b), TileX(b) + TileSize, TileY(b) + TileSize
  155.  
  156.                     GoSub updatebuttons
  157.                     GoSub checkforwin
  158.  
  159.                 End If
  160.             End If
  161.         Next b
  162.     End If
  163.     skip:
  164.  
  165.     ink$ = UCase$(InKey$)
  166.  
  167.     If ink$ = Chr$(32) Then GoTo newlevel
  168.  
  169.     'Right arrows advance to next level
  170.     If ink$ = Chr$(0) + Chr$(77) Then
  171.         GridSize = GridSize + 1
  172.         Level = Level + 1
  173.         If Level > MaxLevel Then Level = 1
  174.         If GridSize > MaxGridSize Then
  175.             GridSize = 3 'MaxGridSize  'restart
  176.         End If
  177.         GoTo newlevel
  178.     End If
  179.  
  180.     'Left Arrows go back a level
  181.     If ink$ = Chr$(0) + Chr$(75) Then
  182.         GridSize = GridSize - 1
  183.         If GridSize < 3 Then GridSize = MaxGridSize
  184.         Level = Level - 1
  185.         If Level < 1 Then Level = MaxLevel
  186.         GoTo newlevel
  187.     End If
  188.  
  189. Loop Until ink$ = Chr$(27)
  190.  
  191.  
  192. '============
  193. updatebuttons:
  194. '============
  195.  
  196. 'first tile always on, draw it green
  197. SHOW TileVal$(1) + "-grn.png", TileX(1), TileY(1), TileX(1) + TileSize, TileY(1) + TileSize
  198.  
  199.  
  200. 'turn all off tile colors first, except 1st
  201. For g = 2 To GridSize * GridSize
  202.     TileClr(g) = 0
  203.  
  204.  
  205. 'set leader tile flow direction
  206. If TileVal$(1) = HZ$ Then direction = 1 'going right
  207. If TileVal$(1) = VT$ Then direction = 2 'going down
  208.  
  209. cur = 1 'start with 1st tile always
  210.  
  211. 'do until can't flow anymore (direction blocked)
  212.  
  213.     If direction = 1 Then 'heading right
  214.         'see if already on the right edge of board
  215.         'if so, it can't go right anymore, so end flow...
  216.         For j = (GridSize * GridSize) - GridSize + 1 To GridSize * GridSize
  217.             If cur = j Then GoTo flowdone
  218.         Next j
  219.         'now see if one to the right can connect with it.
  220.         'if not connectable, end flow here.
  221.         con = 0 'default is not connectable
  222.         nv$ = TileVal$(cur + GridSize)
  223.         If nv$ = HZ$ Then con = 1
  224.         If nv$ = LU$ Then con = 1
  225.         If nv$ = LD$ Then con = 1
  226.         'if not, end flow here
  227.         If con = 0 Then GoTo flowdone
  228.         'looks like it is connectable, so turn it on
  229.         TileClr(cur + GridSize) = 1 'turn piece to the right on.
  230.         'Make new pieve the new current flow position
  231.         tc = (cur + GridSize): cur = tc
  232.         'find/set new direction based on that character
  233.         If nv$ = HZ$ Then direction = 1 'right
  234.         If nv$ = LU$ Then direction = 4 'up
  235.         If nv$ = LD$ Then direction = 2 'down
  236.     End If
  237.  
  238.     If direction = 2 Then 'heading down
  239.         'see if this one is on the bottom edge
  240.         For j = GridSize To (GridSize * GridSize) Step GridSize
  241.             If cur = j Then GoTo flowdone
  242.         Next j
  243.         'now see if new one can connect with this one.
  244.         'if not, end flow here.
  245.         con = 0 'default is not connectable
  246.         nv$ = TileVal$(cur + 1)
  247.         If nv$ = VT$ Then con = 1
  248.         If nv$ = LU$ Then con = 1
  249.         If nv$ = RU$ Then con = 1
  250.         'if not, end flow here
  251.         If con = 0 Then GoTo flowdone
  252.         'looks like it must be connectable
  253.         TileClr(cur + 1) = 1 'turn the next piece on too
  254.         'Make it the new current char position
  255.         tc = (cur + 1): cur = tc
  256.         'find/set new direction based on character
  257.         If nv$ = LU$ Then direction = 3 'left
  258.         If nv$ = RU$ Then direction = 1 'right
  259.         If nv$ = VT$ Then direction = 2 'down
  260.     End If
  261.  
  262.     If direction = 3 Then 'heading left
  263.         'see if this one is on the bottom edge
  264.         For j = 1 To GridSize
  265.             If cur = j Then GoTo flowdone
  266.         Next j
  267.  
  268.         'now see if new one can connect with this one.
  269.         'if not, end flow here.
  270.         con = 0 'default is not connectable
  271.         nv$ = TileVal$(cur - GridSize)
  272.         If nv$ = HZ$ Then con = 1
  273.         If nv$ = RU$ Then con = 1
  274.         If nv$ = RD$ Then con = 1
  275.         'if not, end flow here
  276.         If con = 0 Then GoTo flowdone
  277.         'looks like it must be connectable
  278.         TileClr(cur - GridSize) = 1 'turn the next piece on too
  279.         'Make it the new current char position
  280.         tc = (cur - GridSize): cur = tc
  281.         'find/set new direction based on character
  282.         If nv$ = HZ$ Then direction = 3 'left
  283.         If nv$ = RU$ Then direction = 4 'up
  284.         If nv$ = RD$ Then direction = 2 'down
  285.     End If
  286.  
  287.     If direction = 4 Then 'going up
  288.         'see if this one is on the edge of board
  289.         'if so, it can't go up, so end flow...
  290.         For j = 1 To (GridSize * GridSize) Step GridSize
  291.             If cur = j Then GoTo flowdone
  292.         Next j
  293.         'now see if new one can connect with this one.
  294.         'if not, end flow here.
  295.         con = 0 'default is not connectable
  296.         nv$ = TileVal$(cur - 1)
  297.         If nv$ = VT$ Then con = 1
  298.         If nv$ = LD$ Then con = 1
  299.         If nv$ = RD$ Then con = 1
  300.         'if not, end flow here
  301.         If con = 0 Then GoTo flowdone
  302.         'looks like it must be connectable
  303.         TileClr(cur - 1) = 1 'turn the next piece on too
  304.         'Make it the new current char position
  305.         tc = (cur - 1): cur = tc
  306.         'find/set new direction based on character
  307.         If nv$ = VT$ Then direction = 4 'up
  308.         If nv$ = LD$ Then direction = 3 'left
  309.         If nv$ = RD$ Then direction = 1 'right
  310.     End If
  311.  
  312.  
  313. flowdone:
  314.  
  315. If firstdraw = 0 Then
  316.  
  317.     'draw/colorize board
  318.     For t = 2 To (GridSize * GridSize)
  319.         If TileClr(t) = 1 And TileClr2(t) = 0 Then
  320.             'show green...
  321.             SHOW TileVal$(t) + "-grn.png", TileX(t), TileY(t), TileX(t) + TileSize, TileY(t) + TileSize
  322.         End If
  323.         If TileClr(t) = 0 And TileClr2(t) = 1 Then
  324.             'show white...
  325.             SHOW TileVal$(t) + "-wht.png", TileX(t), TileY(t), TileX(t) + TileSize, TileY(t) + TileSize
  326.         End If
  327.     Next t
  328.  
  329.  
  330.     'draw/colorize board
  331.     For t = 2 To (GridSize * GridSize)
  332.         If TileClr(t) = 1 Then
  333.             tag$ = "-grn.png"
  334.         Else
  335.             tag$ = "-wht.png"
  336.         End If
  337.         SHOW TileVal$(t) + tag$, TileX(t), TileY(t), TileX(t) + TileSize, TileY(t) + TileSize
  338.     Next t
  339.  
  340.     firstdraw = 0
  341.  
  342.  
  343.  
  344. 'copy current color values
  345. For t = 1 To GridSize * GridSize
  346.     TileClr2(t) = TileClr(t)
  347.  
  348.  
  349. '===========
  350. checkforwin:
  351. '===========
  352.  
  353. all = 0
  354. For w = 1 To (GridSize * GridSize)
  355.     If TileClr(w) = 1 Then all = all + 1
  356.     If TileVal$(w) = BM$ Then all = all + 1 'add any blocks
  357.  
  358. If all = (GridSize * GridSize) Then
  359.  
  360.     ' bplus rewrote this section to fade in the You did it! sign over the gameboard =======================
  361.     ' Solved& has already been loaded after sounds at start of program
  362.     _SndPlay clap&
  363.     snap& = _NewImage(_Width, _Height, 32)
  364.     _PutImage , 0, snap&
  365.     For alph = 0 To 255
  366.         Cls
  367.         _PutImage , snap&, 0 'background
  368.         _SetAlpha alph, , Solved&
  369.         _PutImage (166, 258), Solved&
  370.         _Limit 40 ' 255 frames in 2 secs
  371.         _Display ' damn blinking!!! without this
  372.     Next
  373.     _AutoDisplay '<<<<<< back to not needing _display
  374.     _FreeImage snap&
  375.     ' end of bplus meddling ================================================================================
  376.  
  377.     Level = Level + 1
  378.  
  379.     GridSize = GridSize + 1
  380.  
  381.     If Level > MaxLevel Then Level = 1
  382.  
  383.     If GridSize > MaxGridSize Then
  384.         GridSize = 3 'MaxGridSize  'restart
  385.     End If
  386.  
  387.     GoTo newlevel
  388.  
  389.  
  390.  
  391.  
  392. Sub setmaze ()
  393.  
  394.     If Level = 1 Then
  395.         GridSize = 3
  396.         a$ = "" '3x3 MazeConnect GridSize
  397.         a$ = a$ + "hzrdru"
  398.         a$ = a$ + "hzhzhz"
  399.         a$ = a$ + "ldluld"
  400.     End If
  401.  
  402.     If Level = 2 Then
  403.         GridSize = 4
  404.         a$ = "" '4x4 MazeConnect GridSize
  405.         a$ = a$ + "vtvtruru"
  406.         a$ = a$ + "rdvtluhz"
  407.         a$ = a$ + "hzrdruhz"
  408.         a$ = a$ + "ldluldlu"
  409.     End If
  410.  
  411.     If Level = 3 Then
  412.         GridSize = 5
  413.         a$ = "" '5x5 MazeConnect GridSize
  414.         a$ = a$ + "hzrdvtvtld"
  415.         a$ = a$ + "hzhzrdrdhz"
  416.         a$ = a$ + "hzhzldhzhz"
  417.         a$ = a$ + "hzldvtluhz"
  418.         a$ = a$ + "ldvtvtvtlu"
  419.     End If
  420.  
  421.     If Level = 4 Then
  422.         GridSize = 6
  423.         a$ = "" '6x6 MazeConnect GridSize
  424.         a$ = a$ + "hzrdrurdvtru"
  425.         a$ = a$ + "hzhzhzhzrdlu"
  426.         a$ = a$ + "ldluhzhzldru"
  427.         a$ = a$ + "rdvtluhzbmhz"
  428.         a$ = a$ + "hzrdruldruhz"
  429.         a$ = a$ + "ldluldvtlulu"
  430.     End If
  431.  
  432.     If Level = 5 Then
  433.         GridSize = 7
  434.         a$ = "" '7x7 MazeConnect GridSize
  435.         a$ = "vtruvtvtrurdru"
  436.         a$ = a$ + "rdlurdruldluhz"
  437.         a$ = a$ + "ldvtluldrurdlu"
  438.         a$ = a$ + "rdvtrurdluldru"
  439.         a$ = a$ + "ldruldlurdvtlu"
  440.         a$ = a$ + "rdlurdruldvtru"
  441.         a$ = a$ + "ldvtluldvtvtlu"
  442.     End If
  443.  
  444.     If Level = 6 Then
  445.         GridSize = 8
  446.         a$ = "" '8x8 MazeConnect GridSize
  447.         a$ = a$ + "hzvtrurdrurdrubm"
  448.         a$ = a$ + "hzbmldluhzhzldru"
  449.         a$ = a$ + "ldvtrurdluhzrdlu"
  450.         a$ = a$ + "rdvtluldvtluldru"
  451.         a$ = a$ + "ldrurdvtrurdvtlu"
  452.         a$ = a$ + "bmhzhzbmldlurdru"
  453.         a$ = a$ + "rdluldvtvtvtluhz"
  454.         a$ = a$ + "ldvtvtvtvtvtvtlu"
  455.     End If
  456.  
  457.     If Level = 7 Then
  458.         GridSize = 9
  459.         a$ = "" '9x9 MazeConnect GridSize
  460.         a$ = a$ + "hzrdvtvtrurdrurdru"
  461.         a$ = a$ + "hzldvtruldluldluhz"
  462.         a$ = a$ + "ldvtruldrubmrdvtlu"
  463.         a$ = a$ + "rdruldruldruldrubm"
  464.         a$ = a$ + "hzldruldruldruldru"
  465.         a$ = a$ + "ldruhzbmldruhzbmhz"
  466.         a$ = a$ + "rdluldvtvtluldruhz"
  467.         a$ = a$ + "hzrdrurdvtrurdluhz"
  468.         a$ = a$ + "ldluldlubmldluvtlu"
  469.     End If
  470.  
  471.     If Level = 8 Then
  472.         GridSize = 10
  473.         a$ = "" '10x10 MazeConnect GridSize
  474.         a$ = a$ + "vtvtvtrurdrurdvtrubm"
  475.         a$ = a$ + "hzrdvtluhzhzldruldru"
  476.         a$ = a$ + "hzldvtvtluldruhzrdlu"
  477.         a$ = a$ + "hzbmrdvtvtruldluldru"
  478.         a$ = a$ + "hzrdlurdruhzrdvtvtlu"
  479.         a$ = a$ + "hzhzrdluhzldlurdrubm"
  480.         a$ = a$ + "hzhzhzbmldrubmhzldru"
  481.         a$ = a$ + "hzldlurdruldvtlurdlu"
  482.         a$ = a$ + "hzrdruhzldrurdruldru"
  483.         a$ = a$ + "ldluldlubmldluldvtlu"
  484.     End If
  485.  
  486.     If Level = 9 Then
  487.         GridSize = 11
  488.         a$ = "" '11x11 MazeConnect GridSize
  489.         a$ = a$ + "hzvtrubmrdvtrubmrdvtru"
  490.         a$ = a$ + "ldruldruldruldruldruhz"
  491.         a$ = a$ + "bmldruldruldruldruhzhz"
  492.         a$ = a$ + "rdruldruldruldruldluhz"
  493.         a$ = a$ + "hzldruldruldruldrurdlu"
  494.         a$ = a$ + "ldruldruldruldruhzldru"
  495.         a$ = a$ + "bmldruldruldruldlurdlu"
  496.         a$ = a$ + "rdruldruldruldrurdlubm"
  497.         a$ = a$ + "hzldruldruldvtluldvtru"
  498.         a$ = a$ + "ldruldvtlurdrurdrurdlu"
  499.         a$ = a$ + "bmldvtvtvtluldluldlubm"
  500.     End If
  501.  
  502.     If Level = 10 Then
  503.         GridSize = 12
  504.         a$ = "" '12x12 MazeConnect GridSize
  505.         a$ = a$ + "vtvtrubmbmrdrurdrurdvtru"
  506.         a$ = a$ + "bmbmhzbmrdluldluhzhzrdlu"
  507.         a$ = a$ + "bmrdlurdlurdrurdluhzldru"
  508.         a$ = a$ + "rdlurdlurdluhzhzrdlurdlu"
  509.         a$ = a$ + "ldruldvtlurdluhzhzbmldru"
  510.         a$ = a$ + "bmldvtvtruhzbmldlurdvtlu"
  511.         a$ = a$ + "rdvtvtvtluhzrdvtvtlurdru"
  512.         a$ = a$ + "ldrurdvtvtluhzrdvtvtluhz"
  513.         a$ = a$ + "rdluhzbmbmbmldlurdrurdlu"
  514.         a$ = a$ + "hzrdlurdrurdrubmhzhzhzbm"
  515.         a$ = a$ + "ldlurdluhzhzhzrdluhzldru"
  516.         a$ = a$ + "vtvtlubmldluldlubmldvtlu"
  517.     End If
  518.  
  519.     If Level = 11 Then
  520.         GridSize = 13
  521.         a$ = "" '13x13 MazeConnect GridSize
  522.         a$ = a$ + "hzvtvtvtvtvtrurdrurdrurdru"
  523.         a$ = a$ + "hzrdrurdvtruldluhzhzldluhz"
  524.         a$ = a$ + "hzhzhzhzspldvtruhzhzrdruhz"
  525.         a$ = a$ + "hzhzhzldrubmrdluldluhzhzhz"
  526.         a$ = a$ + "hzhzldvtlurdlurdvtvtluldlu"
  527.         a$ = a$ + "hzldrubmrdlubmldvtvtrurdru"
  528.         a$ = a$ + "ldruldruhzbmbmbmrdruhzhzhz"
  529.         a$ = a$ + "rdlurdluldrubmrdluhzldluhz"
  530.         a$ = a$ + "hzrdlurdruldvtlurdlubmrdlu"
  531.         a$ = a$ + "hzldruhzldrurdvtlurdruldru"
  532.         a$ = a$ + "hzrdluhzbmldlurdvtluhzrdlu"
  533.         a$ = a$ + "hzhzrdlurdvtruhzrdvtluldru"
  534.         a$ = a$ + "ldluldvtlubmldluldvtvtvtlu"
  535.     End If
  536.  
  537.     If Level = 12 Then
  538.         GridSize = 14
  539.         a$ = "" '14x14 MazeConnect GridSize
  540.         a$ = a$ + "hzrdrurdvtvtrurdrurdvtvtrubm"
  541.         a$ = a$ + "hzhzhzldvtruhzhzhzhzrdruhzbm"
  542.         a$ = a$ + "ldluhzrdruhzldluldluhzhzhzbm"
  543.         a$ = a$ + "rdruhzhzhzldvtvtvtruhzldlubm"
  544.         a$ = a$ + "hzhzhzhzhzrdrurdruhzldvtrubm"
  545.         a$ = a$ + "hzhzhzhzhzhzhzhzhzhzrdruldru"
  546.         a$ = a$ + "hzhzldluhzhzhzhzhzhzhzldvtlu"
  547.         a$ = a$ + "hzldvtruhzhzhzhzhzhzldrurdru"
  548.         a$ = a$ + "hzrdruhzldluhzhzhzhzbmldluhz"
  549.         a$ = a$ + "ldluhzldvtruhzhzhzhzrdrurdlu"
  550.         a$ = a$ + "rdruhzrdvtluhzhzldluhzhzhzbm"
  551.         a$ = a$ + "hzldluldvtvtluhzrdvtluhzhzbm"
  552.         a$ = a$ + "hzvtvtvtvtvtvtluldrurdluhzbm"
  553.         a$ = a$ + "ldvtvtvtvtvtvtvtvtluldvtlubm"
  554.     End If
  555.  
  556.     If Level = 13 Then
  557.         GridSize = 15
  558.         a$ = "" '15x15 MazeConnect GridSize
  559.         a$ = a$ + "vtvtrurdrurdrurdrubmrdvtvtvtru"
  560.         a$ = a$ + "vtruldluhzhzldluldvtlurdvtruhz"
  561.         a$ = a$ + "rdlubmbmhzldvtvtrurdvtlubmldlu"
  562.         a$ = a$ + "ldrurdruhzbmrdruhzldrurdvtvtru"
  563.         a$ = a$ + "bmhzhzldlurdluhzldruldlurdvtlu"
  564.         a$ = a$ + "rdluldrurdlubmhzrdlurdruldrubm"
  565.         a$ = a$ + "ldrubmldlurdruldlubmhzhzbmldru"
  566.         a$ = a$ + "rdlurdvtvtluldrurdruhzhzrdvtlu"
  567.         a$ = a$ + "ldvtlurdvtvtvtluhzldluhzldvtru"
  568.         a$ = a$ + "rdvtvtlurdvtvtruldrurdlurdruhz"
  569.         a$ = a$ + "ldvtrurdlubmrdlurdluhzrdluldlu"
  570.         a$ = a$ + "rdvtluldrurdlurdlurdluhzbmrdru"
  571.         a$ = a$ + "ldvtrurdluhzbmldruldruldvtluhz"
  572.         a$ = a$ + "rdvtluldruhzrdruldruldvtrurdlu"
  573.         a$ = a$ + "ldvtvtvtluldluldvtlubmbmldlubm"
  574.     End If
  575.  
  576.     dd = 1
  577.     For s = 1 To Len(a$) Step 2
  578.         b$ = Mid$(a$, s, 2)
  579.         If b$ = "vt" Then rotate dd, 1
  580.         If b$ = "hz" Then rotate dd, 1
  581.         If b$ = "ld" Then rotate dd, 2
  582.         If b$ = "lu" Then rotate dd, 2
  583.         If b$ = "rd" Then rotate dd, 2
  584.         If b$ = "ru" Then rotate dd, 2
  585.         If b$ = "bm" Then TileVal$(dd) = BM$
  586.  
  587.         dd = dd + 1
  588.     Next s
  589.  
  590.  
  591. Sub rotate (num, typ)
  592.  
  593.     'there are only two types of rotating characters,
  594.     'straight lines, or right angles...
  595.  
  596.     'randomly rotate straight character
  597.     If typ = 1 Then
  598.         If Int(Rnd * 2) = 0 Then
  599.             TileVal$(num) = VT$
  600.         Else
  601.             TileVal$(num) = HZ$
  602.         End If
  603.     End If
  604.  
  605.     'randomly rotate right angles...
  606.     If typ = 2 Then
  607.         rn = Int(Rnd * 4) + 1
  608.         If rn = 1 Then TileVal$(num) = LD$
  609.         If rn = 2 Then TileVal$(num) = LU$
  610.         If rn = 3 Then TileVal$(num) = RD$
  611.         If rn = 4 Then TileVal$(num) = RU$
  612.     End If
  613.  
  614.  
  615. Sub SHOW (i$, x1, y1, x2, y2)
  616.     'Just a little sub to load & put an image at x1/y1
  617.     ttmp = _LoadImage(i$)
  618.     _PutImage (x1, y1)-(x2, y2), ttmp
  619.     _FreeImage ttmp
  620.  
  621. Sub PPRINT (x, y, size, clr&, trans&, text$)
  622.     'This sub outputs to the current _DEST set
  623.     'It makes trans& the transparent color
  624.  
  625.     'x/y is where to print text
  626.     'size is the font size to use
  627.     'clr& is the color of your text
  628.     'trans& is the background transparent color
  629.     'text$ is the string to print
  630.  
  631.     '=== get users current write screen
  632.     orig& = _Dest
  633.  
  634.     '=== if you are using an 8 or 32 bit screen
  635.     bit = 32: If _PixelSize(0) = 1 Then bit = 256
  636.  
  637.     '=== step through your text
  638.     For t = 0 To Len(text$) - 1
  639.         '=== make a temp screen to use
  640.         pprintimg& = _NewImage(16, 16, bit)
  641.         _Dest pprintimg&
  642.         '=== set colors and print text
  643.         Cls , trans&: Color clr&
  644.         Print Mid$(text$, t + 1, 1);
  645.         '== make background color the transprent one
  646.         _ClearColor _RGB(0, 0, 0), pprintimg&
  647.         '=== go back to original screen  to output
  648.         _Dest orig&
  649.         '=== set it and forget it
  650.         x1 = x + (t * size): x2 = x1 + size
  651.         y1 = y: y2 = y + size
  652.         _PutImage (x1 - (size / 2), y1)-(x2, y2 + (size / 3)), pprintimg&
  653.         _FreeImage pprintimg&
  654.     Next
  655.  
  656.  
  657.