Author Topic: Cave Map Maker  (Read 3739 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Cave Map Maker
« on: September 13, 2020, 03:15:13 am »
This is for people that play roll playing games that use caves, or paths, or whatever and need a completely random map grid. Making it was a challenge but I knew I could do it. It has some A.I. in the fact that it starts out making the START and FINISH areas first, then it generates different caves (or paths) starting from the START area and eventually ending up at the FINISH area. It usually takes a few different paths in order to make the right way to go, which I figured would make your roll playing game more challenging and fun anyway. I haven't added a Save feature, not sure if I will or not, but I did add a Print feature to print it on your printer. When the Title Bar says "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit," that means it is finished generating that one. Usually it only takes a few seconds or less. Once in awhile it only needs one direct cave that goes straight to it. The A.I. points the cave(s) toward the FINISH but not on every turn. I also just added C to copy the image to the Clipboard so you can paste it to any graphics program you have to save or change it. If you don't like the map it makes, when it's done making it, press the Space Bar for another one. It's almost limitless on how many different maps it can make.
Tell me what you think, thanks.

The grid is 800 x 800 with 35 x 35 cells (20 pixels x 20 pixels per cell). It is a white background with black lines so it's printer-friendly and takes up almost an entire page printing it.

Code: QB64: [Select]
  1. 'Cave Map Maker by SierraKen
  2. '9-13-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _TITLE "Cave Map Maker"
  6. picture& = _NEWIMAGE(800, 800, 32)
  7. SCREEN picture&
  8. PAINT (2, 2), _RGB32(255, 255, 255)
  9. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  10. 'Start Location
  11. startlocation:
  12. stx = INT(RND * 650)
  13. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  14. stx = stx + 70
  15. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  16. 'End Location
  17. endlocation:
  18. endx = INT(RND * 650)
  19. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  20. endx = endx + 70
  21. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  22. 'Make Grid
  23. FOR x = 70 TO 730 STEP 20
  24.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  25. FOR y = 70 TO 730 STEP 20
  26.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  27. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  28. _PRINTSTRING (stx - 10, 760), "START"
  29. _PRINTSTRING (endx - 10, 30), "FINISH"
  30.  
  31. start2:
  32. x = stx
  33. y = 750
  34. 'Make Paths
  35.     _LIMIT 500
  36.     direction:
  37.     olddir = dir
  38.     dir = INT(RND * 35) + 1
  39.     tt = tt + 1
  40.     IF tt = 5 THEN
  41.         tt = 0
  42.         IF x > endx THEN
  43.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  44.             x = x - 20
  45.         END IF
  46.         IF x < endx THEN
  47.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  48.             x = x + 20
  49.         END IF
  50.     END IF
  51.     IF dir > 0 AND dir < 10 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  52.     IF dir >= 10 AND dir <= 20 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  53.     IF dir > 20 AND dir <= 30 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  54.     IF dir > 30 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  55.     IF x = endx AND y - 20 = 50 THEN GOTO again:
  56.  
  57. check:
  58. t = t + 1
  59. IF x < 70 THEN x = x + 20: RETURN
  60. IF x > 720 THEN x = x - 20: RETURN
  61. IF x = endx AND y = 70 THEN GOTO again:
  62. IF y <= 70 AND x <> endx THEN GOTO start2:
  63. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): RETURN
  64.  
  65. again:
  66. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  67. a$ = INKEY$
  68. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  69. IF a$ = CHR$(27) THEN END
  70. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  71. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  72. GOTO again:
  73.  
  74. printing:
  75. picture2& = _COPYIMAGE(0)
  76. _PRINTIMAGE picture2&
  77. _FREEIMAGE picture2&
  78.  
« Last Edit: September 13, 2020, 03:17:18 am by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #1 on: September 13, 2020, 05:02:59 pm »
Here's one that goes a tiny bit more directly there with less caves.

