Last active
July 31, 2021 03:10
-
-
Save Enichan/cf6ee9fc534d206e1942b7c6995ef8af to your computer and use it in GitHub Desktop.
Eniko Collatz Fizzle Fade, Pico 8 implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seed = 38 | |
function txp1() | |
if seed == 1 then | |
return seed | |
elseif seed % 2 == 0 then | |
seed /= 2 | |
else | |
seed = seed * 3 + 1 | |
end | |
-- keep seed positive if overflow occurs | |
-- this just masks off the sign bit in pico 8 | |
seed = seed & 0x7fff | |
return seed | |
end | |
c = 8 | |
function _init() | |
cls(0) | |
end | |
function _draw() | |
local step = txp1() | |
if step == 1 then | |
cls(c) | |
return | |
end | |
local x, y = 0, 0 | |
if step == 4 then | |
step = 3 | |
elseif step == 2 then | |
step = 3 | |
x = 2 | |
elseif step % 2 == 0 then | |
step += 1 | |
end | |
while y < 128 do | |
x += step | |
if x >= 128 then | |
local rows = flr(x / 128) | |
y += rows | |
x = x % 128 | |
end | |
pset(x, y, c) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment