This is a more complicated source, it shows how to use the Midas dll to play music and I also made the classic 3D space trip to go with it.
Music is by heatbeat. The source needs the files in the attachment, which also contains an exe for those without Purebasic.
;
; 3D Starfield + Sine Scroll Intro By Nick Simpson 2005.
;
;==============================================================================================
;----------------------------------------------------------------------------------------------
Global xres.w , yres.w , starnum.l , a.l , tx.w , ty.w , halfx.w , halfy.w , spd.f , m.f
;----------------------------------------------------------------------------------------------
xres = 640; Screen Width.
yres = 480; Screen Height.
halfx = xres/2; Precalc Here To Save
halfy = yres/2; Cycles Later.
;----------------------------------------------------------------------------------------------
starnum = 5000; How Many Stars To Have.
Dim starx.w(starnum); Star X Positions.
Dim stary.w(starnum); Star Y Positions.
Dim starz.f(starnum); Star Z Positions.
;----------------------------------------------------------------------------------------------
; Set Star Positions;
;----------------------------------------------------------------------------------------------
For a=1 To starnum
starx(a)=-7500+(Random(15000))
stary(a)=-20000+(Random(40000))
starz(a)=Random(30)
Next
;----------------------------------------------------------------------------------------------
; Start The Music;
;----------------------------------------------------------------------------------------------
InitSound()
InitModule()
LoadModule(1,"sj.xm")
PlayModule(1)
;----------------------------------------------------------------------------------------------
InitSprite(); Initialise DirectX.
window = OpenScreen ( xres , yres , 32 , "(C) Nick Simpson 2005."); Open Screen.
InitKeyboard(); Initialise Keyboard.
;==============================================================================================
; Main Loop Begins;
;==============================================================================================
Repeat
; Draw Stuff;
StartDrawing(ScreenOutput())
Box (0,0,xres,50,$201010)
Box (0,yres-50,xres,50,$201010)
spd=0.5*Sin((m*3.14)/580)
xsp=150*Cos((m*3.14)/870)
ysp=150*Cos((m*3.14)/970)
m=m+1
;If m>360
;m=m-360
;EndIf
For a=1 To starnum
tx=(starx(a)/starz(a))+halfx
ty=(stary(a)/starz(a))+halfy
If tx>1 And tx<xres-1 And ty>1 And ty<yres-1
If ty<50 Or ty>yres-50
clr1=(1+(Int(30-starz(a)))*$010202)
clr2=(1+(Int(30-starz(a)))*$080707)
Else
clr1=(Int(30-starz(a)))*$060303
clr2=(Int(30-starz(a)))*$0a0a0a
EndIf
Plot (tx,ty,clr2)
Plot (tx-1,ty,clr1)
Plot (tx+1,ty,clr1)
Plot (tx,ty-1,clr1)
Plot (tx,ty+1,clr1)
EndIf
starx(a)=starx(a)+xsp
stary(a)=stary(a)+ysp
starz(a) = starz(a) + spd
If xsp>0
If starx(a)>7500
starx(a)=starx(a)-15000
EndIf
EndIf
If xsp<0
If starx(a)<-7500
starx(a)=starx(a)+15000
EndIf
EndIf
If ysp>0
If stary(a)>7500
stary(a)=stary(a)-15000
EndIf
EndIf
If ysp<0
If stary(a)<-7500
stary(a)=stary(a)+15000
EndIf
EndIf
If spd<0
If starz(a)<=0
starz(a)=starz(a)+30
EndIf
EndIf
If spd>0
If starz(a)>=30
starz(a)=starz(a)-30
EndIf
EndIf
Next
Line (0,50,xres,0,$ffffff)
Line (0,yres-50,xres,0,$ffffff)
StopDrawing()
FlipBuffers()
ClearScreen(0,0,0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
;==============================================================================================
; End Of Main Loop.
;==============================================================================================
;StopModule()
End