02-18-2023, 01:20 AM
For some time now I've been trying do something like this recursively:
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.
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 + ...