Code: QB64: [Select]
  1. 'Cave Map Maker by SierraKen
  2. '9-13-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _TITLE "Cave Map Maker"
  6. picture& = _NEWIMAGE(800, 800, 32)
  7. SCREEN picture&
  8. PAINT (2, 2), _RGB32(255, 255, 255)
  9. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  10. 'Start Location
  11. startlocation:
  12. stx = INT(RND * 650)
  13. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  14. stx = stx + 70
  15. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  16. 'End Location
  17. endlocation:
  18. endx = INT(RND * 650)
  19. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  20. endx = endx + 70
  21. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  22. 'Make Grid
  23. FOR x = 70 TO 730 STEP 20
  24.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  25. FOR y = 70 TO 730 STEP 20
  26.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  27. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  28. _PRINTSTRING (stx - 10, 760), "START"
  29. _PRINTSTRING (endx - 10, 30), "FINISH"
  30.  
  31. start2:
  32. x = stx
  33. y = 750
  34. 'Make Paths
  35.     _LIMIT 500
  36.     direction:
  37.     olddir = dir
  38.     dir = INT(RND * 35) + 1
  39.     tt = tt + 1
  40.     IF tt = 3 THEN
  41.         tt = 0
  42.         IF x > endx THEN
  43.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  44.             x = x - 20
  45.         END IF
  46.         IF x < endx THEN
  47.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  48.             x = x + 20
  49.         END IF
  50.     END IF
  51.     IF dir > 0 AND dir < 10 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  52.     IF dir >= 10 AND dir <= 20 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  53.     IF dir > 20 AND dir <= 30 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  54.     IF dir > 30 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  55.     IF x = endx AND y - 20 = 50 THEN GOTO again:
  56.  
  57. check:
  58. t = t + 1
  59. IF x < 70 THEN x = x + 20: RETURN
  60. IF x > 720 THEN x = x - 20: RETURN
  61. IF x = endx AND y = 70 THEN GOTO again:
  62. IF y <= 70 AND x <> endx THEN GOTO start2:
  63. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): RETURN
  64.  
  65. again:
  66. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  67. a$ = INKEY$
  68. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  69. IF a$ = CHR$(27) THEN END
  70. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  71. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  72. GOTO again:
  73.  
  74. printing:
  75. picture2& = _COPYIMAGE(0)
  76. _PRINTIMAGE picture2&
  77. _FREEIMAGE picture2&
  78.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #2 on: September 13, 2020, 05:22:58 pm »
Here's one that goes almost completely directly from START to FINISH. Which would be totally cool for even adding to a computer game. This one also only needs one cave per map. I added an example picture of what this makes below.

Code: QB64: [Select]
  1. 'Cave Map Maker by SierraKen
  2. '9-13-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _TITLE "Cave Map Maker"
  6. picture& = _NEWIMAGE(800, 800, 32)
  7. SCREEN picture&
  8. PAINT (2, 2), _RGB32(255, 255, 255)
  9. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  10. 'Start Location
  11. startlocation:
  12. stx = INT(RND * 650)
  13. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  14. stx = stx + 70
  15. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  16. 'End Location
  17. endlocation:
  18. endx = INT(RND * 650)
  19. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  20. endx = endx + 70
  21. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  22. 'Make Grid
  23. FOR x = 70 TO 730 STEP 20
  24.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  25. FOR y = 70 TO 730 STEP 20
  26.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  27. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  28. _PRINTSTRING (stx - 10, 760), "START"
  29. _PRINTSTRING (endx - 10, 30), "FINISH"
  30.  
  31. start2:
  32. x = stx
  33. y = 750
  34. 'Make Paths
  35.     _LIMIT 500
  36.     direction:
  37.     olddir = dir
  38.     dir = INT(RND * 35) + 1
  39.     tt = tt + 1
  40.     IF tt = 10 THEN
  41.         tt = 0
  42.         IF x > endx THEN
  43.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  44.             x = x - 20
  45.         END IF
  46.         IF x < endx THEN
  47.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  48.             x = x + 20
  49.         END IF
  50.     END IF
  51.     IF dir > 0 AND dir < 10 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  52.     IF dir >= 10 AND dir <= 20 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  53.     IF dir > 20 AND dir <= 30 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  54.     IF dir > 30 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  55.     IF x = endx AND y - 20 = 50 THEN GOTO again:
  56.  
  57. check:
  58. t = t + 1
  59. IF x < 70 THEN x = x + 20: RETURN
  60. IF x > 720 THEN x = x - 20: RETURN
  61. IF x = endx AND y = 70 THEN GOTO again:
  62. IF y <= 70 AND x <> endx THEN y = y + 20: RETURN
  63. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): RETURN
  64.  
  65. again:
  66. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  67. a$ = INKEY$
  68. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  69. IF a$ = CHR$(27) THEN END
  70. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  71. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  72. GOTO again:
  73.  
  74. printing:
  75. picture2& = _COPYIMAGE(0)
  76. _PRINTIMAGE picture2&
  77. _FREEIMAGE picture2&
  78.  

