From b23dbf913d15fca6e537898b406c7428948d8c21 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Wed, 2 Feb 2022 18:24:53 -0800 Subject: uniform circle scrolling function! --- background.lua | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'background.lua') diff --git a/background.lua b/background.lua index fd5073c..070b050 100644 --- a/background.lua +++ b/background.lua @@ -1,5 +1,10 @@ bgcircles = {} -circletimer = 0 + +function scrollingcircles(y, speed, spacing, radius, color) + for i = 1, (128*(radius*4))/spacing, 1 do + circfill(-time()*speed+(spacing*(i-1)), y, radius, color) + end +end function addbgcircle(x, y, velx, r, color, pos) @@ -21,20 +26,10 @@ function addbgcircle(x, y, velx, r, color, pos) add(bgcircles,circle, pos) end - - - - function drawbg() cls(1) - - circletimer -= 1/60 - if circletimer < 0 then - circletimer = .8 - addbgcircle(180,100,-1,32,3) - end - - foreach(bgcircles, function(circle) circle:draw() end) + scrollingcircles(90, 50, 25, 16, 5) + scrollingcircles(120, 100, 50, 32, 3) -- rectfill(0,0,128,16,13) -- rectfill(0,64,128,128,13) -- cgit