Author Topic: Escape from Monster Maze #3  (Read 4912 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Escape from Monster Maze #3
« on: September 05, 2019, 07:45:00 pm »
I am releasing #3 first because the Ninja version doesn't have the latest in Monster code changes and other refinements. This works pretty well I think, maybe even easier that EasyLang version because more walls are removed when monsters are added. Really it starts to become a game of Dodge ball when you get up to around 10 monsters. :)
Code: QB64: [Select]
  1. _TITLE "Escape from Monster Maze 3" 'B+ 2019-09-04
  2. ' 2019-08-31 attempt a better, smoother mouser
  3. ' 2019-09-03 Maze geneartion, nice mouse and arrow key action,
  4. '            momentum removed, just cant turn corners that fast.
  5. ' 2019-09-03 Troubles
  6. ' I either have to loose arrow keys or deactivate mouse or something
  7. ' so arrow key presses are defeated by mouse presence. :-P
  8. ' and still not 100% happy with mouse action. ;(
  9. ' I kicked out walls randomly several for each new monster but not effective for creating
  10. ' alternate paths when dang monsters are ganging up at upper left corner, yikes! no escape!!!
  11. ' to fix that
  12. ' 1. lay out another generated maze over top of current that will create meaningfull alternate route
  13. ' 2. relocate monsters when my guy gets back to start!
  14.  
  15. ' Ok I fixed it so if you start using arrow keys the mouse is disabled for 3 seconds from last arrow press
  16. ' using Luke's time stamp.  This way the mouse position wont counteract arrow key presses.
  17. ' HEY I think XOR smoothed out the mouse action a tiny bit!!! and so did opening up angles
  18. ' directions from mouse to full 90 degrees around 0, 90, 180, 270.
  19.  
  20. '2019-09-04 could have monsters follow one direction until blocked flip a coin and go on
  21. ' really want mouse smoother
  22. ' Oh dang did not have wallThk update! fixed
  23. ' OK my guy can cut corners now!!!
  24.  
  25. '2019-09-05 Escape From Monster Maze 3:
  26. ' I have another idea that will greatly simplify the mouse corner moves
  27. ' AND display step by step, no diagonal skips so all moves remain rectilinear.
  28. ' This version removes more walls because monsters can block only way through
  29. ' and goal tend either top left or bottom right critical cells.
  30. '
  31. '2 subs for my toolbox yCP - printing center alignment at pixel y row
  32. ' cSleep - wait for keypress or Mouse Click
  33.  
  34.  
  35. DECLARE LIBRARY 'give Lukes' timesstamp function a test drive!
  36.     FUNCTION time& (BYVAL null&)
  37.  
  38. CONST xmax = 700, ymax = 700 'screen
  39. CONST W = 15, H = 15, border = 50, wallThk = 2 'maze cells wide and high
  40. CONST mazeClr = &HFFFF8800
  41. CONST mDelay = 6 'slow monsters down so I can speed up limit for loops for mouse moving player
  42.  
  43. TYPE cell
  44.     x AS INTEGER
  45.     y AS INTEGER
  46.  
  47. TYPE monsterType
  48.     x AS INTEGER
  49.     y AS INTEGER
  50.     dir AS INTEGER
  51.     delay AS INTEGER
  52.     face AS INTEGER
  53.  
  54. DIM SHARED cellW AS SINGLE, cellH AS SINGLE, h_walls(W, H) AS INTEGER, v_walls(W, H) AS INTEGER
  55. cellW = (xmax - 2 * border) / W
  56. cellH = (ymax - 2 * border) / H
  57. DIM SHARED stopTime&, nMonsters AS INTEGER
  58. REDIM SHARED m(1 TO 1) AS monsterType
  59.  
  60. '        Locals for Main module code
  61. DIM k$, d, start, i, j, test AS cell, tmp AS LONG
  62.  
  63. SCREEN _NEWIMAGE(xmax, ymax, 32)
  64. _SCREENMOVE 100, 20
  65. nMonsters = 3
  66.     init_walls
  67.     generate_maze
  68.     'open gate a bottom right corner to esacpe
  69.     h_walls(W - 1, H) = 0
  70.     nMonsters = nMonsters + 1
  71.     REDIM m(1 TO nMonsters) AS monsterType
  72.     FOR i = 1 TO nMonsters
  73.         newMonster (i)
  74.         FOR j = 1 TO 2 'for every monster make 4 escape hatches
  75.             test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  76.             WHILE h_walls(test.x, test.y) = 0
  77.                 test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  78.             WEND
  79.             h_walls(test.x, test.y) = 0
  80.             test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  81.             WHILE v_walls(test.x, test.y) = 0
  82.                 test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  83.             WEND
  84.             v_walls(test.x, test.y) = 0
  85.         NEXT
  86.     NEXT
  87.     px = 0: py = 0: start = TIMER
  88.     WHILE 1
  89.         CLS
  90.         show_maze
  91.         FOR i = 1 TO nMonsters
  92.             IF m(i).delay MOD 4 = 0 THEN m(i).face = 1 - m(i).face 'toggle face
  93.             IF m(i).face = 1 THEN
  94.                 monster1 (m(i).x + .5) * cellW + border, (m(i).y + .5) * cellH + border
  95.             ELSE
  96.                 monster2 (m(i).x + .5) * cellW + border, (m(i).y + .5) * cellH + border
  97.             END IF
  98.             m(i).delay = m(i).delay - 1
  99.             IF m(i).delay = 0 THEN
  100.                 m(i).delay = mDelay
  101.                 IF moveOK(m(i).x, m(i).y, m(i).dir) AND RND < .5 THEN 'most of time monsters on momentum
  102.                     move m(i).x, m(i).y, m(i).dir
  103.                 ELSE
  104.                     d = INT(RND * 4) + 1
  105.                     WHILE moveOK(m(i).x, m(i).y, d) = 0
  106.                         d = INT(RND * 4) + 1
  107.                     WEND
  108.                     move m(i).x, m(i).y, d
  109.                     m(i).dir = d
  110.                 END IF 'move OK
  111.                 IF m(i).x = px AND m(i).y = py THEN
  112.                     makeFace (px + .5) * cellW + border, (py + .5) * cellH + border, 1
  113.                     _DISPLAY
  114.                     _DELAY 1
  115.                     px = 0: py = 0
  116.                 END IF 'intersect my guy
  117.                 IF (m(i).x = W - 1 AND m(i).y = H - 1) OR (m(i).x = 0 AND m(i).y = 0) THEN newMonster i
  118.             END IF 'monster delay
  119.             'EDIT 2019-09-07 I think the game plays better without the below block
  120.             'FOR j = 1 TO nMonsters
  121.             '    IF j <> i AND m(j).x = m(i).x AND m(j).y = m(i).y THEN newMonster i
  122.             'NEXT
  123.         NEXT
  124.  
  125.         IF mouseOK(0) = -1 THEN 'might not need this?
  126.             WHILE _MOUSEINPUT: WEND
  127.             mx = INT((_MOUSEX - border) / cellW) 'convert to maze cell
  128.             my = INT((_MOUSEY - border) / cellH)
  129.             dx = mx - px: dy = my - py '                     dist in cells of mouse to player
  130.             IF dx < 0 THEN dx = -1: IF dy < 0 THEN dy = -1 '  one step at a time
  131.             IF dx > 0 THEN dx = 1: IF dy > 0 THEN dy = 1
  132.             adx = ABS(dx): ady = ABS(dy) '                   which is bigger difference = priority move
  133.             IF dx = -1 THEN
  134.                 IF dy = -1 THEN
  135.                     IF adx > ady THEN
  136.                         IF moveOK(px, py, 4) THEN move px, py, 4
  137.                     ELSE
  138.                         IF moveOK(px, py, 1) THEN move px, py, 1
  139.                     END IF
  140.                 ELSEIF dy = 0 THEN
  141.                     IF moveOK(px, py, 4) THEN move px, py, 4
  142.                 ELSEIF dy = 1 THEN
  143.                     IF adx > ady THEN
  144.                         IF moveOK(px, py, 4) THEN move px, py, 4
  145.                     ELSE
  146.                         IF moveOK(px, py, 2) THEN move px, py, 2
  147.                     END IF
  148.                 END IF
  149.             ELSEIF dx = 0 THEN
  150.                 IF dy = -1 THEN
  151.                     IF moveOK(px, py, 1) THEN move px, py, 1
  152.                 ELSEIF dy = 1 THEN
  153.                     IF moveOK(px, py, 2) THEN move px, py, 2
  154.                 END IF
  155.             ELSEIF dx = 1 THEN
  156.                 IF dy = -1 THEN
  157.                     IF adx > ady THEN
  158.                         IF moveOK(px, py, 3) THEN move px, py, 3
  159.                     ELSE
  160.                         IF moveOK(px, py, 1) THEN move px, py, 1
  161.                     END IF
  162.                 ELSEIF dy = 0 THEN
  163.                     IF moveOK(px, py, 3) THEN move px, py, 3
  164.                 ELSEIF dy = 1 THEN
  165.                     IF adx > ady THEN
  166.                         IF moveOK(px, py, 3) THEN move px, py, 3
  167.                     ELSE
  168.                         IF moveOK(px, py, 2) THEN move px, py, 2
  169.                     END IF
  170.                 END IF
  171.             END IF
  172.         END IF
  173.  
  174.         k$ = INKEY$ 'key press takes precedence over mouse
  175.         IF LEN(k$) = 2 THEN
  176.             SELECT CASE ASC(k$, 2) 'turn off mouse control for 3 secs after arrow press
  177.                 CASE 72: tmp = mouseOK(1): IF moveOK(px, py, 1) THEN move px, py, 1 'up
  178.                 CASE 80: tmp = mouseOK(1): IF moveOK(px, py, 2) THEN move px, py, 2 'down
  179.                 CASE 77: tmp = mouseOK(1): IF moveOK(px, py, 3) THEN move px, py, 3 'right
  180.                 CASE 75: tmp = mouseOK(1): IF moveOK(px, py, 4) THEN move px, py, 4 'left
  181.             END SELECT
  182.         END IF
  183.         makeFace (px + .5) * cellW + border, (py + .5) * cellH + border, 0
  184.         yCP 20, STR$(nMonsters) + " Monsters  " + STR$((TIMER - start) \ 1) + " Secs"
  185.         _DISPLAY
  186.         _LIMIT 30
  187.         IF px = W - 1 AND py = H THEN EXIT WHILE
  188.     WEND
  189.     yCP ymax - 20, "You escaped in" + STR$((TIMER - start) \ 1) + " secs, click to continue..."
  190.     _DISPLAY
  191.     cSleep
  192.  
  193. SUB move (x AS INTEGER, y AS INTEGER, direction AS INTEGER)
  194.     SELECT CASE direction
  195.         CASE 1: y = y - 1
  196.         CASE 2: y = y + 1
  197.         CASE 3: x = x + 1
  198.         CASE 4: x = x - 1
  199.     END SELECT
  200.  
  201. FUNCTION moveOK% (curX AS INTEGER, curY AS INTEGER, direction AS INTEGER)
  202.     ' is the way blocked or even inside maze, assuming move is not OK
  203.     '  _____     ________
  204.     '  |x, y     |x+1, y        the walls of the cell x, y are at right and above,
  205.     '  ________                 x+1 has the next wall and y+1 is the next horizontal separator
  206.     '  |x, y+1
  207.     SELECT CASE direction
  208.         CASE 1 'up
  209.             IF curY - 1 >= 0 THEN
  210.                 IF h_walls(curX, curY) = 0 THEN moveOK = -1
  211.             END IF
  212.         CASE 2 'down
  213.             IF curY + 1 <= H THEN ' OR (curX = W - 1 AND curY = H - 1) THEN 'let through gate bottom right corner
  214.                 IF h_walls(curX, curY + 1) = 0 THEN moveOK = -1
  215.             END IF
  216.         CASE 3 'right
  217.             IF curX + 1 <= W - 1 THEN
  218.                 IF v_walls(curX + 1, curY) = 0 THEN moveOK = -1
  219.             END IF
  220.         CASE 4 'left
  221.             IF curX - 1 >= 0 THEN
  222.                 IF v_walls(curX, curY) = 0 THEN moveOK = -1
  223.             END IF
  224.     END SELECT
  225.  
  226. FUNCTION mouseOK% (mode%) '1 set, 0 checks if time is up yes -1, no 0
  227.     IF mode% > 0 THEN 'set
  228.         stopTime& = timestamp& + 3 '3 secs before mouse access
  229.     ELSE
  230.         IF timestamp& - stopTime& > 0 THEN mouseOK% = -1 ELSE mouseOK% = 0
  231.     END IF
  232.  
  233. FUNCTION timestamp& 'try Luke's Timestamp for checking times
  234.     timestamp& = time&(0)
  235.  
  236. SUB makeFace (x, y, white)
  237.     IF white THEN fcirc x, y, cellW / 3, &HFF994422 ELSE fcirc x, y, cellW / 3, &HFF88AAFF
  238.     fcirc x - 3 * cellW / 24, y, cellW / 14, &HFFFFFFFF
  239.     fcirc x + 3 * cellW / 24, y, cellW / 14, &HFFFFFFFF
  240.     fcirc x - 3 * cellW / 24, y + 1, cellW / 28, &HFF000000
  241.     fcirc x + 3 * cellW / 24, y + 1, cellW / 28, &HFF000000
  242.     LINE (x - cellW / 12, y + cellW / 6)-STEP(cellW / 6, 2), &HFFFF4444, BF
  243.  
  244. SUB newMonster (i AS INTEGER)
  245.     DIM x AS INTEGER, y AS INTEGER, j AS INTEGER
  246.     restart:
  247.     x = RND * 7 * W / 8 + W / 8 - 1: y = RND * 7 * H / 8 + H / 8 - 1
  248.     FOR j = 1 TO nMonsters
  249.         IF j <> i AND m(j).x = x AND m(j).y = y THEN GOTO restart
  250.     NEXT
  251.     m(i).x = x: m(i).y = y
  252.     m(i).dir = INT(RND * 4) + 1
  253.     m(i).delay = INT(RND * 8) + 1
  254.     m(i).face = INT(RND * 2)
  255.  
  256. SUB monster1 (x, y)
  257.     fcirc x, y, cellW / 2.5, &HFF990000
  258.     LINE (x - cellW / 6, y - 2)-STEP(cellW / 18, 1), &HFF000000, BF
  259.     LINE (x + cellW / 12, y - 2)-STEP(cellW / 18, 1), &HFF000000, BF
  260.     LINE (x - cellW / 12, y + cellW / 6)-STEP(cellW / 6, 2), &HFF000000, BF
  261.  
  262. SUB monster2 (x, y)
  263.     fcirc x, y, cellW / 2.5, &HFF990000
  264.     LINE (x - cellW / 6, y - 6)-STEP(cellW / 18, 1), &HFF000000, BF
  265.     LINE (x + cellW / 12, y - 6)-STEP(cellW / 18, 1), &HFF000000, BF
  266.     fcirc x, y + cellW / 6, cellW / 6, &HFF000000
  267.  
  268. SUB cSleep 'wait for keypress or mouseclick
  269.     DIM wayt
  270.     wayt = 1
  271.     WHILE wayt
  272.         WHILE _MOUSEINPUT: WEND
  273.         IF _MOUSEBUTTON(1) THEN wayt = 0
  274.         IF LEN(INKEY$) THEN wayt = 0
  275.     WEND
  276.  
  277. SUB yCP (y, s$) 'for xmax pixel wide graphics screen
  278.     _PRINTSTRING ((_WIDTH - LEN(s$) * 8) / 2, y), s$
  279.  
  280. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  281.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  282.     DIM X AS INTEGER, Y AS INTEGER
  283.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  284.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  285.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  286.     WHILE X > Y
  287.         RadiusError = RadiusError + Y * 2 + 1
  288.         IF RadiusError >= 0 THEN
  289.             IF X <> Y + 1 THEN
  290.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  291.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  292.             END IF
  293.             X = X - 1
  294.             RadiusError = RadiusError - X * 2
  295.         END IF
  296.         Y = Y + 1
  297.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  298.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  299.     WEND
  300.  
  301. ' From SmallBASIC code written by Chris WS developer
  302. ' Backtracking maze generator by chrisws 2016-06-30 now found at
  303. ' https://github.com/smallbasic/smallbasic.github.io/blob/5601c8bc1d794c5b143d863555bb7c15a5966a3c/samples/node/1623.bas
  304. '
  305. ' Chris notes:
  306. ' https://en.wikipedia.org/wiki/Maze_generation_algorithm
  307. ' - Starting from a random cell,
  308. ' - Selects a random neighbouring cell that has not been visited.
  309. ' - Remove the wall between the two cells and marks the new cell as visited,
  310. '   and adds it to the stack to facilitate backtracking.
  311. ' - Continues with a cell that has no unvisited neighbours being considered a dead-end.
  312. '   When at a dead-end it backtracks through the path until it reaches a cell with an
  313. '   unvisited neighbour, continuing the path generation by visiting this new,
  314. '   unvisited cell (creating a new junction).
  315. '   This process continues until every cell has been visited, backtracking all the
  316. '   way back to the beginning cell. We can be sure every cell is visited.
  317.  
  318. SUB init_walls ()
  319.     DIM x AS INTEGER, y AS INTEGER
  320.     FOR x = 0 TO W
  321.         FOR y = 0 TO H
  322.             v_walls(x, y) = 1
  323.             h_walls(x, y) = 1
  324.         NEXT
  325.     NEXT
  326.  
  327. SUB show_maze ()
  328.     DIM py AS SINGLE, px AS SINGLE, y AS INTEGER, x AS INTEGER
  329.     py = border
  330.     FOR y = 0 TO H
  331.         px = border
  332.         FOR x = 0 TO W
  333.             IF x < W AND h_walls(x, y) = 1 THEN
  334.                 LINE (px, py)-STEP(cellW + wallThk, wallThk), mazeClr, BF
  335.             END IF
  336.             IF y < H AND v_walls(x, y) = 1 THEN
  337.                 LINE (px, py)-STEP(wallThk, cellH + wallThk), mazeClr, BF
  338.             END IF
  339.             px = px + cellW
  340.         NEXT
  341.         py = py + cellH
  342.     NEXT
  343.  
  344. SUB rand_cell (rWx, rHy)
  345.     rWx = INT(RND * 1000) MOD W: rHy = INT(RND * 1000) MOD H
  346.  
  347. SUB get_unvisited (visited() AS INTEGER, current AS cell, unvisited() AS cell, uvi AS INTEGER)
  348.     REDIM unvisited(0) AS cell
  349.     DIM x AS INTEGER, y AS INTEGER
  350.     x = current.x: y = current.y: uvi = 0
  351.     IF x > 0 THEN
  352.         IF visited(x - 1, y) = 0 THEN
  353.             uvi = uvi + 1
  354.             REDIM _PRESERVE unvisited(uvi) AS cell
  355.             unvisited(uvi).x = x - 1: unvisited(uvi).y = y
  356.         END IF
  357.     END IF
  358.     IF x < W - 1 THEN
  359.         IF visited(x + 1, y) = 0 THEN
  360.             uvi = uvi + 1
  361.             REDIM _PRESERVE unvisited(uvi) AS cell
  362.             unvisited(uvi).x = x + 1: unvisited(uvi).y = y
  363.         END IF
  364.     END IF
  365.     IF y > 0 THEN
  366.         IF visited(x, y - 1) = 0 THEN
  367.             uvi = uvi + 1
  368.             REDIM _PRESERVE unvisited(uvi) AS cell
  369.             unvisited(uvi).x = x: unvisited(uvi).y = y - 1
  370.         END IF
  371.     END IF
  372.     IF y < H - 1 THEN
  373.         IF visited(x, y + 1) = 0 THEN
  374.             uvi = uvi + 1
  375.             REDIM _PRESERVE unvisited(uvi) AS cell
  376.             unvisited(uvi).x = x: unvisited(uvi).y = y + 1
  377.         END IF
  378.     END IF
  379.  
  380. SUB generate_maze ()
  381.     DIM visited(W, H) AS INTEGER
  382.     DIM num_visited AS INTEGER, num_cells AS INTEGER, si AS INTEGER
  383.     DIM cnt AS INTEGER, rc AS INTEGER, x AS INTEGER, y AS INTEGER
  384.     REDIM stack(0) AS cell
  385.     DIM curr_cell AS cell, next_cell AS cell, cur_cell AS cell
  386.  
  387.     rand_cell cur_cell.x, cur_cell.y
  388.     visited(curr_cell.x, curr_cell.y) = 1
  389.     num_visited = 1: num_cells = W * H: si = 0
  390.     WHILE num_visited < num_cells
  391.         REDIM cells(0) AS cell
  392.         cnt = 0
  393.         get_unvisited visited(), curr_cell, cells(), cnt
  394.         IF cnt > 0 THEN
  395.             ' choose randomly one of the current cell's unvisited neighbours
  396.             rc = INT(RND * 100) MOD cnt + 1
  397.             next_cell.x = cells(rc).x: next_cell.y = cells(rc).y
  398.             ' push the current cell to the stack
  399.             si = si + 1
  400.             REDIM _PRESERVE stack(si) AS cell
  401.             stack(si).x = curr_cell.x: stack(si).y = curr_cell.y
  402.             ' remove the wall between the current cell and the chosen cell
  403.             IF next_cell.x = curr_cell.x THEN
  404.                 x = next_cell.x: y = max(next_cell.y, curr_cell.y)
  405.                 h_walls(x, y) = 0
  406.             ELSE
  407.                 x = max(next_cell.x, curr_cell.x): y = next_cell.y
  408.                 v_walls(x, y) = 0
  409.             END IF
  410.             ' make the chosen cell the current cell and mark it as visited
  411.             curr_cell.x = next_cell.x: curr_cell.y = next_cell.y
  412.             visited(curr_cell.x, curr_cell.y) = 1
  413.             num_visited = num_visited + 1
  414.         ELSEIF si > 0 THEN
  415.             ' pop a cell from the stack and make it the current cell
  416.             curr_cell.x = stack(si).x: curr_cell.y = stack(si).y
  417.             si = si - 1
  418.             REDIM _PRESERVE stack(si) AS cell
  419.         ELSE
  420.             EXIT WHILE
  421.         END IF
  422.     WEND
  423.  
  424. FUNCTION max (a, b)
  425.     IF a > b THEN max = a ELSE max = b
  426.  

