Skip to content

Instantly share code, notes, and snippets.

@greg76
Last active May 18, 2020 06:02
Show Gist options
  • Save greg76/46add619fedf605c7a8f8b3e4097d2f2 to your computer and use it in GitHub Desktop.
Save greg76/46add619fedf605c7a8f8b3e4097d2f2 to your computer and use it in GitHub Desktop.
recreated a tiny effect in python. for the lulz.
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()
@wmiki
Copy link

wmiki commented May 18, 2020

Nice one dude! Very elegant solution, also looks cool with the retro resolution and colors :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment