https://youtu.be/oreComUsg78
Code: Select all
REM Raindrop Water Ripples 2
REM Requires BB4W & GfxLib2
*ESC OFF
MODE 8 : OFF
ON ERROR PROCCloseGDIP : PROCerror( REPORT$ + " at line " + STR$ERL )
ON CLOSE PROCCloseGDIP : QUIT
N% = 250 : REM no. of ripples
INSTALL @lib$ + "GDIPLIB.BBC" : PROC_gdipinit
INSTALL @lib$ + "GFXLIB2.BBC" : PROCInitGFXLIB( g{}, 0 )
INSTALL @lib$ + "GFXLIB_modules\ClrLG.BBC" : PROCInitModule( 0 )
INSTALL @lib$ + "GFXLIB_modules\BPlotScale.BBC" : PROCInitModule( 0 )
INSTALL @lib$ + "GFXLIB_modules\PlotAlphaBlend3.BBC" : PROCInitModule( 0 )
INSTALL @lib$ + "GFXLIB_modules\DrawBmFont3.BBC" : PROCInitModule( 0 )
INSTALL @lib$ + "GFXLIB_modules\GetBmFontStrWidth.BBC" : PROCInitModule( 0 )
RESTORE
READ nQuotes%
maxQuoteLines% = 10
DIM quote{( nQuotes%-1 ) nLines%, s$(maxQuoteLines%-1)}
FOR I% = 0 TO nQuotes%-1
REPEAT
READ s$
IF s$ <> "" THEN
quote{(I%)}.s$( quote{(I%)}.nLines% ) = s$
quote{(I%)}.nLines% += 1
ENDIF
UNTIL s$ = ""
NEXT I%
G% = g{}
timeGetTime% = FNSYS_NameToAddress( "timeGetTime" )
font% = FNLoadData( @lib$ + "GFXLIB_media\arial16pt.dat" )
bm% = FNmalloc( 4 * 640*512 )
DIM c{(N%-1) pen%, x, z, r, maxr}
FOR I% = 0 TO N%-1
PROCnew( I%, FALSE )
NEXT I%
quote% = RND(nQuotes%) - 1
SYS timeGetTime% TO time%
displayQuoteTime% = time% + 5000
*REFRESH OFF
SYS timeGetTime% TO time%
REPEAT
old_time% = time%
SYS timeGetTime% TO time%
dt = 60 * (time% - old_time%) / 1000
SYS GFXLIB_Clr%, g{}, &1060B0
FOR I% = 0 TO N%-1
PROC_gdipellipse( c{(I%)}.pen%, c{(I%)}.x, c{(I%)}.z, c{(I%)}.r, c{(I%)}.r, 0 )
c{(I%)}.r += 0.5 * dt
PROC_gdipdeletepen( c{(I%)}.pen% )
t = 2.0 + (5.0 - 2.0)*(1 - c{(I%)}.z / 1024)
opacity% = FNopacity( c{(I%)}.r, c{(I%)}.maxr, c{(I%)}.z )
rgb% = FNrgb( opacity% )
c{(I%)}.pen% = FN_gdipcreatepen( rgb%, 0, t )
IF c{(I%)}.r >= c{(I%)}.maxr THEN
PROC_gdipdeletepen( c{(I%)}.pen% )
PROCnew( I%, TRUE )
ENDIF
NEXT I%
SYS GFXLIB_DWORDCopy%, g.bmBuffAddr%, bm%, 640*512
SYS GFXLIB_ClrLG%, g{}, &104040, &4050A0
y = 0
dy = 1.0
ddy = 0.00375
P% = GFXLIB_BPlotScale%
FOR Y% = 0 TO 319
w = 640 * (1 - 0.5*Y%/319)
SYS P%, G%, bm% + 4*640*INTy, 640, 1, 2*w, 1, 320-2*w/2, Y%
y += dy
dy += ddy
NEXT Y%
IF time% >= displayQuoteTime% PROCDisplayQuote(quote%)
PROCdisplay
UNTIL FALSE
END
DEF FNopacity( r, maxr, z )
= (1 - r/maxr) * (64 + 191 * (1 - z / 1024))
DEF FNrgb( O% )
= (O% << 24) OR &A0FF
DEF PROCnew( I%, R% )
c{(I%)}.x = 1280 * RND(1)
c{(I%)}.z = 1024 * RND(1)
c{(I%)}.maxr = 8 + 48*RND(1)
IF R% THEN
c{(I%)}.r = 0.5
ELSE
c{(I%)}.r = 0.5 * c{(I%)}.maxr * RND(1)
ENDIF
t = 2.0 + (8.0 - 2.0)*(1 - c{(I%)}.z / 1024)
opacity% = FNopacity( c{(I%)}.r, c{(I%)}.maxr, c{(I%)}.z )
rgb% = FNrgb( opacity% )
c{(I%)}.pen% = FN_gdipcreatepen( rgb%, 0, t )
ENDPROC
DEF PROCDisplayQuote(i%)
LOCAL I%, s$
FOR I% = 0 TO quote{(i%)}.nLines%-1
s$ = quote{(i%)}.s$(I%)
SYS GFXLIB_GetBmFontStrWidth%, font%, s$ TO W%
SYS GFXLIB_DrawBmFont3%, G%, font%, s$, 320-W%/2-1, 332-28*I%-1, 0
SYS GFXLIB_DrawBmFont3%, G%, font%, s$, 320-W%/2, 332-28*I%, &D0C010
NEXT I%
ENDPROC
DEF PROCCloseGDIP
LOCAL I%
`GdiplusStartup` += 0
IF `GdiplusStartup` <> 0 THEN
REM FOR I% = 0 TO N%-1
REM IF c{(I%)}.pen% THEN
REM PROC_gdipdeletepen( c{(I%)}.pen% )
REM c{(I%)}.pen% = 0
REM ENDIF
REM NEXT I%
PROC_gdipexit
`GdiplusStartup` = 0
ENDIF
ENDPROC
DEF PROCerror( s$ )
OSCLI "REFRESH ON" : CLS : ON : VDU 7 : PRINT '" "+s$;
REPEAT
WAIT 1
UNTIL FALSE
ENDPROC
REM Number of quotes:
DATA 10
REM Quote 1:
DATA "Predicting rain doesn't count."
DATA "Building arks does."
DATA " "
DATA "(Warren Buffet)"
DATA ""
REM Quote 2:
DATA "No person has the right to rain on your dreams."
DATA " "
DATA "(Marian Wright Edelman)"
DATA ""
REM Quote 3:
DATA "My sorrow, when she's here with me,"
DATA "thinks these dark days of autumn rain"
DATA "are beautiful as days can be;"
DATA "she loves the bare, the withered tree;"
DATA "she walks the sodden pasture lane."
DATA " "
DATA "(Robert Frost)"
DATA ""
REM Quote 4:
DATA "It will never rain roses:"
DATA "when we want to have more roses"
DATA "we must plant more trees."
DATA " "
DATA "(George Eliot)"
DATA ""
REM Quote 5:
DATA "The way I see it, if you want the rainbow,"
DATA "you gotta put up with the rain."
DATA " "
DATA "(Dolly Parton)"
DATA ""
REM Quote 6:
DATA "Sunshine is delicious, rain is refreshing,"
DATA "wind braces us up, snow is exhilarating;"
DATA "there is really no such thing as bad weather,"
DATA "only different kinds of good weather."
DATA " "
DATA "(John Ruskin)"
DATA ""
REM Quote 7:
DATA "Life is the fire that burns"
DATA "and the sun that gives light."
DATA "Life is the wind and the rain"
DATA "and the thunder in the sky."
DATA "Life is matter and is earth,"
DATA "what is and what is not,"
DATA "and what beyond is in Eternity."
DATA " "
DATA "(Lucius Annaeus Seneca)"
DATA ""
REM Quote 8:
DATA "Into each life some rain must fall."
DATA " "
DATA "(Henry Wadsworth Longfellow)"
DATA ""
REM Quote 9:
DATA "I think fish is nice,"
DATA "but then I think that rain is wet,"
DATA "so who am I to judge?"
DATA " "
DATA "(Douglas Adams)"
DATA ""
REM Quote 10:
DATA "Meteorologists are pretty faces reading scripts"
DATA "telling you whether it's going to rain tomorrow."
DATA " "
DATA "(Noam Chomsky)"
DATA ""