|| '@include' https://gist.casuallyblue.dev/autumn/056799f483464c668e0a6a2d9db099df/raw/HEAD/game.nv 'orbit speed' 0.003 'orbit width' 10 '' start a 400 by 400 game '' create 400 circles | '' create 0 circles | | '' create $amount circles | '' (@reduce @main = create { $amount 1 - } circles .) '' (@reduce circles = { 40 400 40 - random } { 40 400 40 - random } { 2 15 random } .) | '' game loop $dt | '@graphics' clear #11111122 '' draw circles '' next frame | '' draw circles? 'circles' $x $y $radius | '' calculate orbit for $x '' draw circle $x $y $radius | '' calculate orbit for $x 'orbit speed' $speed? | '' (@reduce orbit = { time $speed * $x + } .) | '' draw circle $x $y $radius 'orbit' $orbit 'orbit width' $width? | 'drawn' $x $y $radius '' (@reduce @graphics = draw circle size $radius at { $orbit cos $width * $x + } { $orbit sin $width * $y + } .) | '' draw circles | '' reset circles | '' reset circles? 'drawn' $x $y $radius | 'circles' $x $y $radius | '' reset circles | | '@graphics' draw circle size $width at $x $y '@@canvas context' $c? | '@js' $c.beginPath(); const r = $width / 2; $c.arc(Number($x) + r, Number($y) + r, r, 0, 2 * Math.PI); $c.fillStyle = "white"; $c.fill(); | '' @reduce? '' {? '' time | '@js' f("numbers", "" + performance.now()); | '' @reduce? '' {? '' cos 'numbers' $a | '@js' f("numbers", "" + Math.cos(Number($a))); | '' @reduce? '' {? '' sin 'numbers' $a | '@js' f("numbers", "" + Math.sin(Number($a))); || '@include' https://gist.casuallyblue.dev/autumn/e1c6774f800249be87a94240042135db/raw/HEAD/reduce.nv