Frohes neues Jahr - 2016
Verfasst: 01.01.2016 00:59
Hi meine lieben,
ich wünsche euch ein frohes neues Jahr. Feliz año nuevo! Feiert schön.
ich wünsche euch ein frohes neues Jahr. Feliz año nuevo! Feiert schön.
Code: Alles auswählen
EnableExplicit
InitSprite()
Structure Vector
X.f
Y.f
EndStructure
Structure Spark
Position.Vector
Velocity.Vector
Time.i
Color.i
Blink.i
Weight.i
EndStructure
Structure Bullet
Position.Vector
Velocity.Vector
Time.i
Color.i
Weight.i
Type.i
EndStructure
Global NewList Bullet.Bullet()
Global NewList Spark.Spark()
Enumeration
#Window
EndEnumeration
OpenWindow(#Window, 0, 0, 1200, 800, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window), 0, 0, 0)
RandomSeed(4)
Define Time.i, OldTime.i, TimeFactor.f, Length.f, I.i, Angle.f, Radius.f, Factor.f, *Spark.Spark
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_None
Break
EndSelect
ForEver
ClearScreen(0)
Time = ElapsedMilliseconds()
TimeFactor = (Time-OldTime)*0.001
OldTime = Time
StartDrawing(ScreenOutput())
ForEach Spark()
Spark()\Position\X + Spark()\Velocity\X*TimeFactor
Spark()\Position\Y + Spark()\Velocity\Y*TimeFactor
Spark()\Velocity\Y + 98.1*TimeFactor
If Time > Spark()\Time-250
Factor = (Spark()\Time-Time)/250.
Else
Factor = 1.0
EndIf
If Spark()\Weight Or Spark()\Blink
Circle(Spark()\Position\X, Spark()\Position\Y, Spark()\Blink+Sqr(Spark()\Weight/100), RGB(Red(Spark()\Color)*(Factor*0.5+0.5), Green(Spark()\Color)*(Factor*0.5+0.5), Blue(Spark()\Color)*(Factor*0.5+0.5)))
Else
Line(Spark()\Position\X, Spark()\Position\Y, 1, 1, RGB(Red(Spark()\Color)*Factor, Green(Spark()\Color)*Factor, Blue(Spark()\Color)*Factor))
EndIf
If Spark()\Blink
*Spark = Spark()
Angle = Radian(Random(3600)/10.)
Radius = Sqr(Random(1000)/1000.)*10
AddElement(Spark())
Spark()\Position = *Spark\Position
;Spark()\Velocity = *Spark\Velocity
Spark()\Velocity\X + Cos(Angle)*Radius
Spark()\Velocity\Y + Sin(Angle)*Radius
Spark()\Color = $40B0F0 + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 250 + Random(250)
ChangeCurrentElement(Spark(), *Spark)
EndIf
If Time > Spark()\Time
If Spark()\Weight
*Spark = Spark()
For I = 1 To *Spark\Weight
Angle = Radian(Random(3600)/10.)
Radius = Sqr(Random(1000)/1000.)*40+10
AddElement(Spark())
Spark()\Position = *Spark\Position
Spark()\Velocity = *Spark\Velocity
Spark()\Velocity\X + Cos(Angle)*Radius
Spark()\Velocity\Y + Sin(Angle)*Radius
Spark()\Color = $40B0F0 + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 250 + Random(250)
Next
ChangeCurrentElement(Spark(), *Spark)
EndIf
DeleteElement(Spark())
EndIf
Next
ForEach Bullet()
Bullet()\Position\X + Bullet()\Velocity\X*TimeFactor
Bullet()\Position\Y + Bullet()\Velocity\Y*TimeFactor
Bullet()\Velocity\Y + 98.1*TimeFactor
Length = Sqr(Bullet()\Velocity\X*Bullet()\Velocity\X+Bullet()\Velocity\Y*Bullet()\Velocity\Y)
Circle(Bullet()\Position\X, Bullet()\Position\Y, 1+Sqr(Bullet()\Weight/100), $C0C0C0)
LineXY(Bullet()\Position\X, Bullet()\Position\Y, Bullet()\Position\X-Bullet()\Velocity\X*20/Length, Bullet()\Position\Y-Bullet()\Velocity\Y*20/Length, $808080)
If Bullet()\Time < Time
Select Bullet()\Type
Case 0
For I = 1 To Bullet()\Weight
Angle = Radian(Random(3600)/10.)
Radius = Pow(Random(1000)/1000., 0.25)*Sqr(Bullet()\Weight)*5
AddElement(Spark())
Spark()\Position = Bullet()\Position
Spark()\Velocity = Bullet()\Velocity
Spark()\Velocity\X + Cos(Angle)*Radius
Spark()\Velocity\Y + Sin(Angle)*Radius
Spark()\Color = Bullet()\Color + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 1000 + Random(1000)
Next
Case 1
For I = 1 To Bullet()\Weight/10
Angle = Radian(Random(3600)/10.)
Radius = Sqr(Random(1000)/1000.)*Sqr(Bullet()\Weight)*5
AddElement(Spark())
Spark()\Position = Bullet()\Position
Spark()\Velocity = Bullet()\Velocity
Spark()\Velocity\X + Cos(Angle)*Radius
Spark()\Velocity\Y + Sin(Angle)*Radius
Spark()\Color = Bullet()\Color + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 500 + Random(500)
Spark()\Weight = 50
Next
Case 2
For I = 1 To Bullet()\Weight/10
Angle = Radian(Random(3600)/10.)
Radius = Sqr(Random(1000)/1000.)*Sqr(Bullet()\Weight)*5
AddElement(Spark())
Spark()\Position = Bullet()\Position
Spark()\Velocity = Bullet()\Velocity
Spark()\Velocity\X + Cos(Angle)*Radius
Spark()\Velocity\Y + Sin(Angle)*Radius
Spark()\Color = Bullet()\Color + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 2500 + Random(500)
Spark()\Blink = #True
Next
EndSelect
DeleteElement(Bullet())
ElseIf Random(1) = 0
Radius = Random(50)+50
Angle = Radian(Random(100)/10.-5) + ATan2(Bullet()\Velocity\X, Bullet()\Velocity\Y)
AddElement(Spark())
Spark()\Position = Bullet()\Position
Spark()\Velocity = Bullet()\Velocity
Spark()\Velocity\X - Cos(Angle)*Radius
Spark()\Velocity\Y - Sin(Angle)*Radius
Spark()\Color = $40B0F0 + (Random($F)|Random($F)<<8|Random($F)<<16)
Spark()\Time = Time + 1000 + Random(1000)
EndIf
Next
If Random(20) = 0
Angle = Radian(Random(400)/10.+250)
AddElement(Bullet())
Bullet()\Position\X = ScreenWidth()/2 - 100 + Random(200)
Bullet()\Position\Y = ScreenHeight()
Bullet()\Velocity\X = Cos(Angle)*350
Bullet()\Velocity\Y = Sin(Angle)*350
Bullet()\Color = PeekI(?Color+Random(5)*SizeOf(Integer))
Bullet()\Time = Time + 2000 + Random(500)
Bullet()\Weight = 100+Random(800)
Bullet()\Type = Random(2)
EndIf
StopDrawing()
FlipBuffers()
ForEver
DataSection
Color:
Data.i $4060F0, $00F040, $F08040, $00D0F0, $F040C0, $F0F0F0
EndDataSection