And here is Matrix Rain #4 using randWeight to assign many smaller size drops with fewer large drops for better 3d effect plus an improvement in transparent background of letters that I don't think my last version of Matrix Rain had... whatever, I like the look much better than Matrix Rain #3.
_TITLE "Matrix Rain 4" 'B+ started 2019-03-16 ' from Matrix Rain 2019-03-14
' or QB64 Purple Rain!
'>>> Save this file as: Matrix Rain 4.bas, so the program can load the strings from it. <<<
'2019-03-15 This will attempt to spin the drops as they fall
'2019-03-16 Don't need no damn Character Set.DAT file!!!
'2019-03-16 Ijust want to see the vertical code strings dangle and twist.
'2019-03-19 Matrix Rain 4
' + added randWeight to weight the random sizes chosen so many more on small side than large
' + draw letters on a transparent background so the background of the letter does not cover
' the drops behind it.
dxs
AS SINGLE 'direction and change of spin some small fraction of 1, +-1/3, +-1/4, +-1/5...
'_FULLSCREEN 'as screen saver
REDIM SHARED fileStrings$
(1000) 'container for these program lines that will be dangling i = i + 1
' check loading
'FOR i = 0 TO UBOUND(fileStrings$)
' PRINT i, fileStrings$(i)
'NEXT
'END
'setup drops
newDrop i, 1
drawDrop (i)
drop(i).curY = drop(i).curY + 1
IF drop
(i
).curY
> LEN(s$
(i
)) THEN newDrop i
, 0
drop
(i
).x
= RND * xmax
'set location drop(i).sz = randWeight(.3, 5, 3) 'set size weighted on small sizes
'length of text string can fit on screen
charLength = ymax \ (drop(i).sz * 16) + 1 'from size determine how many chars fit on screen
randLine
= INT(RND * UBOUND(fileStrings$
)) 'pick a random program line s$
(i
) = MID$(fileStrings$
(randLine
), 1, charLength
) 'here is text string to dangle IF randLine
+ 1 > UBOUND(fileStrings$
) THEN randLine
= 0 ELSE randLine
= randLine
+ 1 s$
(i
) = MID$(s$
(i
) + " : " + fileStrings$
(randLine
), 1, charLength
) IF start
<> 0 THEN drop
(i
).curY
= INT(RND * (charLength
)) + 1 ELSE drop
(i
).curY
= 1 'flat and readable at curY drop
(i
).dxs
= 1 / (INT(RND * 7) + 3) 'change of spin rate +-1/3, +-1/4, ... +-1/9
FOR j
= 1 TO drop
(i
).curY
d = drop(i).curY - j
c~&
= _RGBA32(255, 0, 255, 190 - d
* 5) rot = 1: dir = -1
rot = rot + drop(i).dxs * dir
IF rot
> 1 THEN dir
= -1 * dir: rot
= 1 + drop
(i
).dxs
* dir
IF rot
< -1 THEN dir
= dir
* -1: rot
= -1 + drop
(i
).dxs
* dir
drwChar
MID$(s$
(i
), j
, 1), c~&
, drop
(i
).x
+ 4 * drop
(i
).sz
, drop
(i
).sz
* 16 * (j
- 1) + 8 * drop
(i
).sz
, rot
* drop
(i
).sz
, drop
(i
).sz
, 0
SUB drwChar
(char$
, c
AS _UNSIGNED LONG, midX
, midY
, xScale
, yScale
, Rotation
) 'what ever the present color is set at RotoZoom2 midX, midY, I&, xScale, yScale, Rotation
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
sinr!
= SIN(-Rotation
): cosr!
= COS(-Rotation
) x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + Y
px(i&) = x2&: py(i&) = y2&
_MAPTRIANGLE (0, 0)-(0, H&
- 1)-(W&
- 1, H&
- 1), Image&
TO(px
(0), py
(0))-(px
(1), py
(1))-(px
(2), py
(2)) _MAPTRIANGLE (0, 0)-(W&
- 1, 0)-(W&
- 1, H&
- 1), Image&
TO(px
(0), py
(0))-(px
(3), py
(3))-(px
(2), py
(2))
FUNCTION randWeight
(manyValue
, fewValue
, power
) randWeight
= manyValue
+ RND ^ power
* (fewValue
- manyValue
)
EDIT: remove attachment tag in the code, I wondered where that went. :D