Skip to content

Instantly share code, notes, and snippets.

@sealgair
Created January 9, 2017 17:24
Show Gist options
  • Save sealgair/d2fb7b02bb8673e9ba4a46386dec62df to your computer and use it in GitHub Desktop.
Save sealgair/d2fb7b02bb8673e9ba4a46386dec62df to your computer and use it in GitHub Desktop.
-- randomly choose item from table
function rndchoice(t)
return t[flr(rnd(#t))+1]
end
stars = {}
function makestars(n)
colors={1,5,6,7,13}
for i=1,n do
add(stars, {
x=flr(rnd(128)),
y=flr(rnd(128)),
c=rndchoice(colors)
})
end
end
function _draw()
for s in all(stars) do
if rnd()>0.02 then
pset(s.x, s.y, s.c)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment