Created
October 11, 2021 10:31
-
-
Save jonathontoon/0448f753b43c8b155fc6410bc5229230 to your computer and use it in GitHub Desktop.
A quick spiral visualization. Written in Lua for PICO-8.
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
pico-8 cartridge // http://www.pico-8.com | |
version 33 | |
__lua__ | |
function _init() | |
frme=0 | |
pi=3.141592653589793 | |
cx=64 | |
cy=64 | |
size=4 | |
prtcles={} | |
clrs={0,5,6,15,14,8,2,4,9,10,11,3,12,13,1} | |
clr_pos=1 | |
end | |
function _update() | |
local fps=stat(8) | |
frme+=flr(100/fps) | |
if frme>=32767 then | |
frme=0 | |
end | |
if frme%16==0 then | |
clr_pos+=1 | |
if clr_pos==15 then | |
clr_pos=1 | |
end | |
end | |
end | |
function _draw() | |
cls(7) | |
local rd=frme*(pi*270) | |
add(prtcles,{ | |
pos={x=cx,y=cy}, | |
vel={x=cos(rd),y=sin(rd)}, | |
col=clrs[clr_pos], | |
odd=frme%2==0 | |
}) | |
for i=1,count(prtcles),1 do | |
local p=prtcles[i] | |
p.pos.x+=p.vel.x | |
p.pos.y+=p.vel.y | |
if p.odd then | |
circfill(p.pos.x,p.pos.y,size-2,p.col) | |
else | |
circfill(p.pos.x,p.pos.y,size,p.col) | |
end | |
end | |
if count(prtcles)>5000 then | |
local st={} | |
for i=1,#prtcles,1 do | |
st[#st+1]=prtcles[i] | |
end | |
prtcles=st | |
end | |
end | |
__gfx__ | |
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment