Last active
May 18, 2020 06:02
-
-
Save greg76/46add619fedf605c7a8f8b3e4097d2f2 to your computer and use it in GitHub Desktop.
recreated a tiny effect in python. for the lulz.
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
import pyxel | |
class Intro: | |
def __init__(self): | |
pyxel.init(160, 120, caption="Greg was here") | |
self.timer = 0 | |
pyxel.run(self.update, self.draw) | |
def update(self): | |
self.timer += 1 | |
def draw(self): | |
for y in range(pyxel.height): | |
for x in range(pyxel.width): | |
magic = 0x21F | |
# making sure we don't divide by zero. | |
# also cropping the noisy top of the tilted checkerboard pattern | |
yy = y + (magic >> 4) | |
# seed for perspective distorsion by y axis | |
a = magic // yy | |
# centering x, adjusting pattern width | |
cx = (x - pyxel.width // 2) * 5 | |
# generating checkerboard pattern, shifted by time | |
t = (cx // yy) ^ (a - self.timer) | |
# adjusting color for available color palette | |
color = t & 0b1011 | |
pyxel.pset(x, y, color) | |
Intro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice one dude! Very elegant solution, also looks cool with the retro resolution and colors :)