Cave Map 1.jpg
* Cave Map 1.jpg (Filesize: 162.75 KB, Dimensions: 800x800, Views: 180)
« Last Edit: September 13, 2020, 05:25:50 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #3 on: September 13, 2020, 06:47:09 pm »
And then of course I HAD to make the crazy maze version. I've made similar maze generators in the past but this is the first time every single one of them have a way out. If people used this as a roll playing map, it might take TONS of time to get through it. LOL There is a picture below.

Code: QB64: [Select]
  1. 'Cave Map Maker by SierraKen
  2. '9-13-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _TITLE "Cave Map Maker"
  6. picture& = _NEWIMAGE(800, 800, 32)
  7. SCREEN picture&
  8. PAINT (2, 2), _RGB32(255, 255, 255)
  9. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  10. 'Start Location
  11. startlocation:
  12. stx = INT(RND * 650)
  13. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  14. stx = stx + 70
  15. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  16. 'End Location
  17. endlocation:
  18. endx = INT(RND * 650)
  19. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  20. endx = endx + 70
  21. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  22. 'Make Grid
  23. FOR x = 70 TO 730 STEP 20
  24.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  25. FOR y = 70 TO 730 STEP 20
  26.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  27. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  28. _PRINTSTRING (stx - 10, 760), "START"
  29. _PRINTSTRING (endx - 10, 30), "FINISH"
  30.  
  31. start2:
  32. x = stx
  33. y = 750
  34. 'Make Paths
  35. _LIMIT 500
  36.     direction:
  37.     dir = INT(RND * 35) + 1
  38.     tt = tt + 1
  39.     IF tt = 8 THEN
  40.         tt = 0
  41.         IF x > endx THEN
  42.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  43.             x = x - 20
  44.         END IF
  45.         IF x < endx THEN
  46.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  47.             x = x + 20
  48.         END IF
  49.     END IF
  50.     IF dir > 0 AND dir < 10 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  51.     IF dir >= 10 AND dir <= 20 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  52.     IF dir > 20 AND dir <= 30 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  53.     IF dir > 30 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  54.     IF x = endx AND y - 20 = 50 THEN GOTO more:
  55.  
  56.  
  57. check:
  58. IF x < 70 THEN x = x + 20: RETURN
  59. IF x > 720 THEN x = x - 20: RETURN
  60. IF x = endx AND y = 70 THEN GOTO more:
  61. IF y <= 70 AND x <> endx THEN y = y + 20: RETURN
  62. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): RETURN
  63.  
  64. more:
  65. cells = INT(RND * 300) + 1000
  66. FOR cell = 1 TO cells
  67.     calc:
  68.     x2 = INT(RND * 680) + 70
  69.     y2 = INT(RND * 780) + 70
  70.     IF x2 / 20 <> INT(x2 / 20) THEN GOTO calc:
  71.     IF y2 / 20 <> INT(y2 / 20) THEN GOTO calc:
  72.     x2 = x2 + 10
  73.     y2 = y2 - 10
  74.     vh = INT(RND * 2) + 1
  75.     length = INT(RND * 10) + 1
  76.     l = length * 5
  77.  
  78.     IF vh = 1 THEN
  79.         LINE (x2 + 1, y2)-(x2 + l - 1, y2), _RGB32(255, 255, 255)
  80.     END IF
  81.     IF vh = 2 THEN
  82.         LINE (x2, y2)-(x2, y2 + l - 1), _RGB32(255, 255, 255)
  83.     END IF
  84. NEXT cell
  85.  
  86. again:
  87. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  88. a$ = INKEY$
  89. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  90. IF a$ = CHR$(27) THEN END
  91. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  92. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  93. GOTO again:
  94.  
  95. printing:
  96. picture2& = _COPYIMAGE(0)
  97. _PRINTIMAGE picture2&
  98. _FREEIMAGE picture2&
  99.  