« Last Edit: September 07, 2019, 08:49:34 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #1 on: September 05, 2019, 08:20:47 pm »
Escape #2 Ninja version with diagonal corner maneuvers but more walls blocking way out:
Code: QB64: [Select]
  1. _TITLE "Escape from Monster Maze 2 Ninja" 'B+ 2019-09-04 & 5
  2. ' 2019-08-31 attempt a better, smoother mouser
  3. ' 2019-09-03 Maze geneartion, nice mouse and arrow key action,
  4. '            momentum removed, just cant turn corners that fast.
  5. ' 2019-09-03 Troubles
  6. ' I either have to loose arrow keys or deactivate mouse or something
  7. ' so arrow key presses are defeated by mouse presence. :-P
  8. ' and still not 100% happy with mouse action. ;(
  9. ' I kicked out walls randomly several for each new monster but not effective for creating
  10. ' alternate paths when dang monsters are ganging up at upper left corner, yikes! no escape!!!
  11. ' to fix that
  12. ' 1. lay out another generated maze over top of current that will create meaningfull alternate route
  13. ' 2. relocate monsters when my guy gets back to start!
  14.  
  15. ' Ok I fixed it so if you start using arrow keys the mouse is disabled for 3 seconds from last arrow press
  16. ' using Luke's time stamp.  This way the mouse position wont counteract arrow key presses.
  17. ' HEY I think XOR smoothed out the mouse action a tiny bit!!! and so did opening up angles
  18. ' directions from mouse to full 90 degrees around 0, 90, 180, 270.
  19.  
  20. '2019-09-04 could have monsters follow one direction until blocked flip a coin and go on
  21. ' really want mouse smoother
  22. ' Oh dang did not have wallThk update! fixed
  23. ' OK my guy can cut corners now!!!
  24.  
  25. '2019-09-05 Escape From Monster Maze 3:
  26. ' I have another idea that will greatly simplify the mouse corner moves
  27. ' AND display step by step, no diagonal skips so all moves remain rectilinear.
  28. ' This version removes more walls because monsters can block only way through
  29. ' and goal tend either top left or bottom right critical cells.
  30. '
  31. '2 subs for my toolbox yCP - printing center alignment at pixel y row
  32. ' cSleep - wait for keypress or Mouse Click
  33.  
  34. '2019-09-05 plug in mouse action code that cuts corners in one step, Ninja!
  35. ' Because Ninja can cut corners (go diagonally) 2 steps in one,
  36. ' it removes less walls per monster added, maybe none??
  37.  
  38. DECLARE LIBRARY 'give Lukes' timesstamp function a test drive!
  39.     FUNCTION time& (BYVAL null&)
  40.  
  41. CONST xmax = 700, ymax = 700 'screen
  42. CONST W = 15, H = 15, border = 50, wallThk = 2 'maze cells wide and high
  43. CONST mazeClr = &HFFFF8800
  44. CONST mDelay = 6 'slow monsters down so I can speed up limit for loops for mouse moving player
  45.  
  46. TYPE cell
  47.     x AS INTEGER
  48.     y AS INTEGER
  49.  
  50. TYPE monsterType
  51.     x AS INTEGER
  52.     y AS INTEGER
  53.     dir AS INTEGER
  54.     delay AS INTEGER
  55.     face AS INTEGER
  56.  
  57. DIM SHARED cellW AS SINGLE, cellH AS SINGLE, h_walls(W, H) AS INTEGER, v_walls(W, H) AS INTEGER
  58. cellW = (xmax - 2 * border) / W
  59. cellH = (ymax - 2 * border) / H
  60. DIM SHARED stopTime&, nMonsters AS INTEGER
  61. REDIM SHARED m(1 TO 1) AS monsterType
  62.  
  63. '        Locals for Main module code
  64. DIM k$, d, start, i, j, test AS cell, tmp AS LONG
  65.  
  66. SCREEN _NEWIMAGE(xmax, ymax, 32)
  67. _SCREENMOVE 100, 20
  68. nMonsters = 3
  69.     init_walls
  70.     generate_maze
  71.     'open gate a bottom right corner to esacpe
  72.     h_walls(W - 1, H) = 0
  73.     nMonsters = nMonsters + 1
  74.     REDIM m(1 TO nMonsters) AS monsterType
  75.     FOR i = 1 TO nMonsters
  76.         newMonster (i)
  77.         FOR j = 1 TO 1 'for every monster make 4 escape hatches
  78.             test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  79.             WHILE h_walls(test.x, test.y) = 0
  80.                 test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  81.             WEND
  82.             h_walls(test.x, test.y) = 0
  83.             test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  84.             WHILE v_walls(test.x, test.y) = 0
  85.                 test.x = INT(RND * (W - 2)) + 1: test.y = INT(RND * (H - 2)) + 1
  86.             WEND
  87.             v_walls(test.x, test.y) = 0
  88.         NEXT
  89.     NEXT
  90.     px = 0: py = 0: start = TIMER
  91.     WHILE 1
  92.         CLS
  93.         show_maze
  94.         FOR i = 1 TO nMonsters
  95.             IF m(i).delay MOD 4 = 0 THEN m(i).face = 1 - m(i).face 'toggle face
  96.             IF m(i).face = 1 THEN
  97.                 monster1 (m(i).x + .5) * cellW + border, (m(i).y + .5) * cellH + border
  98.             ELSE
  99.                 monster2 (m(i).x + .5) * cellW + border, (m(i).y + .5) * cellH + border
  100.             END IF
  101.             m(i).delay = m(i).delay - 1
  102.             IF m(i).delay = 0 THEN
  103.                 m(i).delay = mDelay
  104.                 IF moveOK(m(i).x, m(i).y, m(i).dir) AND RND < .5 THEN 'most of time monsters on momentum
  105.                     move m(i).x, m(i).y, m(i).dir
  106.                 ELSE
  107.                     d = INT(RND * 4) + 1
  108.                     WHILE moveOK(m(i).x, m(i).y, d) = 0
  109.                         d = INT(RND * 4) + 1
  110.                     WEND
  111.                     move m(i).x, m(i).y, d
  112.                     m(i).dir = d
  113.                 END IF 'move OK
  114.                 IF m(i).x = px AND m(i).y = py THEN
  115.                     makeFace (px + .5) * cellW + border, (py + .5) * cellH + border, 1
  116.                     _DISPLAY
  117.                     _DELAY 1
  118.                     px = 0: py = 0
  119.                 END IF 'intersect my guy
  120.                 IF (m(i).x = W - 1 AND m(i).y = H - 1) OR (m(i).x = 0 AND m(i).y = 0) THEN newMonster i
  121.             END IF 'monster delay
  122.             'EDIT 2019-09-07 I think game plays better without next code block
  123.             'FOR j = 1 TO nMonsters
  124.             '    IF j <> i AND m(j).x = m(i).x AND m(j).y = m(i).y THEN newMonster i
  125.             'NEXT
  126.         NEXT
  127.  
  128.         IF mouseOK(0) = -1 THEN 'might not need this?
  129.             WHILE _MOUSEINPUT: WEND
  130.             mx = INT((_MOUSEX - border) / cellW): my = INT((_MOUSEY - border) / cellH) 'convert to maze cell
  131.             dx = mx - px: dy = my - py
  132.             IF dx < 0 THEN dx = -1: IF dy < 0 THEN dy = -1
  133.             IF dx > 0 THEN dx = 1: IF dy > 0 THEN dy = 1
  134.  
  135.             IF dx = -1 THEN
  136.                 IF px - 1 >= 0 THEN
  137.                     IF dy = -1 THEN
  138.                         IF py - 1 >= 0 THEN
  139.                             IF (v_walls(px, py) = 0 AND h_walls(px - 1, py) = 0) OR (h_walls(px, py) = 0 AND v_walls(px, py - 1) = 0) THEN
  140.                                 px = px - 1: py = py - 1
  141.                             END IF
  142.                         END IF
  143.                     ELSEIF dy = 0 THEN
  144.                         IF v_walls(px, py) = 0 THEN px = px - 1
  145.                     ELSEIF dy = 1 THEN
  146.                         IF py + 1 <= H - 1 OR (px = W - 1 AND py + 1 = H) THEN
  147.                             IF v_walls(px, py) = 0 AND h_walls(px - 1, py + 1) = 0 OR (h_walls(px, py + 1) = 0 AND v_walls(px, py + 1) = 0) THEN
  148.                                 px = px - 1: py = py + 1
  149.                             END IF
  150.                         END IF
  151.                     END IF
  152.                 END IF
  153.             END IF
  154.  
  155.             IF dx = 0 THEN
  156.                 IF dy = -1 THEN
  157.                     IF py - 1 >= 0 THEN
  158.                         IF h_walls(px, py) = 0 THEN py = py - 1
  159.                     END IF
  160.                 ELSEIF dy = 1 THEN
  161.                     IF py + 1 <= H - 1 OR (px = W - 1 AND py + 1 = H) THEN
  162.                         IF h_walls(px, py + 1) = 0 THEN py = py + 1
  163.                     END IF
  164.                 END IF
  165.             END IF
  166.  
  167.  
  168.             IF dx = 1 THEN
  169.                 IF px + 1 <= W - 1 THEN
  170.                     IF dy = -1 THEN
  171.                         IF py - 1 >= 0 THEN
  172.                             IF h_walls(px, py) = 0 AND v_walls(px + 1, py - 1) = 0 OR v_walls(px + 1, py) = 0 AND h_walls(px + 1, py) = 0 THEN
  173.                                 px = px + 1: py = py - 1
  174.                             END IF
  175.                         END IF
  176.                     ELSEIF dy = 0 THEN
  177.                         IF v_walls(px + 1, py) = 0 THEN px = px + 1
  178.                     ELSEIF dy = 1 THEN
  179.                         IF py + 1 <= H - 1 OR (px = W - 1 AND py + 1 = H) THEN
  180.                             IF h_walls(px, py + 1) = 0 AND v_walls(px + 1, py + 1) = 0 OR v_walls(px + 1, py) = 0 AND h_walls(px + 1, py + 1) = 0 THEN
  181.                                 px = px + 1: py = py + 1
  182.                             END IF
  183.                         END IF
  184.                     END IF
  185.                 END IF
  186.             END IF
  187.  
  188.         END IF
  189.  
  190.         k$ = INKEY$ 'key press takes precedence over mouse
  191.         IF LEN(k$) = 2 THEN
  192.             SELECT CASE ASC(k$, 2) 'turn off mouse control for 3 secs after arrow press
  193.                 CASE 72: tmp = mouseOK(1): IF moveOK(px, py, 1) THEN move px, py, 1 'up
  194.                 CASE 80: tmp = mouseOK(1): IF moveOK(px, py, 2) THEN move px, py, 2 'down
  195.                 CASE 77: tmp = mouseOK(1): IF moveOK(px, py, 3) THEN move px, py, 3 'right
  196.                 CASE 75: tmp = mouseOK(1): IF moveOK(px, py, 4) THEN move px, py, 4 'left
  197.             END SELECT
  198.         END IF
  199.         makeFace (px + .5) * cellW + border, (py + .5) * cellH + border, 0
  200.         yCP 20, STR$(nMonsters) + " Monsters  " + STR$((TIMER - start) \ 1) + " Secs"
  201.         _DISPLAY
  202.         _LIMIT 30
  203.         IF px = W - 1 AND py = H THEN EXIT WHILE
  204.     WEND
  205.     yCP ymax - 20, "You escaped in" + STR$((TIMER - start) \ 1) + " secs, click to continue..."
  206.     _DISPLAY
  207.     cSleep
  208.  
  209. SUB move (x AS INTEGER, y AS INTEGER, direction AS INTEGER)
  210.     SELECT CASE direction
  211.         CASE 1: y = y - 1
  212.         CASE 2: y = y + 1
  213.         CASE 3: x = x + 1
  214.         CASE 4: x = x - 1
  215.     END SELECT
  216.  
  217. FUNCTION moveOK% (curX AS INTEGER, curY AS INTEGER, direction AS INTEGER)
  218.     ' is the way blocked or even inside maze, assuming move is not OK
  219.     '  _____     ________
  220.     '  |x, y     |x+1, y        the walls of the cell x, y are at right and above,
  221.     '  ________                 x+1 has the next wall and y+1 is the next horizontal separator
  222.     '  |x, y+1
  223.     SELECT CASE direction
  224.         CASE 1 'up
  225.             IF curY - 1 >= 0 THEN
  226.                 IF h_walls(curX, curY) = 0 THEN moveOK = -1
  227.             END IF
  228.         CASE 2 'down
  229.             IF curY + 1 <= H THEN ' OR (curX = W - 1 AND curY = H - 1) THEN 'let through gate bottom right corner
  230.                 IF h_walls(curX, curY + 1) = 0 THEN moveOK = -1
  231.             END IF
  232.         CASE 3 'right
  233.             IF curX + 1 <= W - 1 THEN
  234.                 IF v_walls(curX + 1, curY) = 0 THEN moveOK = -1
  235.             END IF
  236.         CASE 4 'left
  237.             IF curX - 1 >= 0 THEN
  238.                 IF v_walls(curX, curY) = 0 THEN moveOK = -1
  239.             END IF
  240.     END SELECT
  241.  
  242. FUNCTION mouseOK% (mode%) '1 set, 0 checks if time is up yes -1, no 0
  243.     IF mode% > 0 THEN 'set
  244.         stopTime& = timestamp& + 3 '3 secs before mouse access
  245.     ELSE
  246.         IF timestamp& - stopTime& > 0 THEN mouseOK% = -1 ELSE mouseOK% = 0
  247.     END IF
  248.  
  249. FUNCTION timestamp& 'try Luke's Timestamp for checking times
  250.     timestamp& = time&(0)
  251.  
  252. SUB makeFace (x, y, white)
  253.     IF white THEN fcirc x, y, cellW / 3, &HFF994422 ELSE fcirc x, y, cellW / 3, &HFF88AAFF
  254.     fcirc x - 3 * cellW / 24, y, cellW / 14, &HFFFFFFFF
  255.     fcirc x + 3 * cellW / 24, y, cellW / 14, &HFFFFFFFF
  256.     fcirc x - 3 * cellW / 24, y + 1, cellW / 28, &HFF000000
  257.     fcirc x + 3 * cellW / 24, y + 1, cellW / 28, &HFF000000
  258.     LINE (x - cellW / 12, y + cellW / 6)-STEP(cellW / 6, 2), &HFFFF4444, BF
  259.  
  260. SUB newMonster (i AS INTEGER)
  261.     DIM x AS INTEGER, y AS INTEGER, j AS INTEGER
  262.     restart:
  263.     x = RND * 7 * W / 8 + W / 8 - 1: y = RND * 7 * H / 8 + H / 8 - 1
  264.     FOR j = 1 TO nMonsters
  265.         IF j <> i AND m(j).x = x AND m(j).y = y THEN GOTO restart
  266.     NEXT
  267.     m(i).x = x: m(i).y = y
  268.     m(i).dir = INT(RND * 4) + 1
  269.     m(i).delay = INT(RND * 8) + 1
  270.     m(i).face = INT(RND * 2)
  271.  
  272. SUB monster1 (x, y)
  273.     fcirc x, y, cellW / 2.5, &HFF990000
  274.     LINE (x - cellW / 6, y - 2)-STEP(cellW / 18, 1), &HFF000000, BF
  275.     LINE (x + cellW / 12, y - 2)-STEP(cellW / 18, 1), &HFF000000, BF
  276.     LINE (x - cellW / 12, y + cellW / 6)-STEP(cellW / 6, 2), &HFF000000, BF
  277.  
  278. SUB monster2 (x, y)
  279.     fcirc x, y, cellW / 2.5, &HFF990000
  280.     LINE (x - cellW / 6, y - 6)-STEP(cellW / 18, 1), &HFF000000, BF
  281.     LINE (x + cellW / 12, y - 6)-STEP(cellW / 18, 1), &HFF000000, BF
  282.     fcirc x, y + cellW / 6, cellW / 6, &HFF000000
  283.  
  284. SUB cSleep 'wait for keypress or mouseclick
  285.     DIM wayt
  286.     wayt = 1
  287.     WHILE wayt
  288.         WHILE _MOUSEINPUT: WEND
  289.         IF _MOUSEBUTTON(1) THEN wayt = 0
  290.         IF LEN(INKEY$) THEN wayt = 0
  291.     WEND
  292.  
  293. SUB yCP (y, s$) 'for xmax pixel wide graphics screen
  294.     _PRINTSTRING ((_WIDTH - LEN(s$) * 8) / 2, y), s$
  295.  
  296. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  297.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  298.     DIM X AS INTEGER, Y AS INTEGER
  299.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  300.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  301.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  302.     WHILE X > Y
  303.         RadiusError = RadiusError + Y * 2 + 1
  304.         IF RadiusError >= 0 THEN
  305.             IF X <> Y + 1 THEN
  306.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  307.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  308.             END IF
  309.             X = X - 1
  310.             RadiusError = RadiusError - X * 2
  311.         END IF
  312.         Y = Y + 1
  313.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  314.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  315.     WEND
  316.  
  317. ' From SmallBASIC code written by Chris WS developer
  318. ' Backtracking maze generator by chrisws 2016-06-30 now found at
  319. ' https://github.com/smallbasic/smallbasic.github.io/blob/5601c8bc1d794c5b143d863555bb7c15a5966a3c/samples/node/1623.bas
  320. '
  321. ' Chris notes:
  322. ' https://en.wikipedia.org/wiki/Maze_generation_algorithm
  323. ' - Starting from a random cell,
  324. ' - Selects a random neighbouring cell that has not been visited.
  325. ' - Remove the wall between the two cells and marks the new cell as visited,
  326. '   and adds it to the stack to facilitate backtracking.
  327. ' - Continues with a cell that has no unvisited neighbours being considered a dead-end.
  328. '   When at a dead-end it backtracks through the path until it reaches a cell with an
  329. '   unvisited neighbour, continuing the path generation by visiting this new,
  330. '   unvisited cell (creating a new junction).
  331. '   This process continues until every cell has been visited, backtracking all the
  332. '   way back to the beginning cell. We can be sure every cell is visited.
  333.  
  334. SUB init_walls ()
  335.     DIM x AS INTEGER, y AS INTEGER
  336.     FOR x = 0 TO W
  337.         FOR y = 0 TO H
  338.             v_walls(x, y) = 1
  339.             h_walls(x, y) = 1
  340.         NEXT
  341.     NEXT
  342.  
  343. SUB show_maze ()
  344.     DIM py AS SINGLE, px AS SINGLE, y AS INTEGER, x AS INTEGER
  345.     py = border
  346.     FOR y = 0 TO H
  347.         px = border
  348.         FOR x = 0 TO W
  349.             IF x < W AND h_walls(x, y) = 1 THEN
  350.                 LINE (px, py)-STEP(cellW + wallThk, wallThk), mazeClr, BF
  351.             END IF
  352.             IF y < H AND v_walls(x, y) = 1 THEN
  353.                 LINE (px, py)-STEP(wallThk, cellH + wallThk), mazeClr, BF
  354.             END IF
  355.             px = px + cellW
  356.         NEXT
  357.         py = py + cellH
  358.     NEXT
  359.  
  360. SUB rand_cell (rWx, rHy)
  361.     rWx = INT(RND * 1000) MOD W: rHy = INT(RND * 1000) MOD H
  362.  
  363. SUB get_unvisited (visited() AS INTEGER, current AS cell, unvisited() AS cell, uvi AS INTEGER)
  364.     REDIM unvisited(0) AS cell
  365.     DIM x AS INTEGER, y AS INTEGER
  366.     x = current.x: y = current.y: uvi = 0
  367.     IF x > 0 THEN
  368.         IF visited(x - 1, y) = 0 THEN
  369.             uvi = uvi + 1
  370.             REDIM _PRESERVE unvisited(uvi) AS cell
  371.             unvisited(uvi).x = x - 1: unvisited(uvi).y = y
  372.         END IF
  373.     END IF
  374.     IF x < W - 1 THEN
  375.         IF visited(x + 1, y) = 0 THEN
  376.             uvi = uvi + 1
  377.             REDIM _PRESERVE unvisited(uvi) AS cell
  378.             unvisited(uvi).x = x + 1: unvisited(uvi).y = y
  379.         END IF
  380.     END IF
  381.     IF y > 0 THEN
  382.         IF visited(x, y - 1) = 0 THEN
  383.             uvi = uvi + 1
  384.             REDIM _PRESERVE unvisited(uvi) AS cell
  385.             unvisited(uvi).x = x: unvisited(uvi).y = y - 1
  386.         END IF
  387.     END IF
  388.     IF y < H - 1 THEN
  389.         IF visited(x, y + 1) = 0 THEN
  390.             uvi = uvi + 1
  391.             REDIM _PRESERVE unvisited(uvi) AS cell
  392.             unvisited(uvi).x = x: unvisited(uvi).y = y + 1
  393.         END IF
  394.     END IF
  395.  
  396. SUB generate_maze ()
  397.     DIM visited(W, H) AS INTEGER
  398.     DIM num_visited AS INTEGER, num_cells AS INTEGER, si AS INTEGER
  399.     DIM cnt AS INTEGER, rc AS INTEGER, x AS INTEGER, y AS INTEGER
  400.     REDIM stack(0) AS cell
  401.     DIM curr_cell AS cell, next_cell AS cell, cur_cell AS cell
  402.  
  403.     rand_cell cur_cell.x, cur_cell.y
  404.     visited(curr_cell.x, curr_cell.y) = 1
  405.     num_visited = 1: num_cells = W * H: si = 0
  406.     WHILE num_visited < num_cells
  407.         REDIM cells(0) AS cell
  408.         cnt = 0
  409.         get_unvisited visited(), curr_cell, cells(), cnt
  410.         IF cnt > 0 THEN
  411.             ' choose randomly one of the current cell's unvisited neighbours
  412.             rc = INT(RND * 100) MOD cnt + 1
  413.             next_cell.x = cells(rc).x: next_cell.y = cells(rc).y
  414.             ' push the current cell to the stack
  415.             si = si + 1
  416.             REDIM _PRESERVE stack(si) AS cell
  417.             stack(si).x = curr_cell.x: stack(si).y = curr_cell.y
  418.             ' remove the wall between the current cell and the chosen cell
  419.             IF next_cell.x = curr_cell.x THEN
  420.                 x = next_cell.x: y = max(next_cell.y, curr_cell.y)
  421.                 h_walls(x, y) = 0
  422.             ELSE
  423.                 x = max(next_cell.x, curr_cell.x): y = next_cell.y
  424.                 v_walls(x, y) = 0
  425.             END IF
  426.             ' make the chosen cell the current cell and mark it as visited
  427.             curr_cell.x = next_cell.x: curr_cell.y = next_cell.y
  428.             visited(curr_cell.x, curr_cell.y) = 1
  429.             num_visited = num_visited + 1
  430.         ELSEIF si > 0 THEN
  431.             ' pop a cell from the stack and make it the current cell
  432.             curr_cell.x = stack(si).x: curr_cell.y = stack(si).y
  433.             si = si - 1
  434.             REDIM _PRESERVE stack(si) AS cell
  435.         ELSE
  436.             EXIT WHILE
  437.         END IF
  438.     WEND
  439.  
  440. FUNCTION max (a, b)
  441.     IF a > b THEN max = a ELSE max = b
  442.  
  443.  
