Here's a twist on the lines one. Makes a ghost lines, patchwork looking screen. Increase the lines count for more involved look. 5000 looks interesting. My Laptop could go up to 10000 lines before getting too slow.
- Dav
- Dav
Code: (Select All)
'==================
'BouncingLines2.bas
'==================
'Coded by Dav, May/2022
SCREEN _NEWIMAGE(800, 600, 32)
RANDOMIZE TIMER
lines = 100 'Number of lines on screen. (Try 5000!)
DIM line.x1(lines), line.y1(lines), line.cx1(lines), line.cy1(lines)
DIM line.r(lines), line.g(lines), line.b(lines), line.a(lines)
'Init values for each box
FOR s = 1 TO lines
line.y1(s) = INT(RND * _HEIGHT) + 1: line.x1(s) = INT(RND * _WIDTH) + 1
line.cx1(s) = RND * 2: line.cy1(s) = RND * 2
line.r(s) = RND * 200 + 55: line.g(s) = RND * 200 + 55: line.b(s) = RND * 200 + 55
line.a(s) = RND * 100
NEXT
DO
FOR s = 1 TO lines
LINE (line.x1(s) - RND * 8, line.y1(s) - RND * 8)-(line.x1(s) + RND * 8, line.y1(s) + RND * 8), _RGBA(line.r(s), line.g(s), line.b(s), line.a(s)), BF
LINE (line.x1(s) - 8, line.y1(s) - 8)-(line.x1(s) + 8, line.y1(s) + 8), _RGBA(0, 0, 0, line.a(s)), B
IF line.x1(s) <= 0 OR line.x1(s) >= _WIDTH THEN line.cx1(s) = -line.cx1(s): line.a(s) = RND * 15
IF line.y1(s) <= 0 OR line.y1(s) >= _HEIGHT THEN line.cy1(s) = -line.cy1(s): line.a(s) = RND * 15
line.x1(s) = line.x1(s) + line.cx1(s): line.y1(s) = line.y1(s) + line.cy1(s)
line.a(s) = line.a(s) - .05
IF line.a(s) <= -10 THEN line.a(s) = RND * 100
NEXT
_DISPLAY
_LIMIT 300
LOOP UNTIL INKEY$ <> ""