Cave Map 2.jpg
* Cave Map 2.jpg (Filesize: 131.35 KB, Dimensions: 800x800, Views: 169)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #4 on: September 13, 2020, 07:24:22 pm »
2 lines of code turns it into a City Map Maker. :)

Code: QB64: [Select]
  1. 'City Map Maker by SierraKen
  2. '9-13-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _TITLE "City Map Maker"
  6. picture& = _NEWIMAGE(800, 800, 32)
  7. SCREEN picture&
  8. PAINT (2, 2), _RGB32(255, 255, 255)
  9. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  10. 'Start Location
  11. startlocation:
  12. stx = INT(RND * 650)
  13. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  14. stx = stx + 70
  15. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  16. 'End Location
  17. endlocation:
  18. endx = INT(RND * 650)
  19. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  20. endx = endx + 70
  21. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  22. 'Make Grid
  23. FOR x = 70 TO 730 STEP 20
  24.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  25. FOR y = 70 TO 730 STEP 20
  26.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  27. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  28. _PRINTSTRING (stx - 10, 760), "START"
  29. _PRINTSTRING (endx - 10, 30), "FINISH"
  30.  
  31. start2:
  32. x = stx
  33. y = 750
  34. 'Make Paths
  35.     _LIMIT 500
  36.     direction:
  37.     t = t + 1
  38.     IF t = 10 THEN dir = INT(RND * 35) + 1: t = 0
  39.     tt = tt + 1
  40.     IF tt = 10 THEN
  41.         tt = 0
  42.         IF x > endx THEN
  43.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  44.             x = x - 20
  45.         END IF
  46.         IF x < endx THEN
  47.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  48.             x = x + 20
  49.         END IF
  50.     END IF
  51.     IF dir > 0 AND dir < 10 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  52.     IF dir >= 10 AND dir <= 20 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  53.     IF dir > 20 AND dir <= 30 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  54.     IF dir > 30 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  55.     IF x = endx AND y - 20 = 50 THEN GOTO again:
  56.  
  57. check:
  58. t = t + 1
  59. IF x < 70 THEN x = x + 20: RETURN
  60. IF x > 720 THEN x = x - 20: RETURN
  61. IF x = endx AND y = 70 THEN GOTO again:
  62. IF y <= 70 AND x <> endx THEN y = y + 20: RETURN
  63. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): RETURN
  64.  
  65. again:
  66. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  67. a$ = INKEY$
  68. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  69. IF a$ = CHR$(27) THEN END
  70. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  71. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  72. GOTO again:
  73.  
  74. printing:
  75. picture2& = _COPYIMAGE(0)
  76. _PRINTIMAGE picture2&
  77. _FREEIMAGE picture2&
  78.  
City Map 1.jpg
* City Map 1.jpg (Filesize: 153.86 KB, Dimensions: 800x800, Views: 169)
« Last Edit: September 13, 2020, 07:25:29 pm by SierraKen »

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Cave Map Maker
« Reply #5 on: September 14, 2020, 08:22:26 pm »
Those are pretty neat, and I like the copy to clipboard function. I can take it to a image editor, mess with the various filters and contrast and get a good looking basic cave shape.