« Last Edit: September 07, 2019, 08:51:17 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Escape from Monster Maze #3
« Reply #2 on: September 05, 2019, 09:16:48 pm »
Woo Hoo!!!  Escaped in 53 seconds and avoided 4 monsters....  Unusual feeling... So this is what it's like to win? Woo Hoo!
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #3 on: September 05, 2019, 09:29:53 pm »
Yeah Johnno, if you are stuck, try charging right through monsters, sometimes you survive!

Ninja is nice because can duck around a corner fast!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Escape from Monster Maze #3
« Reply #4 on: September 05, 2019, 09:36:43 pm »
Hmm... Luck and I have never really been on speaking terms... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #5 on: September 05, 2019, 09:40:41 pm »
Hmm... Luck and I have never really been on speaking terms... lol

Ha! check this out:
Lucky 7 in 7 see the diagonal!.PNG
* Lucky 7 in 7 see the diagonal!.PNG (Filesize: 21.06 KB, Dimensions: 698x732, Views: 157)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Escape from Monster Maze #3
« Reply #6 on: September 05, 2019, 09:50:58 pm »
Quick question. How difficult would it be to make the game either 2.5 or 3D? Twofold reason for asking. 1. It would make for a more interesting game... not that this game isn't... lol (dodged THAT bullet... phew...) and 2. While you are working on that, I want be envious by your fast completion times... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #7 on: September 05, 2019, 10:04:43 pm »
Hi Johnno,

