Skip to content

Instantly share code, notes, and snippets.

@Godzil
Created September 5, 2018 14:38
Show Gist options
  • Save Godzil/9698bbb1886e1ebe88bd17f34ed83841 to your computer and use it in GitHub Desktop.
Save Godzil/9698bbb1886e1ebe88bd17f34ed83841 to your computer and use it in GitHub Desktop.
Blue moving things....
# Translated from PICO-8 Lua code to Python/PyGame
# Original: https://twitter.com/TedAjax/status/1036295369968115713
# _set_fps(60)::_::cls(1)for q=48,12,-1 do
# for i=0,1,.1 do r=q+12*sin(t()/2+i*3)x=cos(i)*r+64
# y=sin(i)*r+64
# z=cos(i+.1)*r+64
# w=sin(i+.1)*r+64line(x,y,z,w,12)end
# end
# flip()goto _
import sys
import pygame
import math
import random
pygame.init()
clk = pygame.time.Clock()
screen = pygame.display.set_mode((128, 128))
palette = [
(0, 0, 0),
(29, 43, 83),
(126, 37, 83),
(0, 135, 81),
(171, 82, 54),
(95, 87, 79),
(194, 195, 199),
(255, 241, 232),
(255, 0, 77),
(255, 163, 0),
(255, 236, 39),
(0, 228, 54),
(41, 173, 255),
(131, 118, 156),
(255, 119, 168),
(255, 204, 170),
]
t = 0
random.seed()
def picosin(r):
r = r * (math.pi*2)
return math.sin(-r)
def picocos(r):
r = r * (math.pi * 2)
return math.cos(r)
def circfill(x, y, radius, colour):
pygame.draw.circle(screen, palette[int(colour)], (int(x), int(y)), int(radius))
def line(x1, y1, x2, y2, colour):
pygame.draw.line(screen, palette[int(colour)], (x1, y1), (x2, y2))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
screen.fill(palette[1])
for q in range(48, 12, -1):
for iInt in range(0, 10):
i = iInt / 10.
r = q + 12 * picosin(t / 2 + i * 3)
x = picocos(i) * r + 64
y = picosin(i) * r + 64
z = picocos(i + 0.1) * r + 64
w = picosin(i + 0.1) * r + 64
line(x, y, z, w, 12)
pygame.display.flip()
clk.tick(60)
t += 0.05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment