Munching squares: Difference between revisions

Content added Content deleted
(→‎{{header|MiniScript}}: simplified for modern Mini Micro)
Line 1,174: Line 1,174:


=={{header|MiniScript}}==
=={{header|MiniScript}}==
This version runs in Mini Micro (for the graphics). Note that because MiniScript does not currently have any bit operations (all numbers are floating-point), we have to implement an <code>xor</code> function the hard way.
This version runs in Mini Micro (for the graphics, and the bitXor intrinsic).


<syntaxhighlight lang="miniscript">xor = function(a, b)
<syntaxhighlight lang="miniscript">for x in range(0,255)
result = 0
bit = 1
while a > 0 or b > 0
if (a%2 == 0) != (b%2 == 0) then result = result + bit
bit = bit * 2
a = floor(a/2)
b = floor(b/2)
end while
return result
end function

for x in range(0,255)
for y in range(0,255)
for y in range(0,255)
gfx.setPixel x, y, color.rgb(0, xor(x,y), 0)
gfx.setPixel x, y, color.rgb(0, bitXor(x,y), 0)
end for
end for
end for</syntaxhighlight>
end for</syntaxhighlight>