PS I pasted one to Image Composer and alternated a neon glow effect with a negative effect.
Sprite 6.jpg
* Sprite 6.jpg (Filesize: 58.92 KB, Dimensions: 800x800, Views: 195)
« Last Edit: September 14, 2020, 08:27:24 pm by OldMoses »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #6 on: September 14, 2020, 08:29:47 pm »
Wow that looks wild, thanks OldMoses! I tested it with PAINT also and it fills in the caves and streets very nicely. I didn't post it though because it wouldn't be too great for printers. But people can do like you did and use Fill to fill in too. :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Cave Map Maker
« Reply #7 on: September 14, 2020, 10:50:58 pm »
I kinda like the city map.

@SierraKen what was the thing you changed to make it so neat?

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #8 on: September 14, 2020, 11:07:08 pm »
Thanks B+. I added a counter and when the counter reaches 10, then it changes direction. The counter is actually in 2 places so it counts them at different times. This program has been beating me up the last couple days though. I've made it look like a simple maze, adding streets of different lengths and locations. But the maze itself is only good for kids like under 5 years old because they are so simple to finish. I remember you showing us the maze you made that time. I don't know if I could ever do that though, which is why I've been trying to make this one better. But here is what I have so far. I don't know if I will (or can) make it any better than this though. I don't like how it makes giant looking parking lots sometimes. I tried for around an hour or more to fix that, but to no prevail.

