Bouncing lines & boxes
#5
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

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$ <> ""

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
Bouncing lines & boxes - by Dav - 05-25-2022, 10:46 PM
RE: Bouncing lines & boxes - by SierraKen - 05-25-2022, 11:07 PM
RE: Bouncing lines & boxes - by bplus - 05-26-2022, 12:03 AM
RE: Bouncing lines & boxes - by James D Jarvis - 05-26-2022, 12:22 PM
RE: Bouncing lines & boxes - by Dav - 05-27-2022, 12:53 PM
RE: Bouncing lines & boxes - by Kernelpanic - 05-27-2022, 04:55 PM



Users browsing this thread: 4 Guest(s)