Checkered Checkers
#1
For some time now I've been trying do something like this recursively:
Code: (Select All)
_Title "Checkered Checkers, press any for another screen..." ' b+ 2023-02-17
Screen _NewImage(641, 641, 12)
_ScreenMove 300, 60
d = 8: sq = 640 / d: sq8 = sq / d: dm1 = d - 1
Dim arr(d, d)
While _KeyDown(27) = 0
    For j = 0 To dm1
        For i = 0 To dm1
            If Rnd < .5 Then arr(i, j) = 1 Else arr(i, j) = 0
        Next
    Next
    For y = 0 To dm1
        For x = 0 To dm1
            If arr(x, y) Then
                For yy = 0 To dm1
                    For xx = 0 To dm1
                        If arr(xx, yy) Then
                            Line (x * sq + xx * sq8, y * sq + yy * sq8)-(x * sq + xx * sq8 + sq8 - 1, y * sq + yy * sq8 + sq8 - 1), , BF
                        Else
                            Line (x * sq + xx * sq8, y * sq + yy * sq8)-(x * sq + xx * sq8 + sq8 - 1, y * sq + yy * sq8 + sq8 - 1), , B
                        End If
                    Next
                Next
            End If
            Line (x * sq, y * sq - 1)-(x * sq + sq, y * sq + sq - 1), , B
        Next
    Next
    Sleep
    Cls
Wend

So it wouldn't take more code lines to do deeper levels. With recursion you could just keep going deeper as long as the side length of a checker was >=1 pixel.
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: 1 Guest(s)