Code: QB64: [Select]
  1. 'City Map Maker by SierraKen
  2. '9-14-2020
  3. 'Each cell is 20 pixels x 20 pixels.
  4. start:
  5. _LIMIT 200
  6. _TITLE "City Map Maker"
  7. x = 0: y = 0: x2 = 0: y2 = 0
  8. picture& = _NEWIMAGE(800, 800, 32)
  9. SCREEN picture&
  10. PAINT (2, 2), _RGB32(255, 255, 255)
  11. LINE (50, 50)-(750, 750), _RGB32(0, 0, 0), B
  12. 'Start Location
  13. startlocation:
  14. stx = INT(RND * 650)
  15. IF stx / 20 <> INT(stx / 20) THEN GOTO startlocation:
  16. stx = stx + 70
  17. LINE (stx, 750)-(stx + 20, 750), _RGB32(255, 255, 255)
  18. 'End Location
  19. endlocation:
  20. endx = INT(RND * 650)
  21. IF endx / 20 <> INT(endx / 20) THEN GOTO endlocation:
  22. endx = endx + 70
  23. LINE (endx, 50)-(endx + 20, 50), _RGB32(255, 255, 255)
  24. 'Make Grid
  25. FOR x = 70 TO 730 STEP 20
  26.     LINE (x, 50)-(x, 750), _RGB32(0, 0, 0)
  27. FOR y = 70 TO 730 STEP 20
  28.     LINE (50, y)-(750, y), _RGB32(0, 0, 0)
  29. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 255)
  30. _PRINTSTRING (stx - 10, 760), "START"
  31. _PRINTSTRING (endx - 10, 30), "FINISH"
  32.  
  33. start2:
  34. t = 0: tt = 0
  35. x = stx
  36. y = 750
  37. x2 = 0: y2 = 0
  38. 'Make Paths
  39. _LIMIT 200
  40.     direction:
  41.     t = t + 1
  42.     IF t = 10 THEN dir = INT(RND * 100) + 1: t = 0
  43.     tt = tt + 1
  44.     IF tt = 5 THEN
  45.         tt = 0
  46.         IF x > endx THEN
  47.             LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255)
  48.             x = x - 20
  49.         END IF
  50.         IF x < endx THEN
  51.             LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255)
  52.             x = x + 20
  53.         END IF
  54.     END IF
  55.     IF dir > 0 AND dir < 40 THEN LINE (x, y)-(x, y - 20), _RGB32(255, 255, 255): x = x - 20: GOSUB check:
  56.     IF dir >= 40 AND dir <= 80 THEN LINE (x + 20, y)-(x + 20, y - 20), _RGB32(255, 255, 255): x = x + 20: GOSUB check:
  57.     IF dir > 80 AND dir <= 90 THEN LINE (x, y - 20)-(x + 20, y - 20), _RGB32(255, 255, 255): y = y - 20: GOSUB check:
  58.     IF dir > 90 THEN LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255): y = y + 20: GOSUB check:
  59.     IF x = endx AND y - 20 = 50 THEN GOTO more:
  60.  
  61. check:
  62. t = t + 1
  63. IF x < 70 THEN x = x + 20
  64. IF x > 720 THEN x = x - 20
  65. IF x = endx AND y = 70 THEN GOTO more:
  66. IF y <= 70 AND x <> endx THEN y = y + 20
  67. IF y > 730 THEN y = 730: LINE (x, y)-(x + 20, y), _RGB32(255, 255, 255)
  68.  
  69. check2:
  70. IF x2 < 70 THEN x2 = x2 + 20
  71. IF x2 > 720 THEN x2 = x2 - 20
  72. IF y2 <= 70 AND x2 <> endx THEN y2 = y2 + 20
  73. IF y2 > 730 THEN y2 = 730: LINE (x2, y2)-(x2 + 20, y2), _RGB32(255, 255, 255)
  74.  
  75.  
  76. more:
  77. walls = INT(RND * 10) + 3
  78. FOR w = 1 TO walls
  79.     thewall:
  80.     x2 = INT(RND * 700) + 70
  81.     y2 = INT(RND * 700) + 70
  82.     IF x2 / 20 <> INT(x2 / 20) THEN GOTO thewall:
  83.     IF y2 / 20 <> INT(y2 / 20) THEN GOTO thewall:
  84.     x2 = x2 + 10
  85.     y2 = y2 + 10
  86.     dir2 = INT(RND * 100) + 1
  87.     walllength = INT(RND * 3) + 3
  88.     FOR ww = 1 TO walllength
  89.         IF x2 > endx THEN
  90.             LINE (x2, y2)-(x2, y2 - 20), _RGB32(255, 255, 255)
  91.             x2 = x2 - 20
  92.         END IF
  93.         IF x2 < endx THEN
  94.             LINE (x2 + 20, y2)-(x2 + 20, y2 - 20), _RGB32(255, 255, 255)
  95.             x2 = x2 + 20
  96.         END IF
  97.         IF dir2 > 0 AND dir2 < 40 THEN LINE (x2, y2)-(x2, y2 - 20), _RGB32(255, 255, 255): x2 = x2 - 20: GOSUB check2:
  98.         IF dir2 >= 40 AND dir2 <= 80 THEN LINE (x2 + 20, y2)-(x2 + 20, y2 - 20), _RGB32(255, 255, 255): x2 = x2 + 20: GOSUB check2:
  99.         IF dir2 > 80 AND dir2 <= 90 THEN LINE (x2, y2 - 20)-(x2 + 20, y2 - 20), _RGB32(255, 255, 255): y2 = y2 - 20: GOSUB check2:
  100.         IF dir2 > 90 THEN LINE (x2, y2)-(x2 + 20, y2), _RGB32(255, 255, 255): y2 = y2 + 20: GOSUB check2:
  101.     NEXT ww
  102.  
  103. again:
  104. _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  105. a$ = INKEY$
  106. IF a$ = " " THEN t = 0: dir = 0: GOTO start:
  107. IF a$ = CHR$(27) THEN END
  108. IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  109. IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  110. GOTO again:
  111.  
  112. printing:
  113. picture2& = _COPYIMAGE(0)
  114. _PRINTIMAGE picture2&
  115. _FREEIMAGE picture2&
  116.  


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Cave Map Maker
« Reply #9 on: September 14, 2020, 11:29:40 pm »
That kind of layout reminds me of Pac Man, if the ghoulies were coming down one "street" you could duck off into another route.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #10 on: September 14, 2020, 11:57:28 pm »
LOL That's true!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #11 on: September 23, 2020, 02:11:13 am »
I have decided to make a more complicated path maker, with smaller blocks. Plus there's less code on this version and written a lot differently. Check it out. There's no "Start" or "Finish" words but I figured that is obvious. Sometimes there will even be 2 open Finish areas. This one determines when it's finished just when the path reaches the top. Like the other one, sometimes there's a lot of open space, sometimes a direct path, etc.

