Les fichiers qui vont bien (logo + fichier ogg) sont ici : http://bombseb.free.fr/TEMP/Chaosstarfield/
le code source :
Code : Tout sélectionner
If InitSprite () = 0
MessageRequester ("Erreur", "Impossible d'initialiser directx", #PB_MessageRequester_Ok)
End
EndIf
; ; ---------- Mode fenetré ----------
; #WindowWidth = 400
; #WindowHeight = 300
; hWnd = OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test")
; If hwnd = 0
; MessageRequester ("Erreur", "Impossible d'ouvrir l'écran", #PB_MessageRequester_Ok)
; End
; EndIf
;
; If OpenWindowedScreen(hWnd, 0, 0, #WindowWidth, #WindowHeight, 1, 0, 0) = 0
; MessageRequester ("Erreur", "Impossible d'ouvrir l'écran", #PB_MessageRequester_Ok)
; End
; EndIf
; ; ----------------------------------
; ou
;---------- Plein écran ----------
#WindowWidth = 640
#WindowHeight = 480
If OpenScreen(640, 480, 32, "Starfield") = 0
MessageRequester ("Erreur", "Impossible d'ouvrir l'écran", #PB_MessageRequester_Ok)
End
EndIf
;----------------------------------
InitKeyboard ()
ClearScreen (0,0,0)
FlipBuffers ()
ClearScreen (0,0,0)
; ---------- INIT ----------
#nb = 500
Dim x2.f(#nb)
Dim y2.f(#nb)
Dim decalx.f (#nb)
Dim decaly.f (#nb)
Dim dist.f(#nb)
Dim col(#nb)
For i = 1 To #nb
x2.f(i) = (Random (256) - 128)
If x2(i) = 0
x2(i) = 1
EndIf
y2.f(i) = (Random (256) - 128)
If y2(i) = 0
y2(i) = 1
EndIf
dist(i) = Random (20)
If dist(i) = 0
dist(i) = 1
EndIf
col (i) = Abs (x2(i)) + Abs (y2(i))
Next
;------- init du son -------
If InitSound () = 0
MessageRequester ("Erreur", "Impossible d'utiliser la carte son",#PB_MessageRequester_Ok)
End
EndIf
UseOGGSoundDecoder()
Result = CatchSound(1, ?chaos, 1182796)
If Result = 0
MessageRequester ("Erreur", "Impossible d'ouvrir le fichier ogg",#PB_MessageRequester_Ok)
End
EndIf
; --- Logo ---
UseJPEGImageDecoder()
Result = CatchSprite(1, ?chaoslogo)
If result = 0
MessageRequester ("Erreur", "Impossible d'ouvrir le logo",#PB_MessageRequester_Ok)
End
EndIf
Restore Chaosrythm
Read chaosbeat
PlaySound (1)
starttime = ElapsedMilliseconds()
Repeat
ExamineKeyboard ()
ClearScreen(0,0,0)
If ElapsedMilliseconds() - starttime >= chaosbeat
decalxbeat = Random (20) - Random (10)
decalybeat = Random (20) - Random (10)
Read chaosbeat
If chaosbeat = -1
Goto fin
EndIf
Else
decalxbeat = decalxbeat * 0.8
decalybeat = decalybeat * 0.8
EndIf
DisplaySprite(1, 100 + decalxbeat, 164 + decalybeat)
If StartDrawing (ScreenOutput ())
rx2.f = rx2 * 0.99 + (Random (10) - 5) / 1000
ry2.f = ry2 * 0.99 + (Random (10) - 5) / 1000
rx.f = rx * 0.99 + rx2
ry.f = ry * 0.99 + ry2
For i = 1 To #nb
x2.f(i) = rx * dist (i) / 3 + x2(i) * 1.005
y2.f(i) = ry * dist (i) / 3 + y2(i) * 1.005
x.f = (#WindowWidth / 2) + x2(i) + decalx(i) * dist(i)
y.f = (#WindowHeight / 2) + y2(i) + decaly(i) * dist(i)
If x < 0 Or x > #WindowWidth-1 Or y < 0 Or y > #WindowHeight-1
x2.f(i) = (Random (256) - 128)
If x2(i) = 0
x2(i) = 1
EndIf
y2.f(i) = (Random (256) - 128)
If y2(i) = 0
y2(i) = 1
EndIf
dist.f(i) = Random (20)
If dist(i) = 0
dist(i) = 1
EndIf
decalx.f (i) = -rx * dist (i)
decaly.f (i) = -ry * dist (i)
col (i) = Abs (x2(i)) + Abs (y2(i))
Else
Plot (x,y,RGB (col(i),col(i),col(i)))
EndIf
Next
StopDrawing ()
EndIf
FlipBuffers ()
Delay (15)
Until KeyboardPushed (#PB_Key_Escape)
Fin :
StopSound (1)
End
DataSection
chaos : IncludeBinary "chaosseb.ogg"
chaoslogo : IncludeBinary "chaosstarfieldlogo.jpg"
chaosrythm :
Data.l 375,609,1093,1421,2062,2359,2968,3265,3859,4171,4437,5000,5375,5984,6296,6875,7203,7812,8109,8421,9015,9359
Data.l 9937,10281,10843,11203,11765,12109,12421,13015,13359,13921,14265,14906,15250,15812,16156,16453,17015,17390
Data.l 17968,18296,18890,19234,19828,20093,20406,21000,21375,21984,22328,22937,23265,23828,24140,24437,25000,25343
Data.l 25984,26328,26890,27234,27781,28078,28609,29093,29640,30171,30656,31187,31671,32171,32656,33156,33656,34156
Data.l 34640,35125,35625,36109,36593,37109,37593,38093,38625,39109,39640,40125,40609,41140,41640,42109,42484,43093
Data.l 43421,44031,44328,44937,45250,45859,46156,46578,47031,47375,47968,48312,48921,49234,49796,50109,50406,50968
Data.l 51359,51921,52296,52859,53203,53734,54062,54375,54968,55359,55953,56296,56859,57234,57765,58140,58640,59031
Data.l 59375,59968,60312,60921,61265,61828,62125,62421, -1