Its a simple but very nice effect
Code: Select all
; Meteors - by Werner Albus - www.nachtoptik.de
UsePNGImageDecoder()
UseJPEGImageDecoder()
Define b_meteor_add_yy_y.f ,b_meteor_add_yy_yy.f ,meteor.f ,meteor_1.f
Global timer_event_1
;landscape$="C:\Users\Werner\Desktop\Polarlicht.jpg" ; Set here the pad to your Landscape Picture
meteor_start=1 ; Meteor - start Quantity
meteor_max=100 ; Meteor maximal Quantity
meteor_1=0.1 ; Increment accrete Quantity Speed
animation_speed=30 ; Animation Speed
fall_speed=5 ; Felocity of Fall
drift=-2 ; drift - as sample -3 = left // +3 = right
alpha=255 ; Meteor Brightness
full_at_startup=0 ; 1 = Filling Screen at Startup // 0 = Filling Screen slowly at startup
; For filling at Startup set also meteor_start many bigger or equal meteor_max
win_x=1200 ; Window width
win_y=800 ; Window height
If landscape$<>""
LoadImage(0,landscape$) ; Load a dark landscape Image
Else
CreateImage(0,1200,800) ; Or load nothing
EndIf
ResizeImage(0,win_x,win_y)
CopyImage(0,1)
meteor=meteor_start
ExamineDesktops()
OpenWindow(0,DesktopWidth(0)/2-win_x/2,DesktopHeight(0)/2-win_y/2,win_x,win_y,"Meteor´s")
If Not InitSprite() Or Not OpenWindowedScreen(WindowID(0),0,0,win_x,win_y,0,0,0)
MessageRequester("Error", "Can not init",0)
End
EndIf
Procedure timer_events()
Select EventTimer()
Case 1
timer_event_1=1
EndSelect
EndProcedure
AddWindowTimer(0,1,animation_speed)
BindEvent(#PB_Event_Timer, @timer_events())
Dim meteor (meteor_max,2)
For i=0 To meteor_max
meteor(i,0)=Random(win_x)
If full_at_startup
meteor(i,1)=Random(win_y)
Else
meteor(i,1)=-Random(win_y)
EndIf
Next i
Repeat
If timer_event_1
timer_event_1=0
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(1),0,0,50)
If meteor<meteor_max ; Add meteor slowly
meteor+meteor_1
If meteor>meteor_max
meteor=meteor_max
EndIf
EndIf
For i=0 To meteor
If drift
meteor(i,0)+drift
Else
meteor(i,0)+-Random(2)+1
EndIf
If meteor(i,0)>win_x
meteor(i,0)=0
EndIf
If meteor(i,0)<0
meteor(i,0)=win_x
EndIf
If meteor(ii,0)>win_x
meteor(ii,0)=0
EndIf
If meteor(ii,0)<0
meteor(ii,0)=win_x
EndIf
Select Random(2)
Case 0,1
Circle(meteor(i,0)+Random(1),meteor(i,1)+meteor_add_y,Random(1),RGBA(255,255,0,alpha))
Case 2
Circle(meteor(i,0)+Random(1),meteor(i,1)+meteor_add_y,0,RGBA(255,255,0,alpha))
EndSelect
meteor(i,1)+Random(fall_speed+1)
If meteor(i,1)>win_y
meteor(i,1)=0
EndIf
Next i
StopDrawing()
EndIf
StartDrawing(WindowOutput(0))
DrawAlphaImage(ImageID(0),0,0)
StopDrawing()
Repeat
event=WindowEvent()
If event=#PB_Event_CloseWindow
End
EndIf
Until Not event
ForEver
AddWindowTimer(0,1,animation_speed)
BindEvent(#PB_Event_Timer, @timer_events())
Dim meteor (meteor_max,2)
For i=0 To meteor_max
meteor(i,0)=Random(win_x)
If full_at_startup
meteor(i,1)=Random(win_y)
Else
meteor(i,1)=-Random(win_y)
EndIf
Next i
Repeat
If timer_event_1
timer_event_1=0
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(1),0,0,50)
If meteor<meteor_max ; Add meteor slowly
meteor+meteor_1
If meteor>meteor_max
meteor=meteor_max
EndIf
EndIf
For i=0 To meteor
If drift
meteor(i,0)+drift
Else
meteor(i,0)+-Random(2)+1
EndIf
If meteor(i,0)>win_x
meteor(i,0)=0
EndIf
If meteor(i,0)<0
meteor(i,0)=win_x
EndIf
If meteor(ii,0)>win_x
meteor(ii,0)=0
EndIf
If meteor(ii,0)<0
meteor(ii,0)=win_x
EndIf
Select Random(2)
Case 0,1
Circle(meteor(i,0)+Random(1),meteor(i,1)+meteor_add_y,Random(1),RGBA(255,255,0,alpha))
Case 2
Circle(meteor(i,0)+Random(1),meteor(i,1)+meteor_add_y,0,RGBA(255,255,0,alpha))
EndSelect
meteor(i,1)+Random(fall_speed+1)
If meteor(i,1)>win_y
meteor(i,1)=0
EndIf
Next i
StopDrawing()
EndIf
StartDrawing(WindowOutput(0))
DrawAlphaImage(ImageID(0),0,0)
StopDrawing()
Until WindowEvent()=#PB_Event_CloseWindow