Created
January 20, 2019 07:20
-
-
Save giantryansaul/35d6ebb58982add47204b5df793f3fec to your computer and use it in GitHub Desktop.
This file contains hidden or 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 16 | |
__lua__ | |
function _init() | |
balls={} | |
for i=1,20 do | |
add(balls,create_ball()) | |
end | |
end | |
function create_ball() | |
local a={} | |
a.x=rnd(127) | |
a.y=rnd(127) | |
a.dx=rnd(2) | |
a.dy=rnd(2) | |
a.r=4 | |
a.c=rnd(16) | |
return a | |
end | |
function _update() | |
foreach(balls,update_ball) | |
end | |
function update_ball(a) | |
a.x+=a.dx | |
a.y+=a.dy | |
if a.x>127 then a.dx=-rnd(2) end | |
if a.x<0 then a.dx=rnd(2) end | |
if a.y>127 then a.dy=-rnd(2) end | |
if a.y<0 then a.dy=rnd(2) end | |
end | |
function _draw() | |
cls() | |
foreach(balls,draw_ball) | |
end | |
function draw_ball(a) | |
circfill(a.x,a.y,a.r,a.c) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment