note : Ce n'est pas encore le résultat que je voudrais, mais il est tard
Code : Tout sélectionner
InitSprite()
InitKeyboard()
OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
Structure explo
x.d
y.d
radius.d
radius_max.d
angle.d
vit.d
vity.d
rebour.l
compteur.l
mem.l
distance.d
rayon_atteint.d
EndStructure
Structure feux
x.d
y.d
angle.d
vit.d
rebour.l
couleur.l
nb_explosion.l
Array explo.explo(1)
rayon_max.l
phase.l
rebour_max.l
EndStructure
NewList fusee.feux()
For i = 0 To 0
AddElement(fusee())
Next
Dim couleur.l(2)
couleur(0) = 0
couleur(1) = 1
couleur(2) = 2
nb_explo = 250
clear = 1
Repeat
event = WindowEvent()
ExamineKeyboard()
tpf = ElapsedMilliseconds() - t
t = ElapsedMilliseconds()
If KeyboardPushed(#PB_Key_Left)
nb_explo - 10
If nb_explo < 10
nb_explo = 10
EndIf
EndIf
If KeyboardPushed(#PB_Key_Right)
nb_explo + 10
EndIf
If KeyboardPushed(#PB_Key_Up)
AddElement(fusee())
EndIf
If KeyboardPushed(#PB_Key_Down)
If LastElement(fusee())
DeleteElement(fusee())
EndIf
EndIf
If KeyboardReleased(#PB_Key_Space)
clear = -clear
EndIf
If clear = 1
ClearScreen(0)
EndIf
If StartDrawing(ScreenOutput())
If tpf
DrawText(0, 0, Str(1000 / tpf))
EndIf
DrawText(0, 20, "[Right/Left] nb_explo = " + Str(nb_explo))
DrawText(0, 40, "[Up/Down] nb_fusée = " + Str(ListSize(fusee())))
DrawText(0, 80, "[Space] : Trainées")
nb_cercle = 0
ForEach fusee()
With fusee()
If \phase = 0
\x = 400
\y = 600
\angle = (Random(40) - 20 + 270) * #PI / 180
\vit = Random(5) + 7
RandomizeArray(couleur())
\couleur = (Random(50) + 200) << (8 * couleur(0)) + (Random(50) + 100) << (8 * couleur(1)) + (Random(50) + 0) << (8 * couleur(2))
val.d = Random(600 / \vit / 10) + 2 * 600 / \vit / 3
\rebour = Int(val)
\nb_explosion = nb_explo
Dim \explo(\nb_explosion)
\rayon_max = Random(150) + 50
\phase + 1
ElseIf \phase = 1
\x = \x + \vit * Cos(\angle)
\y = \y + \vit * Sin(\angle)
Line(\x, \y, -20 * Cos(\angle), -20 * Sin(\angle), \couleur)
\rebour - 1
If \rebour < 0 ; explosion
\rebour_max = 0
For i = 0 To \nb_explosion
\explo(i)\x = \x
\explo(i)\y = \y
\explo(i)\angle = Random(360) * #PI / 180
\explo(i)\vit = 0.6 * (Random(5) + 7)
\explo(i)\vity = 0
\explo(i)\radius = 0
\explo(i)\radius_max = Random(3) + 4
val.d = 2*Random(\rayon_max) / \explo(i)\vit
\explo(i)\rebour = Int(val)
\explo(i)\compteur = 0
\explo(i)\rayon_atteint = Random(\rayon_max)
\explo(i)\distance = 0
If \rebour_max < \explo(i)\rebour
\rebour_max = \explo(i)\rebour
EndIf
Next
\phase + 1
EndIf
ElseIf \phase = 2
ok = \nb_explosion
For i = 0 To \nb_explosion
If \explo(i)\compteur > \explo(i)\rebour
ok - 1
EndIf
\explo(i)\compteur + 1
If \explo(i)\distance < \explo(i)\rayon_atteint
\explo(i)\x = \explo(i)\x + \explo(i)\vit * Cos(\explo(i)\angle)
\explo(i)\y = \explo(i)\y + \explo(i)\vit * Sin(\explo(i)\angle) + \explo(i)\vity
\explo(i)\distance + \explo(i)\vit
If \explo(i)\compteur <= \explo(i)\rebour
\explo(i)\radius = \explo(i)\radius_max * \explo(i)\compteur / \explo(i)\rebour
EndIf
\explo(i)\mem = \explo(i)\compteur
coef.d = 1
Else
\explo(i)\x = \explo(i)\x + \explo(i)\vit * Cos(\explo(i)\angle) * 0.1
\explo(i)\y = \explo(i)\y + \explo(i)\vit * Sin(\explo(i)\angle) * 0.1 + \explo(i)\vity
coef.d = 1 - (\explo(i)\compteur - \explo(i)\mem) / (\rebour_max - \explo(i)\mem)
If coef < 0 : coef = 0 : EndIf
EndIf
\explo(i)\vity + 0.05
Circle(\explo(i)\x, \explo(i)\y, \explo(i)\radius, RGB(Red(\couleur) * coef, Green(\couleur) * coef, Blue(\couleur) * coef))
nb_cercle + 1
Next
If ok <= 0
\phase + 1
EndIf
Else
\phase = 0
EndIf
EndWith
Next
DrawText(0, 60, "nb_cercle = " + Str(nb_cercle))
StopDrawing()
EndIf
FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End