Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checkered Checkers
#2
Today I've got it figured out and added the option to divide the sides of a screen from 2 to 10 cells:
Code: (Select All)
_Title "Checkered Checkers Recursive, press any for another screen..." ' b+ 2023-02-17
Screen _NewImage(740, 740, 12)
Randomize Timer
_ScreenMove 300, 0
Dim Shared As Long Divisor, DivisorMinusOne

While _KeyDown(27) = 0
    Divisor = Int(Rnd * 9) + 2
    DivisorMinusOne = Divisor - 1
    ReDim Shared arr(DivisorMinusOne, DivisorMinusOne) ' holds pattern
    For j = 0 To DivisorMinusOne
        For i = 0 To DivisorMinusOne
            If Rnd < .5 Then arr(i, j) = 1
        Next
    Next
    CheckRecur 0, 0, (_Width - 1) / Divisor
    Sleep
    Cls
Wend

Sub CheckRecur (FirstX, FirstY, Side)
    If Side <= 4 Then Exit Sub ' done
    For y = 0 To DivisorMinusOne
        For x = 0 To DivisorMinusOne
            Line (FirstX + x * Side, FirstY + y * Side)-Step(Side, Side), , B
            If Side / Divisor <= 4 Then
                If arr(x, y) Then
                    Line (FirstX + x * Side + 1, FirstY + y * Side + 1)-Step(Side - 3, Side - 3), 15, BF
                Else
                    Line (FirstX + x * Side + 1, FirstY + y * Side + 1)-Step(Side - 3, Side - 3), 0, BF
                End If
            Else
                If arr(x, y) Then
                    CheckRecur FirstX + x * Side, FirstY + y * Side, Side / Divisor
                End If
            End If
        Next
    Next
End Sub

Note: It is possible to get an all white screen or all black screen except for white grid.
b = b + ...
Reply


Messages In This Thread
Checkered Checkers - by bplus - 02-18-2023, 01:20 AM
RE: Checkered Checkers - by bplus - 02-18-2023, 01:24 AM
RE: Checkered Checkers - by mnrvovrfc - 02-18-2023, 03:15 PM
RE: Checkered Checkers - by bplus - 02-18-2023, 04:21 PM
RE: Checkered Checkers - by bplus - 02-19-2023, 09:31 PM
RE: Checkered Checkers - by mnrvovrfc - 02-20-2023, 07:08 AM
RE: Checkered Checkers - by bplus - 02-20-2023, 02:56 PM



Users browsing this thread: 5 Guest(s)