Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define fbc -s gui
- #include "fbgfx.bi"
- #define ToNum(_N) ((_N) shr 8)
- #define ToFix(_N) (cint((_N)*256))
- #define iRnd(_N) cint(int(rnd*(_N)))
- type DotStruct
- iX as integer
- iY as integer
- iSX as integer
- iSY as integer
- iColor as integer
- iNext as integer
- end type
- '=== Configuration ===
- 'iKeepScreen = -1 > Start Full Black
- 'iKeepScreen = 0 > Gradually Clears
- 'iKeepScreen = 1 > Keep Background
- dim shared as integer iDots=4,iLines=7,iKeepScreen=1
- dim shared as integer iColorStart=12,iColorAdvance=3
- '=====================
- dim shared as integer iScrWid=640,iScrHei=480,iFixWid,iFixHei,iSpeed
- redim shared as DotStruct tDots(iLines-1,iDots-1)
- sub Advance( byref tDot as DotStruct , iAmountFix as integer )
- tDot.iX += ToNum(tDot.iSX * iAmountFix)
- tDot.iY += ToNum(tDot.iSY * iAmountFix)
- if tDot.iX < 0 then tDot.iX = -tDot.iX: tDot.iSX = -tDot.iSX
- if tDot.iX >= iFixWid then tDot.iX = ((iFixWid*2)-2)-tDot.iX: tDot.iSX = -tDot.iSX
- if tDot.iY < 0 then tDot.iY = -tDot.iY: tDot.iSY = -tDot.iSY
- if tDot.iY >= iFixHei then tDot.iY = ((iFixHei*2)-2)-tDot.iY: tDot.iSY = -tDot.iSY
- end sub
- sub AdvanceAllDots( fAdvance as single )
- for iD as integer = 0 to iDots-1
- for iL as integer = 0 to iLines-1
- Advance( tDots(iL,iD) , fAdvance*iSpeed )
- tDots(iL,iD).iNext += ToFix(fAdvance)
- while tDots(iL,iD).iNext >= ToFix(16)
- tDots(iL,iD).iColor += iColorAdvance
- if tDots(iL,iD).iColor > 15 then tDots(iL,iD).iColor -= 7
- tDots(iL,iD).iNext -= ToFix(16)
- wend
- next iL
- next iD
- end sub
- sub InitializeAllDots()
- var iAdvance = (ToFix(16)*256)\iSpeed
- for iD as integer = 0 to iDots-1
- #define iDirection (((-1+iRnd(2)) or 1)*iSpeed)
- tDots(0,iD) = type( iRnd(iFixWid) , iRnd(iFixHei) , iDirection , iDirection , iColorStart )
- for iL as integer = 1 to iLines-1
- tDots(iL,iD) = tDots(iL-1,iD)
- tDots(iL,iD).iColor += iColorAdvance
- if tDots(iL,iD).iColor > 15 then tDots(iL,iD).iColor -= 7
- Advance( tDots(iL,iD) , iAdvance )
- next iL
- next iD
- end sub
- sub DrawAllLines( iJustClear as integer = 0)
- var iSkip = iif(iJustClear,1,2)
- for iY as integer = -1 to 1 step iSkip
- for iX as integer = -1 to 1 step 1'iSkip
- for iL as integer = 0 to iLines-1
- var iD = 0, iC = iif(iJustClear,(iJustClear=1) and 17,tDots(iL,0).iColor and 7)
- for iD = 0 to iDots-2
- line ( ToNum(tDots(iL,iD).iX)+iX , ToNum(tDots(iL,iD).iY)+iY )- _
- ( ToNum(tDots(iL,iD+1).iX)+iX , ToNum(tDots(iL,iD+1).iY)+iY ), iC
- next iD
- line ( ToNum(tDots(iL,iD).iX)+iX , ToNum(tDots(iL,iD).iY)+iY )- _
- ( ToNum(tDots(iL,0).iX)+iX , ToNum(tDots(iL,0).iY)+iY ), iC
- next iL
- next iX
- next iY
- if iJustClear then exit sub
- for iL as integer = 0 to iLines-1
- var iC = tDots(iL,0).iColor, iD = 0
- for iD = 0 to iDots-2
- line ( ToNum(tDots(iL,iD).iX) , ToNum(tDots(iL,iD).iY) )- _
- ( ToNum(tDots(iL,iD+1).iX) , ToNum(tDots(iL,iD+1).iY) ), iC
- next iD
- line ( ToNum(tDots(iL,iD).iX) , ToNum(tDots(iL,iD).iY) )- _
- ( ToNum(tDots(iL,0).iX) , ToNum(tDots(iL,0).iY) ), iC
- next iL
- end sub
- screeninfo iScrWid,iScrHei
- screencontrol(fb.SET_DRIVER_NAME,"GDI")
- screenres iScrWid,iScrHei,8,,fb.GFX_HIGH_PRIORITY or iif(iKeepScreen>=0,fb.GFX_SHAPED_WINDOW,fb.GFX_NO_FRAME)
- screencontrol(fb.SET_WINDOW_POS,0,0)
- for iN as integer = 1 to 6
- dim as integer R,G,B
- palette get (iN or 8),R,G,B
- palette iN,R\3,G\3,B\3
- next iN
- iFixWid=ToFix(iScrWid)
- iFixHei=ToFix(iScrHei)
- iSpeed = ( ToFix(iScrWid+iScrHei) \ iScrWid )
- InitializeAllDots()
- dim as double TMR
- do
- if abs(timer-TMR) > 1/2 then TMR = timer
- var fNewTMR = timer
- screenlock
- DrawAllLines(1+(iKeepScreen and 1))
- #if 1 'TimeBased Movement
- AdvanceAllDots( (fNewTMR-TMR)/(1/60) )
- TMR = fNewTMR
- #else 'FrameBased Movement (compensated)
- while (timer-TMR) > 1/60
- AdvanceAllDots( 1 )
- TMR += 1/60
- wend
- #endif
- DrawAllLines()
- screenunlock
- 'screensync
- sleep (900\iSpeed)+1,1
- loop until len(inkey$)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement