Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sweet little circuit game space maker
#1
Sets up a board with no dead end tracks, might be used for race track or city roads layout or just nice designs.

Code: (Select All)
Option _Explicit
_Title "Little game Circuit game space" 'b+ 2024-02-18
Randomize Timer
Dim Shared SW, SH: SW = 800: SH = 600
Screen _NewImage(SW, SH, 32)
_ScreenMove 200, 60
Dim As Long UbX, UbY, cx, cy, lastTarget, targets, tx, ty, dx, dy
UbX = 80: UbY = 60 ' the max width and height of board cells
Do ' test board layouts
    Cls: ReDim board$(1 To UbX, 1 To UbY) 'resets
    cx = UbX \ 2: cy = UbY \ 2: lastTarget = 30
    For targets = 1 To lastTarget
        tryAgain: ' to avoid dead end streets
        If targets <> lastTarget Then ' stay off the edges
            tx = 2 * Int((Rnd * (UbX - 3) \ 2)) + 2: ty = 2 * Int(Rnd * (UbY - 3) \ 2) + 2
        Else
            tx = UbX \ 2: ty = UbY \ 2
        End If
        If tx = cx Or ty = cy Then GoTo tryAgain ' to avoid dead end streets
        dx = tx - cx: dy = ty - cy ' the distance and direction we have to go
        While cx <> tx: cx = cx + Sgn(dx): GoSub MakeWay: Wend
        While cy <> ty: cy = cy + Sgn(dy): GoSub MakeWay: Wend
    Next
    Sleep
Loop Until _KeyDown(27)
End
MakeWay: board$(cx, cy) = "S": Line ((cx - 1) * 10, (cy - 1) * 10)-Step(9, 9), , BF: Return

Sample board$()
   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
sweet little circuit game space maker - by bplus - 02-18-2024, 08:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Word Search Maker SierraKen 27 4,998 01-21-2026, 12:53 AM
Last Post: SierraKen
  Video conversion utility COMMANDER X16 MOVIE MAKER ahenry3068 1 651 11-20-2025, 09:38 PM
Last Post: ahenry3068
  Tiny Space Invaders bplus 15 1,600 09-11-2025, 04:39 PM
Last Post: Pete
  Space Invaders knock off to show simple collisions Unseen Machine 10 1,091 09-09-2025, 07:23 PM
Last Post: Pete
  Tiny Maze Maker - ASCII SierraKen 19 1,705 08-09-2025, 11:39 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: 1 Guest(s)