3D? whew blew my mind for sec!

Hmm... Raycasting or 15 x 15 x 15 Qube Basic?

Maybe I'll wait for Petr's 3D editor, stay tuned! There is that question of working out the views.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Escape from Monster Maze #3
« Reply #8 on: September 06, 2019, 11:43:55 am »
Hi BPlus, Hi Johnno! That's a very nice idea! First I publish the editor. In the currently under construction version can do walls, floors and ceilings and second program, that can display it and allow you to browse it. Then I could add a program to insert the maze generated by your program into the editor. This will be in the MAPTRIANGLE 3D thread. Today! + your code included to editor later! I go ready it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #9 on: September 07, 2019, 08:56:58 pm »
I made a small edit to the 2 game versions. When monsters collided I had one restarted with a newMonster call but I think having monsters pop in at random all the time was too much specially as their numbers increase.

Today I got up to 30 Monsters and about 17 secs through maze, not luck about 120 walls are removed for 30 monsters and mouse moves guy around very well without walls!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Escape from Monster Maze #3
« Reply #10 on: September 08, 2019, 01:15:22 pm »
Yes I did it!

 
mazeninja.jpg


just after 3 hundred of death this is the result!

« Last Edit: September 08, 2019, 01:19:01 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Escape from Monster Maze #3
« Reply #11 on: September 09, 2019, 05:45:29 am »
Russian Optimization

 
maze_ru.PNG


skins of monsters is as orcs no humans

and I play only in this new Russian version

start is better in a random place quarter northwest

Russian Cipher Cells Danilin as Labirinth



 
ruscodeus.gif
« Last Edit: September 10, 2019, 03:30:46 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Escape from Monster Maze #3
« Reply #12 on: September 09, 2019, 11:59:20 am »
American Ingenuity:
 
Escape from Rusky Maze.PNG


Rusky 10 to 1.PNG
* Rusky 10 to 1.PNG (Filesize: 24.36 KB, Dimensions: 1290x767, Views: 158)
« Last Edit: September 09, 2019, 12:07:21 pm by bplus »