Space Bar makes a new one. C copies to clipboard. P prints it on the printer.

Code: QB64: [Select]
  1. 'Path Maker by SierraKen
  2. '9-22-2020
  3. 'This version is more of a path maker using a grid.
  4. start:
  5. picture& = _NEWIMAGE(600, 600, 32)
  6. SCREEN picture&
  7. PAINT (2, 2), _RGB32(255, 255, 255)
  8. LINE (50, 50)-(550, 550), _RGB32(0, 0, 0), B
  9.  
  10. 'grid
  11. FOR x = 50 TO 550 STEP 10
  12.     LINE (x, 50)-(x, 550), _RGB32(0, 0, 0)
  13. FOR y = 50 TO 550 STEP 10
  14.     LINE (50, y)-(550, y), _RGB32(0, 0, 0)
  15. xx = 295
  16. yy = 545
  17. LINE (xx - 5, yy + 5)-(xx + 5, yy + 5), _RGB32(255, 255, 255)
  18. _LIMIT 100
  19.     direction:
  20.     d = INT(RND * 100) + 1
  21.     IF d < 33 THEN dir = 1 'left
  22.     IF d >= 33 AND d < 66 THEN dir = 2 'right
  23.     IF d >= 66 AND d < 84 THEN dir = 3 'up
  24.     IF d >= 84 THEN dir = 4 'down
  25.     IF olddir = d THEN GOTO direction:
  26.     olddir = d
  27.     length:
  28.     length = INT(RND * 4) + 2
  29.     IF length / 2 <> INT(length / 2) THEN GOTO length:
  30.     FOR ee = 1 TO length
  31.         IF dir = 1 THEN
  32.             'left
  33.             IF xx < 65 THEN xx = 65
  34.             LINE (xx - 5, yy - 5)-(xx - 5, yy + 5), _RGB32(255, 255, 255)
  35.             xx = xx - 10
  36.         END IF
  37.         IF dir = 2 THEN
  38.             'right
  39.             IF xx > 535 THEN xx = 535
  40.             LINE (xx + 5, yy - 5)-(xx + 5, yy + 5), _RGB32(255, 255, 255)
  41.             xx = xx + 10
  42.         END IF
  43.         IF dir = 3 THEN
  44.             'up
  45.             IF yy < 55 THEN GOTO done:
  46.             LINE (xx - 5, yy - 5)-(xx + 5, yy - 5), _RGB32(255, 255, 255)
  47.             yy = yy - 10
  48.         END IF
  49.         IF dir = 4 THEN
  50.             'down
  51.             IF yy > 535 THEN yy = 535
  52.             LINE (xx - 5, yy + 5)-(xx + 5, yy + 5), _RGB32(255, 255, 255)
  53.             yy = yy + 10
  54.         END IF
  55.     NEXT ee
  56. done:
  57.     _LIMIT 10
  58.     _TITLE "Press Space Bar for another one, P to Print, C to copy to Clipboard, or Esc to Quit."
  59.     a$ = INKEY$
  60.     IF a$ = " " THEN GOTO start:
  61.     IF a$ = CHR$(27) THEN END
  62.     IF a$ = "p" OR a$ = "P" THEN GOSUB printing:
  63.     IF a$ = "c" OR a$ = "C" THEN _CLIPBOARDIMAGE = picture&
  64. printing:
  65. picture2& = _COPYIMAGE(0)
  66. _PRINTIMAGE picture2&
  67. _FREEIMAGE picture2&
  68.  
« Last Edit: September 23, 2020, 01:28:17 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Cave Map Maker
« Reply #12 on: September 23, 2020, 01:24:50 pm »
Here is an example picture of the path maker I made, posted right above this post.

Path Maker Example.jpg
* Path Maker Example.jpg (Filesize: 192.56 KB, Dimensions: 600x600, Views: 147)
« Last Edit: September 23, 2020, 01:26:29 pm by SierraKen »