Help add play time to particle

Blitz3D Forums/Blitz3D Programming/Help add play time to particle

Hi. I'm having a problem trying to add the amount of song play time to the particle's life time.

Optimized Code:

Include "WB3DStyles.bb"

Const wm_paint = $000f

Include "particle candy.bb"
Include "mcimp3.bb"
Include "mcimidi.bb"
Include "mciwav.bb"

; setup gfx mode.
Graphics3D 800,600,32,2

Global play_time

Global mp3length

Global midilength

Global mwavlength

Global copyright$ = "Copyright (c) 2008 - 2009 Photo-Xtreme"+Chr$(13)+"          Created by: ~ZeldaX~"

Global cam

cam = CreateCamera()

Listener = CreateListener(Cam, .005, 1, 1)

Global RuntimeWindow_hWnd = WB3D_InitializeGUI(SystemProperty("AppHwnd"),10,10,800,600)
WB3D_DragAcceptFiles RuntimeWindow_hWnd,True

; quick playlist contains the filename of files To be played
Dim playlist$(200)

; the playing loaded_song, and its play status  
Global loaded_song,loaded_song_playing

; the index of the loaded_song playing
Global current_loaded_song_index = 0

menus = WB3D_WindowMenu(RuntimeWindow_hWnd)
file = WB3D_CreateMenu("&File",0,menus,0)
	OpenItem = WB3D_CreateMenu("Open",1,file,0) 
	
	SaveItem = WB3D_CreateMenu("Save",2,file,0)

	WB3D_CreateMenu("",0,file,0)
	QuitItem = WB3D_CreateMenu("Quit",3,file,0)

about = WB3D_CreateMenu("About",0,menus,1)

about1 = WB3D_CreateMenu("About...",4,about,0)

option = WB3D_CreateMenu("Options",5,menus,1)

loop = WB3D_CreateMenu("Loop",6,option,0)
		
u=WB3D_UpdateWindowMenu(RuntimeWindow_hWnd)


statusbar = WB3D_CreateStatusBar(RuntimeWindow_hWnd,"")
s1=WB3D_SetStatusParts(statusbar,5+1)

s2=WB3D_StatusPartWidth(statusbar,0,150)
s3=WB3D_StatusPartWidth(statusbar,1,150)
s4=WB3D_StatusPartWidth(statusbar,2,150)
s5=WB3D_StatusPartWidth(statusbar,3,150)
s6=WB3D_StatusPartWidth(statusbar,4,150)
s7=WB3D_StatusPartWidth(statusbar,5,150)
s8=WB3D_StatusPartWidth(statusbar,6,150)

If s1 Or s2 Or s3 Or s4 Or s5 Or s6 Or s7 Or s8 Then WB3D_UpdateStatusbar(statusbar)

; cleanup any old creation events, its better to do this before we enter the main
; event loop, when some gadgets are created they generate events.
WB3D_FlushEvents 

; setup out quit flag, and loop until the flag is set.
QUIT = 0

p1=InitParticles(cam,"Media\particles.png", 3)
p2=SetParticleUpdateCycle(2)

EM8 = CreateEmitter_Waterfall()

While Not QUIT Or KeyHit(1)

;If mciplaying(loaded_song_playing) And EM8 <> 0 Then Update_particle(EM8)

		event = WB3D_WaitEvent()
	Select event

		Case $1001 ; menu selection
			
			menuID = WB3D_EventData()
			Select menuID
				
;				Case 44
;					WB3D_Notify "","here",0
					
				Case 1 ; open
					; file extensions
					; first the description then the .extension
					; open filerequester and select song to play
ext$ = "*.mp3"+Chr$(0)+"*.mp3"+Chr$(0)
file1$ = WB3D_OpenFileRequest("..","..",ext$,"")
playlist(0) = file1$
					process_playlist()
											
				If FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav"
				test = 1
												
				If test = 1 Then Emitter_Start(EM8) : Else test = 0
				
				Else
				
				notify()
								
				EndIf
				
				Case 2 ; save
					save_file_ext$ = "BlitzBasic Source Code"+Chr(0)+"*.bb"+Chr(0)+"Text"+Chr(0)+"*.txt"+Chr(0)
					save$ = WB3D_SaveFileRequest("select file save","D:\Blitz3D_GUI_DLL",save_file_ext$,"Test")
					If save$ <> "" Then WB3D_Notify("Selected File To Save",save$,0)
					
				Case 3 ; quit
					
					WB3D_EndGUI()
					EndGraphics 
					
					Print "finished press mouse button"
					MouseWait
					End
				
;				Case 5,6,7 ; test radio check menu items 5,6,7
;					WB3D_RadiocheckMenu editmenu_window_1,5,7,menuID

				Case 4
				WB3D_Notify "Menu",copyright$,0

				Case 15 
					
					
					selectedColor = WB3D_RequestColor(100,100,105)
					If selectedColor <> 0 Then
						red = WB3D_RequestedRED()
						green = WB3D_RequestedGREEN()
						blue = WB3D_RequestedBLUE()
					EndIf
					WB3D_Notify "colors","red "+red+" green "+green+" blue "+blue,0

				Case 16
					newdir$ = WB3D_RequestDir("Select NEW Folder",newdir$)
					WB3D_Notify "folder selected","You Selected: "+newdir$,0
				
				Case 17
					font = WB3D_OpenFontRequest()
					WB3D_Notify "font selected","Selected font pointer: "+font,0
					WB3D_Usefont button,font
					
				Case 6000
					;Notify "context menu","6000",0
					WB3D_ShowGadget RuntimeWindow_hWnd
					WB3D_ShowGadget window
					
				Case 6001
					;Notify "context menu","6001",0
					WB3D_HideGadget RuntimeWindow_hWnd
					WB3D_HideGadget window
				Case 6002
					WB3D_Notify "WB3D Demo","WB3D Copyright Kevin Poole"+Chr(13)+"2005,2006.",0
					
				Case 5000
					WB3D_Notify "context menu","5000",0
					
				Case 5001
					WB3D_Notify "context menu","5001",0
							
			End Select
			
					Case WB3D_EVENT_DRAGDROP
			Select WB3D_EventSource()	

				Case RuntimeWindow_hWnd
				
					For do_files = 0 To WB3D_CountDroppedFiles()
		                file1$ = WB3D_DroppedFileName(do_files)
						playlist(do_files) = file1$
					Next
					
						process_playlist()
					
					If file1$ <> "" Then
					test = 1
					
					EndIf
										
					If test = 1 Then Emitter_Start(EM8) : Else test = 0
									
			End Select		
			
		Case $208	; mouse wheel
				flagkey = WB3D_EventFlagKey()
				wheeldata = WB3D_EventData()
				cursx = WB3D_EventX()
				cursy = WB3D_EventY()
						
		Case WB3D_EVENT_GADGET	; gadget event
			id = WB3D_EventSource()
			
			Select id
				
				Case floatbutton
					ret_notify_code = WB3D_Notify("Testing......","WB3D_Notify Test",MB_CANCELTRYCONTINUE Or MB_ICONEXCLAMATION)
					Select ret_notify_code
						Case IDCANCEL
							WB3D_Notify "You Selected","Cancel button was selected",0
								
						Case IDRETRY
						 	WB3D_Notify "You Selected","Retry button was selected",0
						
						Case IDCONTINUE
						 	WB3D_Notify "You selected","Continue button selected",0
						
					End Select
					
				Case trackbar_red
					track_red_pos = WB3D_GetTrackBarPos(trackbar_red)

				Case trackbar_green
					track_green_pos = WB3D_GetTrackBarPos(trackbar_green)

				Case trackbar_blue
					track_blue_pos = WB3D_GetTrackBarPos(trackbar_blue)
					
					
				Case toggle1 
					WB3D_Notify "","Toggle Button State "+WB3D_ButtonState(toggle1),0

				Case toggle2 
					WB3D_Notify "","Toggle Button State "+WB3D_ButtonState(toggle2),0
					
				Case button_tab0
					splash_window = WB3D_CreateWindow("spash window",400,140,320,250,0,0)
					panel_splash = WB3D_CreatePanel(20,20,400,200,splash_window,0)
					WB3D_AddPanelImage panel_splash,"SPLASH.bmp"

				Case button_tab1
					WB3D_Notify "button_tab1","button_tab1",0

				Case button_tab2
					WB3D_Notify "button_tab2","button_tab2",0

				Case button_tab3
					WB3D_Notify "button_tab3","button_tab3",0
					
				Case toolbar
					WB3D_Notify "toolbar","toolbar: "+WB3D_EventData(),0

				Case toolbar2
					WB3D_Notify "toolbar2","toolbar2: "+WB3D_EventData(),0
					
				Case listview
					
					If WB3D_EventEdited() = 0 Then

						selectedcolumn = WB3D_EventData()
						If(selectedcolumn = -1) Then
							oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),WB3D_SelectedListViewItem(listview),22,0)
							WB3D_Notify "listview","listview item selected "+WB3D_SelectedListViewItem(listview),0
						Else
							WB3D_Notify "listview","listview column clicked "+selectedcolumn,0
						EndIf
					
					EndIf
																
				Case button
					
					
				Case edit
					 
				Case combo1
					selected = WB3D_SelectedGadgetItem(combo1)
					
					If selected <> -1 Then
						WB3D_Notify "combo Selected","combo Selected "+selected,0
					
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),-1	; -1 use same icon
							WB3D_SelectGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex()
						EndIf
					EndIf

				Case combo2
					selected = WB3D_SelectedGadgetItem(combo2)
					
					If selected <> -1 Then
						WB3D_Notify "combo Selected","combo Selected "+selected,0
					
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),-1	; -1 use same icon
							WB3D_SelectGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex()
						EndIf
					EndIf
					
				Case listbox
								
										
					If WB3D_EventEdited() = 0 Then
												
						; wb3d_eventdata returns -1 if the items label was clicked, or the index of
						; the items whos checkbox has been selected
						checkbox_selected = WB3D_EventData()
					
						; has the listbox checkbox generated the event?
						If checkbox_selected = -1 Then
							selected = WB3D_SelectedGadgetItem(listbox)
							oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),selected,22,0)
							WB3D_Notify "listbox Selected","listbox Selected "+selected,0
						Else
							selected = checkbox_selected
							WB3D_Notify "listbox Selected","listbox Selected "+selected+Chr(13)+"Checkbox Selected "+WB3D_ListCheckState(listbox,selected),0
						EndIf
								
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),0
						EndIf
					EndIf
					

				Case button2
					
					WB3D_ShowGadget window_floating
										
										
				Case tabber
					selectedtab = WB3D_EventData()
					
					Select selectedtab
					
						Case 0
							WB3D_ShowGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel2
							WB3D_HideGadget panel3
						
						Case 1
							WB3D_ShowGadget panel1
							WB3D_HideGadget panel0
							WB3D_HideGadget panel2
							WB3D_HideGadget panel3
						
						Case 2
							WB3D_ShowGadget panel2
							WB3D_HideGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel3
						
						Case 3
							WB3D_ShowGadget panel3
							WB3D_HideGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel2
					
					Default
						WB3D_Notify "Tab Selected","Tab Selected "+selectedtab,0
	
						WB3D_HideGadget panel0
						WB3D_HideGadget panel1
						WB3D_HideGadget panel2
						WB3D_HideGadget panel3		
					End Select
					
					oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),selectedtab,22,0)
					
				Case treeview
					
					selectednode = WB3D_EventData()
					
					If selectednode = subnode1 
						WB3D_Notify "subnode1 ","subnode1 selected",0
					Else
						WB3D_Notify "selected node","Selected Node "+selectednode ,0
					EndIf
					
					If WB3D_GetEditedLabelIndex() Then
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyTreeViewNode WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel()
						EndIf
					EndIf
					
					WB3D_SetGadgetItemIcon(WB3D_EventSource(),selectednode,22,1)

 
				Case name_field
					;
					WB3D_SetGadgetText window,WB3D_GetGadgetText(name_field)
					;WB3D_Notify "",Len(WB3D_GetGadgetText(name_field)),0
									
				
			End Select
			
		Case WB3D_EVENT_WINDOW_CLOSE   ; close window
			
			closewin = WB3D_EventSource()
			If closewin = window_floating Then
				WB3D_HideGadget window_floating
			EndIf
						
		Case $802	; window size
			; for move,moving,size,sizing see 
			; WB3D_EventData() - edge being moved Or sized
			; WB3D_EventX()	- new size, position
			; WB3D_EventY()	- new size position
			
			; update window toolbars
			;WB3D_UpdateToolbar toolbar
			;WB3D_UpdateToolbar toolbar2
			
			
			; update the status bars
			;WB3D_UpdateStatusbar status
			;WB3D_UpdateStatusbar rstatus
			

		Case $805	; window sizing	
		WB3D_Notify "","NO",0
			
		Case $806	; window moving
		WB3D_Notify "","NO",0
		
		Case $807	; window move
		
		Case $200	; mousemove
			gadget_mouse_over = WB3D_EventSource()
			gadget_mouse_overX = WB3D_EventX()
			gadget_mouse_overY = WB3D_EventY()
							
		Case $101	; key down
			
			gadget_keydown = WB3D_EventSource()
			key_code = WB3D_EventData()	
			
			Select gadget_keydown
				
				Case name_field
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Gadget Contents",WB3D_GetGadgetText(name_field),0
					EndIf
				
				Case edit
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Gadget Contents",WB3D_TextAreaText(edit),0
					EndIf

				Case listbox
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Selected Gadget Item","You Selected Item: "+WB3D_SelectedGadgetItem(listbox)+Chr(13)+"Item Text: "+WB3D_GadgetItemText(listbox,WB3D_SelectedGadgetItem(listbox)),0
					EndIf
				
				Case spinner_label
					
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Spinner ","Spinner Value "+WB3D_GetSpinnerPos(spinner),0
						;WB3D_SetSpinnerPos(spinner,WB3D_GetGadgetText(spinner_label))
					EndIf
					
			End Select
		
		Case $502	; gadgets context menus
				gadget = WB3D_EventSource()
				
				;;Notify Hex(window),Hex(gadget),0
								
				contextmenu_popup = 0
				Select gadget
						
					Case RuntimeWindow_hWnd	
						contextmenu_popup = contextmenu_RuntimeWindow_hWnd
					
					Case button,button3
						contextmenu_popup = contextmenu_button_hWnd
					
					Case listview,listbox
						contextmenu_popup = contextmenu_list_hWnd
					
					Case edit 
						contextmenu_popup = contextmenu_edit_hWnd
								
				End Select
				WB3D_TrackContextMenu(gadget,contextmenu_popup,WB3D_EventX(),WB3D_EventY())
			
		Case $503	; system tray
			
			eventtype = WB3D_EventData()
			
			Select eventtype
				
				Case 1
					WB3D_Notify "system tray","system tray left mouse double click",0

				Case 2,3
					WB3D_TrackContextMenu(WB3D_EventSource(),contextmenu,WB3D_EventX(),WB3D_EventY())
			End Select
		
		
;		Case $504	; drag and drop files
;			gadget = WB3D_EventSource()
			
			
;			For do_files = 0 To WB3D_CountDroppedFiles()
;				WB3D_Notify "",""+WB3D_DroppedFileName(do_files),0
;			Next
		
		Case $200
												
	Default
		
		; reset wheel move flag 	
		wheeldata = 0
		
	End Select

If em8 <> 0

PositionEntity em8, 0, 1, 20

EndIf
 
x = 0 : y = 0
		
		If em0 > 0 Or em1 > 0 Or em2 > 0 Or em3 > 0 Or em4 > 0 Or em5 > 0 Or em6 > 0 Or em7 > 0 Or em8 > 0 Or em9 > 0 Or em10 > 0 Or em11 > 0 Then 

        updateParticles()

		EndIf
		
		If em0 Or em1 Or em2 Or em3 Or em4 Or em5 Or em6 Or em7 Or em8 Or em9 Or em10 Or em11
		 If em0 = 0 Or em1 = 0  Or em2 = 0 Or em3 = 0 Or em4 = 0 Or em5 = 0 Or em6 = 0 Or em7 = 0 Or em8 = 0 Or em9 = 0 Or em10 = 0 Or em11 = 0 Then FreeParticleSystem()
		
		EndIf
	
	UpdateWorld
	RenderWorld

;	If ChannelPlaying(loaded_song_playing) Then Text 10,10,"Playing loaded song: "+playlist(current_loaded_song_index) : Else Text 10, 10, "Please load song."
	
	; generate an internal blitz event
	Flip


	; process the playlist	
	
Wend

If test Then test = 0

If playa And mciplaying(loaded_song_playing) Or mciplaying(loaded_song_playing) Or QUIT Then playa = 0 : stopm()

WB3D_Notify "WB3D GUI Window Example","Bye, Thats It I Quit",MB_OK Or MB_ICONASTERISK

WB3D_EndGUI()
EndGraphics
End

Function CreateEmitter_Waterfall% ()
	Local EM%,P1%,P2%,P3%
	
 	EM = CreateEmitter()

	; MIST
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,2
	ParticleType_SetSpeed    		  P1,4,2
	ParticleType_SetSize     		  P1,.75,.75,4,4
	ParticleType_SetAlpha    		  P1,1,.5,-1
	ParticleType_SetWeight   		  P1,3,2
	ParticleType_SetRotation 		  P1,0,90
	ParticleType_SetColor    		  P1,225,225,250,40,-125,-125,-100
	ParticleType_SetEmissionAngle P1,0,15
	ParticleType_SetStartOffsets  P1,-3,6,0,-1,0,0
	ParticleType_SetLifeTime 		  P1,3000
	ParticleType_SetBounce        P1,-12,0,0
	ParticleType_SetAddedBlend    P1,0
	; CLOUDS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,9
	ParticleType_SetSpeed    		  P2,2,2
	ParticleType_SetSize     		  P2,.75,.75,5,3
	ParticleType_SetAlpha    		  P2,.5,.5,-1.5
	ParticleType_SetWeight   		  P2,0,2
	ParticleType_SetRotation 		  P2,1,45
	ParticleType_SetColor    		  P2,225,225,250,40,-100,-100,-75
	ParticleType_SetEmissionAngle P2,0,15
	ParticleType_SetStartOffsets  P2,-3,6,-10.5,0,0,0
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,1
	; BUBBLES
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,3
	ParticleType_SetSpeed    		  P3,2.5,2
	ParticleType_SetSize     		  P3,.7,.5
	ParticleType_SetAlpha    		  P3,1,.5,-1
	ParticleType_SetWeight   		  P3,.5,.5
	ParticleType_SetRotation 		  P3,1,45
	ParticleType_SetColor    		  P3,210,210,250,20,-100,-100,-75
	ParticleType_SetEmissionAngle P3,0,15
	ParticleType_SetStartOffsets  P3,-3,6,1,0,0,0
	ParticleType_SetLifeTime 		  P3,1000
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetAddedBlend    P3,0
			
	   Emitter_SetSound EM,"Media\water.mp3",1
	
;	If FileExtension(playlist$(0)) = ".mp3" Then play_time = playtime(FileExtension(playlist$(0)), loaded_song)
	
;	WB3D_Notify "",play_time,0

	Emitter_AddParticleType EM, P1, 0,play_time,115
	Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
	Emitter_AddParticleType EM, P3, 0,play_time,50

	Return EM
End Function

Function playtime(songtype$, snd%)

If mciplaying(snd%) And songtype$ = "mp3" And FileExtension(playlist$(0)) = ".mp3" Then Return play_time = mcimp3length(snd%)
If mciplaying(snd%) And songtype$ = "mid" And FileExtension(playlist$(0)) = ".Mid" Then Return play_time = mcimidilength(snd%)
If mciplaying(snd%) And songtype$ = "wav" And FileExtension(playlist$(0)) = ".wav" Then Return play_time = mciwavlength(snd%)

Return play_time

End Function

Function part_time()

test1a = mcimp3length(snd)

WB3D_Notify "",test1a,0

Return test1a

End Function

Function Update_Particle(EM8)
 Local P1%, P2%, P3%

;	If mciplaying(snd) Then WB3D_Notify "",FileExtension(file1$),0
	
;	If FileExtension(file1$) = ".mp3" Then part_time = mciMp3length(snd)
;	If FileExtension(file1$) = ".mid" Then part_time = mciMidilength(snd)
;	If FileExtension(file1$) = ".wav" Then part_time = mciWavlength(snd)
	
;	If FileExtension(file1$) = ".mp3" Then WB3D_Notify "",part_time+";"+mciMp3length(snd),0
;	If FileExtension(file1$) = ".mid" Then WB3D_Notify "",part_time+";"+mciMidilength(snd),0
;	If FileExtension(file1$) = ".wav" Then WB3D_Notify "",part_time+";"+mciWavlength(snd),0

If mciplaying(loaded_song_playing)

If FileExtension(file1$) = ".mp3"
play_time = playtime("mp3",loaded_song_playing)
EndIf
If FileExtension(file1$) = ".mid"
play_time = playtime("mid",loaded_song_playing)
EndIf
If FileExtension(file1$) = ".wav"
play_time = playtime("wav",loaded_song_playing)
EndIf
EndIf

If mciplaying(loaded_song_playing) Then WB3D_Notify "",play_time,0

	Emitter_AddParticleType EM, P1, 0,play_time,115
	Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
	Emitter_AddParticleType EM, P3, 0,play_time,50
	
Return play_time

End Function

Function Millisecs2Time$(m)
Local HourPart%, MinSecLeft%, MinPart%, SecLeft%, SecPart%
Local TimeStr$

   HourPart = Int(m / 3600000)
   MinSecLeft = m Mod 3600000
   MinPart = Int(MinSecLeft / 60000)
   SecLeft = m Mod 60000
   SecPart = SecLeft / 1000

   TimeStr=Str$(HourPart)+":"
   If HourPart<10 Then TimeStr="0"+TimeStr

   If MinPart<10 Then TimeStr=TimeStr+"0"
   TimeStr=TimeStr+Str$(MinPart)+":"
   
   If SecPart<10 Then TimeStr=TimeStr+"0"
   TimeStr=TimeStr+Str$(SecPart)
   
   Return TimeStr
End Function

Function mciplaying(snd)

If snd > 0 And FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav" Then playing = 1

Return playing

End Function

Function l_setAlpha(alpha#)

EntityAlpha l_surface,alpha#

End Function

Function l_update()

CopyRect 0,0,width,Height,0,0,BackBuffer(),TextureBuffer(l_texture)

End Function

Function notify()

WB3D_Notify "WARNING","Sorry, but file "+file1$+" is invalid.",0

End Function

Function stopm()

If FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav" And mciplaying(snd) Then mciMP3free() : mciMidifree() : mciWavfree()
If FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav" And ChannelPlaying(loaded_song_playing) Then StopChannel(snd) : FreeSound(loaded_song_playing)

End Function

Function Write_BB(appname$, filedata$)

readme=WriteFile("README.txt")

WriteLine readme, "Please use Blitz3D to compile your project!"

file=WriteFile(filedata$)

WriteLine file, "AppTitle "+Chr$(34)+appname$+Chr$(34)

WriteLine file, ""

WriteLine file, "Graphics3D "+screenwidth+", "+screenheight+", "+screendepth+", "+screenmode

WriteLine file, ""

WriteLine file, "cam = CreateCamera()"

WriteLine file, "CameraRange cam, .1, 1000000"

WriteLine file, "PositionEntity cam, "+xcam+", 1, "+zcam

WriteLine file, ""

WriteLine file, "Land = CreatePlane()"

WriteLine file, ""

WriteLine file, "While Not Keyhit(1)"

WriteLine file, ""

WriteLine file, "If KeyDown(200) Or KeyDown(208) MoveEntity cam, 0, 0, (KeyDown(200)-KeyDown(208))*1"

WriteLine file, "If KeyDown(203) Or KeyDown(205) TurnEntity cam, 0, (KeyDown(203)-KeyDown(205))*1, 0"

WriteLine file, ""

WriteLine file, "UpdateWorld()"

WriteLine file, "RenderWorld()"

WriteLine file, ""

WriteLine file, "Flip"

WriteLine file, ""

WriteLine file, "Wend"

CloseFile file

WB3D_Notify "Menu","Compilation Successful",0

WB3D_Notify "Menu","Compiled file in: "+CurrentDir$(),0

End Function

Function get_menu()

menu = menu + 1

If menu > 43 Then menu = 43

Return menu

End Function

Function File_Extension$(ext$)

For I% = Len(ext$) To 1 Step -1

If Mid$(ext$, I%,1) = "," Then Return "*"+Left(ext$, I%-1)+";"+"*"+ Right$(ext$, I%-1)

Next

End Function

Function FileName$(File$)
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return Mid(File$, I% + 1)
	Next
Return File$
End Function

Function FileExtension$(File$)
If FileType(file$) = 1
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "." Return "."+Mid(File$, I% + 1)
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return ""
	Next
Else
Return "Unknown"
EndIf
End Function

Function FilePath$(File$)
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return Left(File$, I% - 1)
	Next
End Function

; Adds a file extention, if not exists. | F?Et eine Dateiendung hinzu falls noch keine da ist.
Function AddFileExtension$(File$, Extension$)
If FileExtension(File$) = "" Then Return File$ + "." + Extension$ Else Return File$
End Function

; plays the next loaded_song in the playlist, or reset to the first loaded_song.
Function process_playlist()

	; return if loaded_songs still playing
;	If ChannelPlaying(loaded_song_playing) = 1 
;		Return
;	Else
;	
;		; free the memory of the finished loaded_song
;		FreeSound loaded_song
;
;		; move to the next loaded_song in the playlist
;		current_loaded_song_index = current_loaded_song_index + 1
;
;		; check we have a loaded_song in the playlist, if we do play it
;		If playlist(current_loaded_song_index) <> "" Then
;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
;		Else
;			; loop playlist 
;			current_loaded_song_index = 0
;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
;		EndIf
;	EndIf

	; return if loaded_songs still playing
	If mciplaying(loaded_song_playing) = 1 
		Return
	Else
	
		; free the memory of the finished loaded_song
		mcimp3free() : mcimidifree() : mciwavfree()

		; move to the next loaded_song in the playlist
		current_loaded_song_index = current_loaded_song_index + 1

		; check we have a loaded_song in the playlist, if we do play it
		If playlist(current_loaded_song_index) <> "" Then

request(playlist(current_loaded_song_index))

;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
		
Else
			; loop playlist 
			current_loaded_song_index = 0

request(playlist(current_loaded_song_index))

;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
		EndIf
	EndIf
	
End Function

Function request(test1)

loaded_song = mciMP3Open(test1) : loaded_song_playing = mciMP3Play(loaded_song)

						 
If FileExtension(playlist$(0)) = ".mp3" Or FileExtension(playlist$(0)) = ".mid" Or FileExtension(playlist$(0)) = ".midi" Or FileExtension(playlist$(0)) = ".wav" Then playa = 1

If FileExtension(playlist$(0)) = ".mid" Or FileExtension(playlist$(0)) = ".midi"

loaded_song = mciMidiOpen(playlist$(0)) : loaded_song_playing = mciMidiPlay(loaded_song)

midilength = mciMidiLength(loaded_song)

WB3D_Notify "",midilength,0

Else

If FileExtension(playlist$(0)) = ".mp3"

loaded_song = mciMP3Open(playlist$(0)) : loaded_song_playing = mciMP3Play(loaded_song)

mp3length = mciMP3Length(loaded_song)

WB3D_Notify "",mp3length,0

Else

If FileExtension(playlist$(0)) = ".wav"

loaded_song = mciWAVOpen(playlist$(0)) : loaded_song_playing = mciWAVPlay(loaded_song)

mwavlength = mciWAVLength(loaded_song)

WB3D_Notify "",mwavlength,0

EndIf

EndIf

EndIf

End Function


The line of the particle life:

Emitter_AddParticleType EM, P1, 0,play_time,115
	Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
	Emitter_AddParticleType EM, P3, 0,play_time,50


Inside CreateEmitter_Waterfall()

Basically, I want the songs play time to be the particle's life time =)

Any help would be GREATLY appreciated =)

~DarkShadowWing~

anyone? please. it would be greatly appreciated. I'm on a time schedule.... =/

~DarkShadowWing~


Hi. I'm having a problem trying to add the amount of song play time to the particle's life time.

Basically, I want the songs play time to be the particle's life time =)



I'll try to help but first I need some clarification:
* Are you sure you want each particle to live as long as a song?

That sounds very long for a particle to be honest. I can however understand why you would like the particle effect to live throughout the song.

If this is the case you should probably read up on particle effects and learn about emitters and particles and their responsibilities. (Emitters and particles are standard parts of most particle systems)

* What happens when you run your program,and how is that different from what you want to happen?

* If you want quick answers I'd strongly recommend you to make small example snippets that demonstrate whats happening along with the descriptions of what you'd like to happen.

* If you have debugged some of the problem yourself and pinpointed the problem to a certain line it will also help others on this forum to help out.

* When you do examples try to make them as small as possible (while still demonstrating the problem) and make them depend on as few external libs/userlibs as possible. It's easier for people to feel motivated to try to recreate your problem if they don't have to spend an hour trying to set up an rig that will run the program in the first place.

1) I would like the particle to live through the song. Otherwise, my project is pointless. Thats the whole idea. 2) I already showed an example above. 3) What i need, is a variable I can use as the particle's lifetime. The PROBLEM is the function w/ the particle has to be called BEFORE the loop. It wont let me use a variable AFTER the song has been called.

~DarkShadowWing~

I found this information (http://www.x-pressive.com/ParticleCandy/html/feeding.html) and i guess this is what you need:



UPDATING ATTACHED PARTICLE TYPES
With version 1.4.9, a new command has been introduced:

Emitter_UpdateSlot MyEmitter%, SlotID%, A%, B%, C%


Using this command, you can change a particle type's emission rate, start time and duration at any later time again. The parameters are the same as with the AddParticleType()-command above:
A = Delay time (in milliseconds) of that particle type
B = The duration of the particle emission in milliseconds
C = Emission rate per second.

Note, that you must provide an Emitter ID and a Slot ID here. A Slot ID can be obtained when you attach a particle type to an emitter:

SlotID% =
Emitter_AddParticleType (MyEmitter%, MyParticleType%, A%, B%, C%)


So Slot ID is the returned slot number of the emitter where this particle type has been attached to. To learn more about an emitter's particle slots, please refer to this chapter.




It should allow you to update the added particle-types after the song has been loaded with the correct playtime. (Note that you'll have to save a handle to the particle types when you first create them, to be able to update them later)


Also i see another (very probable) problem with the code:

global play_time

function playtime(song$)
  if songtype('something') then return play_time = mcimp3length(snd%)
end function

; later inside the loop:


play_time = playtime(song$)



The construction "return play_time = mcimp3length(snd%)" is probably not what you want. What this means is that if the variable play_time is the same as mcimp3length(snd%) then return True (i.e. the integer 1) as return from the function.

Most of the time play_time will probably not be equal to mcimp3length(snd%) and therefore you'll get False as return from the function and that equals integer 0.

If you instead write it like this it will probably work better:

global play_time

function playtime(song$)
  if songtype('something') then return mcimp3length(snd%)
end function

; later inside the loop:


play_time = playtime(song$)



Note that i return mcimp3length(snd%) instead of returning the result of the comparision between mcimp3length(snd%) and the play_time variable.

What do you mean save the particles to a type? Can you please show me a small example? Its the only way I know how to learn

~DarkShadowWing~

I mean exactly like it says in the example:

SlotID% = Emitter_AddParticleType (MyEmitter%, MyParticleType%, A%, B%, C%)


Notice that Emitter_AddParticleType returns a SlotID%. It is necessary that you save this slot id in some structure or variable if you want to use the function.
Emitter_UpdateSlot MyEmitter%, SlotID%, A%, B%, C%.


As you see the Emitter_UpdateSlot MyEmitter% takes the slotId as a parameter and to get a valid slotId you have to save it somewhere when calling Emitter_AddParticleType to have it later on in the main-loop after you have loaded a new song and call Emitter_UpdateSlot MyEmitter% afterwards.

I tried that. Can you show me a small example? B/c I took your advice, and it still didnt work.

Heres what I have:

Misc:

Dim Playlist$(200)


Call for particle:

Global cam

cam = CreateCamera()

Listener = CreateListener(Cam, .005, 1, 1)

p1=InitParticles(cam,"Media\particles.png", 3)
p2=SetParticleUpdateCycle(2)

EM8 = CreateEmitter_Waterfall()


Functions:

Function playtime(snd%)
  If FileExtension(playlist$(0)) = ".mp3" Then Return play_time = mcimp3length(snd%)
  If FileExtension(playlist$(0)) = ".mid" Then Return play_time = mcimidilength(snd%)
  If FileExtension(playlist$(0)) = ".wav" Then Return play_time = mciwavlength(snd%)
End Function

Function FileExtension$(File$)
If FileType(file$) = 1
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "." Return "."+Mid(File$, I% + 1)
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return ""
	Next
Else
Return "Unknown"
EndIf
End Function

Function CreateEmitter_Waterfall% ()
	Local EM%,P1%,P2%,P3%
	
 	EM = CreateEmitter()

	; MIST
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,2
	ParticleType_SetSpeed    		  P1,4,2
	ParticleType_SetSize     		  P1,.75,.75,4,4
	ParticleType_SetAlpha    		  P1,1,.5,-1
	ParticleType_SetWeight   		  P1,3,2
	ParticleType_SetRotation 		  P1,0,90
	ParticleType_SetColor    		  P1,225,225,250,40,-125,-125,-100
	ParticleType_SetEmissionAngle P1,0,15
	ParticleType_SetStartOffsets  P1,-3,6,0,-1,0,0
	ParticleType_SetLifeTime 		  P1,3000
	ParticleType_SetBounce        P1,-12,0,0
	ParticleType_SetAddedBlend    P1,0
	; CLOUDS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,9
	ParticleType_SetSpeed    		  P2,2,2
	ParticleType_SetSize     		  P2,.75,.75,5,3
	ParticleType_SetAlpha    		  P2,.5,.5,-1.5
	ParticleType_SetWeight   		  P2,0,2
	ParticleType_SetRotation 		  P2,1,45
	ParticleType_SetColor    		  P2,225,225,250,40,-100,-100,-75
	ParticleType_SetEmissionAngle P2,0,15
	ParticleType_SetStartOffsets  P2,-3,6,-10.5,0,0,0
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,1
	; BUBBLES
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,3
	ParticleType_SetSpeed    		  P3,2.5,2
	ParticleType_SetSize     		  P3,.7,.5
	ParticleType_SetAlpha    		  P3,1,.5,-1
	ParticleType_SetWeight   		  P3,.5,.5
	ParticleType_SetRotation 		  P3,1,45
	ParticleType_SetColor    		  P3,210,210,250,20,-100,-100,-75
	ParticleType_SetEmissionAngle P3,0,15
	ParticleType_SetStartOffsets  P3,-3,6,1,0,0,0
	ParticleType_SetLifeTime 		  P3,1000
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetAddedBlend    P3,0
			
	   Emitter_SetSound EM,"Media\water.mp3",1
	
		Emitter_AddParticleType EM, P1, 0,play_time,115
		Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
		Emitter_AddParticleType EM, P3, 0,play_time,50
	
	Return EM
End Function


Loop:

While not Keyhit(1)
If loaded_song
	play_time = playtime(loaded_song)
        eu = Emitter_UpdateSlot(EM8, P1, P2, P3)
	WB3D_Notify "",eu,0
    EndIf
UpdateWorld
RenderWorld
Flip
Wend


The problem is this line:

Emitter_AddParticleType EM, P1, 0,play_time,115
		Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
		Emitter_AddParticleType EM, P3, 0,play_time,50


The problem is that as you see, I must call the emitter function BEFORE the song plays, thats why it returns 0 on Emitter_AddParticleType.

I need it so it happens EVERY time I play a song =)

~DarkShadowWing~

What does your time schedule relate to?

If I dont get done by January, I'm gonna have to trash the project. I need to finish it on time, so I can start selling it. I want to hopefully get a patent for it. Or w/e I have to do to sell it on store shelves.

~DarkShadowWing~

I see that you still haven't fixed the Function playtime(snd%) in your post #8 as i suggested in my post #5, so I made a little example program that illustrates the problem a bit more clear.

Imho issues like this are should probably be posted in the beginner forums, but it's not my decision.

Global song_length


Function ExampleGetSongFunc()
	Return Rand(1500, 2500)
End Function

Function EpicFailSongLength%()
	Return song_length = ExampleGetSongFunc()
End Function

Function CorrectSongLength%()
	Return ExampleGetSongFunc()
End Function


Graphics3D 640, 480
While Not KeyHit(1)
	Cls
	Text 0,0, "Epic Fail returns: " + Str(EpicFailSongLength%())
	Text 0, 10, "Correct returns: " + Str(CorrectSongLength%())
	Flip
	Delay(1000)
Wend


i see. i know what you're doing. the prob is, i just dont know how to update the below lines:

Emitter_AddParticleType EM, P1, 0,play_time,115
		Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
		Emitter_AddParticleType EM, P3, 0,play_time,50


as its needed in CreateEmitter_Waterfall() in order to work. is it not? PLEASE do correct if Im wrong.

No offensive here intended, but how can you have dead lines, and stick to them, using a programing language you don't understand? All the best though.

No offensive here intended, but how can you have dead lines, and stick to them, using a programing language you don't understand? All the best though.


I second that.

PLEASE. I REALLY need help w/ this. I'm willing to send anyone who is willing to help me fix this very last problem the ENTIRE source. I'm desperate. I'll give whoever helps fix it a free copy of the final version AND any updates afterwords for free.

~DarkShadowWing~

PLEASE. This is the FINAL problem im having w/ it....

How do I get the variable into the Emitter_Addtype and have it update so it shows the particle?

Kev, I need your help 1 last time....

Please


i see. i know what you're doing.



No I don't think you do. If you understood the importance of my suggestion in post #5 (and very clearly exemplified in post #11), you'd know that this is one big source to your problem. The way you have written it play_time will probably be stuck on 0 (false/zero). I'm pretty sure of this even though i have never run your code.

Furthermore post #5 shows you the info you need to use to update the particle system "on the fly". Note that I have never in my life used that particle system but nevertheless i find the info that i found with google on their site clear as water to understand.

I took some time and checked other posts you've made on this forum and you seem to ask people to do the programming for you, which I find a bit strange since you apparently try to make an releasable product. When you write things like this ...

I'm on a time schedule.... =/


... and ...

Can you show me a small example?


... again and again it sounds to me that you don't really want to learn this language or understand the problems at hand, but rather get some ready code that will magically solve your problems for you.

I cannot speak for everybody here, but for my part I really enjoy helping people struggling with concepts and algorithms to understand how things work. Likewise I'm very thankful when others show me new things I haven't been able to grasp before.

All information you need to resolve this matter can now be found in this thread (I'm >95% sure about this). It's now mostly a matter of wanting to learn it and use it correctly on your part.

My hottest tip is the debugger. Use the Stop-keyword and then step through you own code and look at the variables at the same time to get a good grip on what your program is actually doing.

i fixed that..... i take some offense to this post... i do NOT want people to do it for me. The ONLY way I know how to learn is by seeing something as CLOSE to my code I show you as possible. I will even PROVE I fixed it. It wont WORK b/c you CANT repeat the CreateEmitter_Waterfall() function. And I cant learn when people give me problems about it. Im sorry, but Im already upset about something else..

I know you're trying to help, I'm not saying you're the 1 giving me problems b/c you're not. It's some other people on this forum, and i wont give names.

Anyway, I fixed the function:

Function playtime(snd%)
 Local play_time
;  If FileExtension(playlist$(0)) = ".mp3" Then Return play_time = mcimp3length(snd%)
;  If FileExtension(playlist$(0)) = ".mid" Then Return play_time = mcimidilength(snd%)
;  If FileExtension(playlist$(0)) = ".wav" Then Return play_time = mciwavlength(snd%)

If FileExtension(playlist$(0)) = ".mp3" Then play_time = mcimp3length(snd%)
If FileExtension(playlist$(0)) = ".mid" Then play_time = mcimidilength(snd%)
If FileExtension(playlist$(0)) = ".wav" Then play_time = mciwavlength(snd%)

If loaded_song Then WB3D_Notify "",FileExtension(playlist$(0))+":"+play_time,0
	
   Return play_time
End Function


If I could see an example, thats AS CLOSE to MY code as you can, THEN I might understand. The rest of my code should be in post 1.

~DarkShadowWing~

That function you got there it looks a lot better!

(of course I'd recommend against having both local and global variables called the same thing, like play_time, but I don't wanna bother you about it to much because what you wrote there should work)

Now given that I don't have access to the libs you've got I have only quickly glanced the docs, but I'll try to give some hints from how I believe it works:

Inside you function Function CreateEmitter_Waterfall% () I'd recommend you save the slots where the three particle types are added.

This code right now looks like this:

	Emitter_AddParticleType EM, P1, 0,play_time,115
	Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
	Emitter_AddParticleType EM, P3, 0,play_time,50



I'd do this:

	emitter_slot1 = Emitter_AddParticleType EM, P1, 0,play_time,115
	emitter_slot2 = Emitter_AddParticleType EM, P2, 1000,play_time-1000,40
	emitter_slot3 = Emitter_AddParticleType EM, P3, 0,play_time,50


Now what are the emitter_slot* variables? Well we'll need to access them from elsewhere so I'd suggest to just declare them global, right beside your global play_time variable:

Global play_time
Global emitter_slot1%
Global emitter_slot2%
Global emitter_slot3%


Now we've save those for future use. And what might that be?

Inside your function Function Update_Particle(EM8) You've got a new set of Emitter_AddParticleType calls.

I think you should change those calls into the calls Emitter_UpdateSlot MyEmitter%, SlotID%, A%, B%, C% that i cut&pasted into post #5.

And now i think you see where the saved emitter_slot* are going, don't you?

These calls are your way of modifying existing Particle type slots inside a "living" emitter with new parameters.

At least thats how I think this works.

Thanks mate. Im CLOSE. Can you please tell me what im doing wrong now?

I looked through particle candy, and there is a function that makes this easier. ( Emitter_IsActive(Emitter%) )

Globals:

Global play_time
Global emitter_slot1%
Global emitter_slot2%
Global emitter_slot3%


Loop:

While Not QUIT = 1 Or KeyHit(1)

If loaded_song Then update_particle(EM8)

If em8 <> 0

PositionEntity em8, 0, 1, 20

EndIf
 		
		If em0 > 0 Or em1 > 0 Or em2 > 0 Or em3 > 0 Or em4 > 0 Or em5 > 0 Or em6 > 0 Or em7 > 0 Or em8 > 0 Or em9 > 0 Or em10 > 0 Or em11 > 0 Then 

        If test Then updateParticles()

		EndIf
		
		If em0 Or em1 Or em2 Or em3 Or em4 Or em5 Or em6 Or em7 Or em8 Or em9 Or em10 Or em11
		 If em0 = 0 Or em1 = 0  Or em2 = 0 Or em3 = 0 Or em4 = 0 Or em5 = 0 Or em6 = 0 Or em7 = 0 Or em8 = 0 Or em9 = 0 Or em10 = 0 Or em11 = 0
		
		If test Then FreeParticleSystem()
		
    		EndIf
		
		EndIf

UpdateWorld
RenderWorld
Flip
Wend


Functions:

Function update_particle(EM)

WB3D_Notify "","",0

;Local EM%, P1%, P2%, P3%

If Emitter_IsActive(EM)
	emitter_slot1 = Emitter_AddParticleType(EM, P1, 0,play_time,115)
	emitter_slot2 = Emitter_AddParticleType(EM, P2, 1000,play_time-1000,40)
	emitter_slot3 = Emitter_AddParticleType(EM, P3, 0,play_time,50)
a1=Emitter_UpdateSlot(EM, emitter_slot1, 0, part_time, 115)
b1=Emitter_UpdateSlot(EM, emitter_slot2, 1000, part_time, 40)
c1=Emitter_UpdateSlot(EM, emitter_slot3, 0, part_time, 50)
WB3D_Notify "",a1,0
WB3D_Notify "",b1,0
WB3D_Notify "",c1,0
WB3D_Notify "",play_time,0
EndIf

Return play_time

End Function

Function playtime(snd%)
 Local play_time
;  If FileExtension(playlist$(0)) = ".mp3" Then Return play_time = mcimp3length(snd%)
;  If FileExtension(playlist$(0)) = ".mid" Then Return play_time = mcimidilength(snd%)
;  If FileExtension(playlist$(0)) = ".wav" Then Return play_time = mciwavlength(snd%)

If FileExtension(playlist$(0)) = ".mp3" Then play_time = mcimp3length(snd%)
If FileExtension(playlist$(0)) = ".mid" Then play_time = mcimidilength(snd%)
If FileExtension(playlist$(0)) = ".wav" Then play_time = mciwavlength(snd%)

If loaded_song And test Then WB3D_Notify "",FileExtension(playlist$(0))+":"+play_time,0
	
   Return play_time
End Function


~DarkShadowWing~

I really don't know. :-)

The code examples a beginning to look reasonable, but I am not able to see the whole code or run it myself.

I got a suggestion though: Why don't you write a completely separate program in a separate folder just to try out this feature?

If you want to try out how "Updating a particle system on the fly, making it run for exactly x seconds", it's a real advantage to try out that without all the rest of the code.

I develop software for a living and i use this technique 2-5 times a week to try out some stuff or experiment to see how something behaves "out of context".

Also while you're at it, try some debugging! You'll go from "shit, this thing does not work at all!" to "What? is play_time set to zero at this time? It can't be? I'll have to check the calc()-function once again!"

If your song is still playing check to make sure the emitter is still active...

If play_time < mcimp3length and Emitter_IsActive(EM1) = False then StartEmitter(EM1).

Mahan. If I sent you the code, could you at least look at it? I think it might work if theres a way to create a Emitter_exists() function. Emitter_IsActive() just wont do it for me.

stayne, I did, and it made no difference to me.

~DarkShadowWing~

OMG! IDK HOW! BUT I FIXED IT! HAHA! THIS IS AMAZING! There's only ONE SMALL prob left. when it repeats, it doesnt restart the Emitter. o.o

~DarkShadowWing~

Guys. I have a few probs here. I need the particle to loop EVERYTIME the music is played. Not just once then stop. Also, for some reason, my particles are being effected by play_time. Idk why, but when you use sparks for example, it doesnt look like sparks. It looks like smoke.. =/

Anyway, here's my code:

AppTitle "Particlos 1.0"

Const AW_SLIDE = $0004
Const AW_ACTIVATE = $0002
Const AW_BLEND = $0008
Const AW_HIDE = $00010000
Const AW_CENTER = $0010
Const AW_HOR_POSITIVE = $0001
Const AW_HOR_NEGATIVE = $0002
Const AW_VER_POSITIVE = $0004
Const AW_VER_NEGATIVE = $0008

Global image

Global isactive

Global particle_isOn

Global Water

Global fountain

Global sa
Global sa_type

Global Animate1

Global EM0
Global EM1
Global EM2
Global EM3
Global EM4
Global EM5
Global EM6
Global EM7
Global EM8
Global EM9
Global EM10

Include "WB3DStyles.bb"

Const wm_paint = $000f

Include "particle candy.bb"
Include "mcimp3.bb"
Include "mcimidi.bb"
Include "mciwav.bb"

; setup gfx mode.
Graphics3D 1024,768,32,2

Global soundpath$ = "Media/"

Global mp3length

Global midilength

Global mwavlength

Global copyright$ = "Copyright (c) 2008 - 2009 Photo-Xtreme"+Chr$(13)+"          Created by: ~ZeldaX~"

Global cam

cam = CreateCamera()

Light  = CreateLight()

PositionEntity cam, -4, 1, -18

Listener = CreateListener(Cam, .005, 1, 1)

Global RuntimeWindow_hWnd = WB3D_InitializeGUI(SystemProperty("AppHwnd"),0,0,GraphicsWidth(),GraphicsHeight())
WB3D_DragAcceptFiles RuntimeWindow_hWnd,True

Global mainmenu = WB3D_CreateWindow("Main Menu", 0, 0, GraphicsWidth()/4+41, GraphicsHeight()-71, Runtimewindow_hWnd, WINDOW_TITLEBAR)
WB3D_DragAcceptFiles mainmenu,True

api_MoveWindow% (Runtimewindow_hWnd, 0, 0, GraphicsWidth(), GraphicsHeight(), wm_paint)
api_MoveWindow% (mainmenu, 0, 0, GraphicsWidth()/4+41, GraphicsHeight()-71, wm_paint)

; quick playlist contains the filename of files To be played
Dim playlist$(200)

Dim emitter_slot(29)

; the playing loaded_song, and its play status  
Global loaded_song,loaded_song_playing

Dim play_time(29)

; the index of the loaded_song playing
Global current_loaded_song_index = 0

tabber = WB3D_CreateTabber(0,0,GraphicsWidth(),GraphicsHeight(),mainmenu,0)
WB3D_SetGadgetIconStrip(tabber,icons)
ss11=WB3D_CreateToolTip(tabber,"Im a tabber tooltip",0)

;For loop = 0 To 10
;	icon_index = Rnd(0,5)
;	WB3D_AddGadgetItem tabber,"item: "+loop,0,icon_index
;Next

icon_index = Rnd(0,5)
	WB3D_AddGadgetItem tabber,"Particles",0,icon_index

	WB3D_AddGadgetItem tabber,"Misc",0,icon_index
panel0 = WB3D_CreateTabberPanel(5,30,GraphicsWidth(),GraphicsHeight(),tabber)
;button_tab0 = WB3D_CreateButton("Show Panel Splash",5,10,190,40,panel0,0)
;WB3D_CreateToolTip button_tab0,"show me the splash",1

spacerock = WB3D_CreateButton("Space Rock", 10, 10, 110, 25, panel0, 0)

waterfountain = WB3D_CreateButton("Water Fountain", 10, 35, 110, 25, panel0, 0)

waterfall = WB3D_CreateButton("Waterfall", 10, 60, 110, 25, panel0, 0)

flamethrower = WB3D_CreateButton("Flame Thrower", 10, 85, 110, 25, panel0, 0)

sparks = WB3D_CreateButton("Sparks", 10, 110, 110, 25, panel0, 0)

torch = WB3D_CreateButton("Torch", 10, 135, 110, 25, panel0, 0)

smoke = WB3D_CreateButton("Smoke", 10, 160, 110, 25, panel0, 0)

rocks = WB3D_CreateButton("Rocks", 10, 185, 110, 25, panel0, 0)

smokeflares = WB3D_CreateButton("SmokeFlare", 10, 210, 110, 25, panel0, 0)

explosion1 = WB3D_CreateButton("Explosion1", 10, 235, 110, 25, panel0, 0)

explosion2 = WB3D_CreateButton("Explosion2", 10, 260, 110, 25, panel0, 0)

;font = WB3D_OpenFont("blitz",8,8,True,True,True) ; set bold ,italic ,underline to true
;WB3D_Usefont button_tab0,font


panel1 = WB3D_CreateTabberPanel(5,30,150,100,tabber)
wire = WB3D_CreateButton("Wireframe",10,10,100,20,panel1,0)
WB3D_HideGadget panel1

panel2 = WB3D_CreateTabberPanel(5,30,150,100,tabber)
button_tab2 = WB3D_CreateButton("Tab2",10,10,100,20,panel2,0)
WB3D_HideGadget panel2

panel3 = WB3D_CreateTabberPanel(5,30,150,100,tabber)
button_tab3 = WB3D_CreateButton("Tab3",10,10,100,20,panel3,0)
WB3D_HideGadget panel3


menus = WB3D_WindowMenu(RuntimeWindow_hWnd)
file = WB3D_CreateMenu("File",0,menus,0)
	OpenItem = WB3D_CreateMenu("Open",1,file,0) 
	
	Song_list = WB3D_CreateMenu(Songlist(),2,file,0)

	Menu_seperator = WB3D_CreateMenu("A",0,file,0)
	QuitItem = WB3D_CreateMenu("Quit",2,file,0)

about = WB3D_CreateMenu("About",0,menus,1)

about1 = WB3D_CreateMenu("About...",3,about,0)

option = WB3D_CreateMenu("Options",5,menus,1)

loop = WB3D_CreateMenu("Loop",6,option,0)
		
u=WB3D_UpdateWindowMenu(RuntimeWindow_hWnd)


statusbar = WB3D_CreateStatusBar(RuntimeWindow_hWnd,"")
s1=WB3D_SetStatusParts(statusbar,5+1)

s2=WB3D_StatusPartWidth(statusbar,0,150)
s3=WB3D_StatusPartWidth(statusbar,1,150)
s4=WB3D_StatusPartWidth(statusbar,2,150)
s5=WB3D_StatusPartWidth(statusbar,3,150)
s6=WB3D_StatusPartWidth(statusbar,4,150)
s7=WB3D_StatusPartWidth(statusbar,5,150)
s8=WB3D_StatusPartWidth(statusbar,6,150)

If s1 Or s2 Or s3 Or s4 Or s5 Or s6 Or s7 Or s8 Then WB3D_UpdateStatusbar(statusbar)

; cleanup any old creation events, its better to do this before we enter the main
; event loop, when some gadgets are created they generate events.
WB3D_FlushEvents 

; setup out quit flag, and loop until the flag is set.
QUIT = 0

If Not api_GetFocus() = Runtimewindow_hWnd Then api_SetFocus(Runtimewindow_hWnd)

;Animate1 = api_animatewindow(Runtimewindow_hWnd, MilliSecs()/1000*2, AW_SLIDE Or AW_BLEND)

Global p1, p2

Init_Particle()

SetParticleWind 1.0
image = load_banner()

ScaleImage image, .8, .8

Create_Particle()

While Not QUIT = 1 Or KeyHit(1)

If isactive > 1 Then isactive = 1

If KeyHit(57) Then i = 1-i : isactive = i : WB3D_Notify "",isactive,0

For id = 0 To 28

If em0 Or em1 Or em2 Or em3 Or em4 Or em5 Or em6 Or em7 Or em8 Or em9 Or em10 Then play_time(id) = playtime(loaded_song)

Next

MoveEntity cam, 0, 0, (KeyDown(200)-KeyDown(208))*1
MoveEntity cam, (KeyDown(205)-KeyDown(203))*1, 0, 0

If KeyDown(44) Or KeyDown(45) Then MoveEntity cam, 0, (KeyDown(44)-KeyDown(45))*1, 0

If loaded_song And EM0 <> 0 Then update_particle(EM0)
If loaded_song And EM1 <> 0 Then update_particle(EM1)
If loaded_song And EM2 <> 0 Then update_particle(EM2)
If loaded_song And EM3 <> 0 Then update_particle(EM3)
If loaded_song And EM4 <> 0 Then update_particle(EM4)
If loaded_song And EM5 <> 0 Then update_particle(EM5)
If loaded_song And EM6 <> 0 Then update_particle(EM6)
If loaded_song And EM7 <> 0 Then update_particle(EM7)
If loaded_song And EM8 <> 0 Then update_particle(EM0)
If loaded_song And EM9 <> 0 Then update_particle(EM9)
If loaded_song And EM10 <> 0 Then update_particle(EM10)

		event = WB3D_WaitEvent()
	Select event

		Case $1001 ; menu selection
			
			menuID = WB3D_EventData()
			Select menuID
				
;				Case 44
;					WB3D_Notify "","here",0
					
				Case 1 ; open
					; file extensions
					; first the description then the .extension
					; open filerequester and select song to play
					
ext$ = "*.mp3"+Chr$(0)+"*.mp3"+Chr$(0)+"*.mid"+Chr$(0)+"*.mid"+Chr$(0)+"*.wav"+Chr$(0)+"*.wav"+Chr$(0)
file1$ = WB3D_OpenFileRequest("..","..",ext$,"") : file_loaded = 1
playlist(0) = file1$
process_playlist()
											
				If FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav"
				test = 1
								
				EndIf
				
				If test
												
				If FileExtension(playlist$(0)) = ".mp3" Then extension$ = "mp3"
				If FileExtension(playlist$(0)) = ".mid" Then extension$ = ".mid"
				If FileExtension(playlist$(0)) = ".wav" Then extension$ = ".wav"
				If FileExtension(playlist$(0)) = ".mp3" Or FileExtension(playlist$(0)) = ".mid" Or FileExtension(playlist$(0)) = ".wav" Then Check_Particle(extension$)
				
				EndIf
					
				Case 2 ; quit
					
					WB3D_EndGUI()
					ClearWorld()
					
					End
				
;				Case 5,6,7 ; test radio check menu items 5,6,7
;					WB3D_RadiocheckMenu editmenu_window_1,5,7,menuID

				Case 3
				WB3D_Notify "Menu",copyright$,0

				Case 15 
					
					
					selectedColor = WB3D_RequestColor(100,100,105)
					If selectedColor <> 0 Then
						red = WB3D_RequestedRED()
						green = WB3D_RequestedGREEN()
						blue = WB3D_RequestedBLUE()
					EndIf
					WB3D_Notify "colors","red "+red+" green "+green+" blue "+blue,0

				Case 16
					newdir$ = WB3D_RequestDir("Select NEW Folder",newdir$)
					WB3D_Notify "folder selected","You Selected: "+newdir$,0
				
				Case 17
					font = WB3D_OpenFontRequest()
					WB3D_Notify "font selected","Selected font pointer: "+font,0
					WB3D_Usefont button,font
					
				Case 6000
					;Notify "context menu","6000",0
					WB3D_ShowGadget RuntimeWindow_hWnd
					WB3D_ShowGadget window
					
				Case 6001
					;Notify "context menu","6001",0
					WB3D_HideGadget RuntimeWindow_hWnd
					WB3D_HideGadget window
				Case 6002
				WB3D_Notify "",copyright$,0
					
				Case 5000
					WB3D_Notify "context menu","5000",0
					
				Case 5001
					WB3D_Notify "context menu","5001",0
							
			End Select
			
					Case WB3D_EVENT_DRAGDROP
										
			Select WB3D_EventSource()	

				Case RuntimeWindow_hWnd
				
					For do_files = 0 To WB3D_CountDroppedFiles()
		                file1$ = WB3D_DroppedFileName(do_files)
						playlist(do_files) = file1$
					Next
					
						process_playlist()
					
					If playlist$(0) <> "" Then
					test = 1
					
					EndIf
										
				If FileExtension(playlist$(0)) = ".mp3" Then extension$ = "mp3"
				If FileExtension(playlist$(0)) = ".mid" Then extension$ = "mid"
				If FileExtension(playlist$(0)) = ".wav" Then extension$ = "wav"
				If FileExtension(playlist$(0)) = ".mp3" Or FileExtension(playlist$(0)) = ".mid" Or FileExtension(playlist$(0)) = ".wav" Then Check_Particle(extension$)
									
			End Select		
			
		Case $208	; mouse wheel
				flagkey = WB3D_EventFlagKey()
				wheeldata = WB3D_EventData()
				cursx = WB3D_EventX()
				cursy = WB3D_EventY()
						
		Case WB3D_EVENT_GADGET	; gadget event
			id = WB3D_EventSource()
			Select id
;				
				Case floatbutton
;					ret_notify_code = WB3D_Notify("Testing......","WB3D_Notify Test",MB_CANCELTRYCONTINUE Or MB_ICONEXCLAMATION)
;					Select ret_notify_code
;						Case IDCANCEL
;							WB3D_Notify "You Selected","Cancel button was selected",0
;								
;						Case IDRETRY
;						 	WB3D_Notify "You Selected","Retry button was selected",0
;						
;						Case IDCONTINUE
;						 	WB3D_Notify "You selected","Continue button selected",0
;						
;					End Select
					
				Case trackbar_red
					track_red_pos = WB3D_GetTrackBarPos(trackbar_red)

				Case trackbar_green
					track_green_pos = WB3D_GetTrackBarPos(trackbar_green)

				Case trackbar_blue
					track_blue_pos = WB3D_GetTrackBarPos(trackbar_blue)
						
				Case spacerock
				sa = 1
				sa_type = EM0
				WB3D_Notify "","You have chosen the space rock particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case rocks
				sa = 1
				sa_type = EM1
				WB3D_Notify "","You have chosen the rock particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case explosion1
				sa = 1
				sa_type = EM2
				WB3D_Notify "","You have chosen the explosion particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)				
				Case explosion2
				sa = 1
				sa_type = EM3
				WB3D_Notify "","You have chosen the advanced explosion particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case smoke
				sa = 1
				sa_type = EM4
				WB3D_Notify "","You have chosen the smoke particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case torch
				sa = 1
				sa_type = EM5
				WB3D_Notify "","You have chosen the torch particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case sparks
				sa = 1
				sa_type = EM6
				WB3D_Notify "","You have chosen the sparks particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case flamethrower
				sa = 1
				sa_type = EM7
				WB3D_Notify "","You have chosen the flame thrower particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				Case waterfall
				sa = 1
				sa_type = EM8
				WB3D_Notify "","You have chosen the waterfall particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)				
				Case waterfountain
				sa = 1
				sa_type = EM9
				WB3D_Notify "","You have chosen the water fountain particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
				load_scene("waterfountain")
				
				Case smokeflares
				sa = 1
				sa_type = EM10
				WB3D_Notify "","You have chosen the smoke flare particle.",0
				WB3D_Notify "","Now load a song.",0
				api_SetFocus(RuntimehWnd)
										
				Case toggle1 
					WB3D_Notify "","Toggle Button State "+WB3D_ButtonState(toggle1),0

				Case toggle2 
					WB3D_Notify "","Toggle Button State "+WB3D_ButtonState(toggle2),0
					
				Case button_tab0
					splash_window = WB3D_CreateWindow("spash window",400,140,320,250,0,0)
					panel_splash = WB3D_CreatePanel(20,20,400,200,splash_window,0)
					WB3D_AddPanelImage panel_splash,"SPLASH.bmp"

				Case wire
				enable=1-enable

				WireFrame enable
				WB3D_Notify "",enable,0

				Case button_tab2
					WB3D_Notify "button_tab2","button_tab2",0

				Case button_tab3
					WB3D_Notify "button_tab3","button_tab3",0
					
				Case toolbar
					WB3D_Notify "toolbar","toolbar: "+WB3D_EventData(),0

				Case toolbar2
					WB3D_Notify "toolbar2","toolbar2: "+WB3D_EventData(),0
					
				Case listview
					
					If WB3D_EventEdited() = 0 Then

						selectedcolumn = WB3D_EventData()
						If(selectedcolumn = -1) Then
							oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),WB3D_SelectedListViewItem(listview),22,0)
							WB3D_Notify "listview","listview item selected "+WB3D_SelectedListViewItem(listview),0
						Else
							WB3D_Notify "listview","listview column clicked "+selectedcolumn,0
						EndIf
					
					EndIf
																
				Case button
					
					
				Case edit
					 
				Case combo1
					selected = WB3D_SelectedGadgetItem(combo1)
					
					If selected <> -1 Then
						WB3D_Notify "combo Selected","combo Selected "+selected,0
					
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),-1	; -1 use same icon
							WB3D_SelectGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex()
						EndIf
					EndIf

				Case combo2
					selected = WB3D_SelectedGadgetItem(combo2)
					
					If selected <> -1 Then
						WB3D_Notify "combo Selected","combo Selected "+selected,0
					
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),-1	; -1 use same icon
							WB3D_SelectGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex()
						EndIf
					EndIf
					
				Case listbox
								
										
					If WB3D_EventEdited() = 0 Then
												
						; wb3d_eventdata returns -1 if the items label was clicked, or the index of
						; the items whos checkbox has been selected
						checkbox_selected = WB3D_EventData()
					
						; has the listbox checkbox generated the event?
						If checkbox_selected = -1 Then
							selected = WB3D_SelectedGadgetItem(listbox)
							oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),selected,22,0)
							WB3D_Notify "listbox Selected","listbox Selected "+selected,0
						Else
							selected = checkbox_selected
							WB3D_Notify "listbox Selected","listbox Selected "+selected+Chr(13)+"Checkbox Selected "+WB3D_ListCheckState(listbox,selected),0
						EndIf
								
					Else
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyGadgetItem WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel(),0
						EndIf
					EndIf
					

				Case button2
					
					WB3D_ShowGadget window_floating
										
										
				Case tabber
					selectedtab = WB3D_EventData()
					
					Select selectedtab
					
						Case 0
							WB3D_ShowGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel2
							WB3D_HideGadget panel3
						
						Case 1
							WB3D_ShowGadget panel1
							WB3D_HideGadget panel0
							WB3D_HideGadget panel2
							WB3D_HideGadget panel3
						
						Case 2
							WB3D_ShowGadget panel2
							WB3D_HideGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel3
						
						Case 3
							WB3D_ShowGadget panel3
							WB3D_HideGadget panel0
							WB3D_HideGadget panel1
							WB3D_HideGadget panel2
					
					Default
						WB3D_Notify "Tab Selected","Tab Selected "+selectedtab,0
	
						WB3D_HideGadget panel0
						WB3D_HideGadget panel1
						WB3D_HideGadget panel2
						WB3D_HideGadget panel3		
					End Select
					
					oldicon = WB3D_SetGadgetItemIcon(WB3D_EventSource(),selectedtab,22,0)
					
				Case treeview
					
					selectednode = WB3D_EventData()
					
					If selectednode = subnode1 
						WB3D_Notify "subnode1 ","subnode1 selected",0
					Else
						WB3D_Notify "selected node","Selected Node "+selectednode ,0
					EndIf
					
					If WB3D_GetEditedLabelIndex() Then
						If WB3D_GetEditedLabel() <> "" Then
							WB3D_ModifyTreeViewNode WB3D_EventSource(),WB3D_GetEditedLabelIndex(),WB3D_GetEditedLabel()
						EndIf
					EndIf
					
					WB3D_SetGadgetItemIcon(WB3D_EventSource(),selectednode,22,1)

 
				Case name_field
					;
					WB3D_SetGadgetText window,WB3D_GetGadgetText(name_field)
					;WB3D_Notify "",Len(WB3D_GetGadgetText(name_field)),0
									
				
			End Select
			
		Case WB3D_EVENT_WINDOW_CLOSE   ; close window
			
			closewin = WB3D_EventSource()
			If closewin = window_floating Then
				WB3D_HideGadget window_floating
			EndIf
						
		Case $802	; window size
			; for move,moving,size,sizing see 
			; WB3D_EventData() - edge being moved Or sized
			; WB3D_EventX()	- new size, position
			; WB3D_EventY()	- new size position
			
			; update window toolbars
			;WB3D_UpdateToolbar toolbar
			;WB3D_UpdateToolbar toolbar2
			
			
			; update the status bars
			;WB3D_UpdateStatusbar status
			;WB3D_UpdateStatusbar rstatus
			

		Case $805	; window sizing	
WB3D_DisableGadget mainmenu
api_MoveWindow% (Runtimewindow_hWnd, 0, 0, GraphicsWidth(), GraphicsHeight(), wm_paint)
api_MoveWindow% (mainmenu, 0, 0, GraphicsWidth()/4+41, GraphicsHeight()-71, wm_paint)
			
		Case $806	; window moving
WB3D_DisableGadget mainmenu
api_MoveWindow% (Runtimewindow_hWnd, 0, 0, GraphicsWidth(), GraphicsHeight(), wm_paint)
api_MoveWindow% (mainmenu, 0, 0, GraphicsWidth()/4+41, GraphicsHeight()-71, wm_paint)
		
		Case $807	; window move
WB3D_DisableGadget mainmenu
api_MoveWindow% (Runtimewindow_hWnd, 0, 0, GraphicsWidth(), GraphicsHeight(), wm_paint)
api_MoveWindow% (mainmenu, 0, 0, GraphicsWidth()/4+41, GraphicsHeight()-71, wm_paint)
		
		Case $200	; mousemove
			gadget_mouse_over = WB3D_EventSource()
			gadget_mouse_overX = WB3D_EventX()
			gadget_mouse_overY = WB3D_EventY()
							
		Case $101	; key down
			
			gadget_keydown = WB3D_EventSource()
			key_code = WB3D_EventData()	
			
			Select gadget_keydown
				
				Case name_field
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Gadget Contents",WB3D_GetGadgetText(name_field),0
					EndIf
				
				Case edit
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Gadget Contents",WB3D_TextAreaText(edit),0
					EndIf

				Case listbox
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Selected Gadget Item","You Selected Item: "+WB3D_SelectedGadgetItem(listbox)+Chr(13)+"Item Text: "+WB3D_GadgetItemText(listbox,WB3D_SelectedGadgetItem(listbox)),0
					EndIf
				
				Case spinner_label
					
					If key_code = WB3D_KEY_ENTER Then
						WB3D_Notify "Spinner ","Spinner Value "+WB3D_GetSpinnerPos(spinner),0
						;WB3D_SetSpinnerPos(spinner,WB3D_GetGadgetText(spinner_label))
					EndIf
					
			End Select
		
		Case $502	; gadgets context menus
				gadget = WB3D_EventSource()
				
				;;Notify Hex(window),Hex(gadget),0
								
				contextmenu_popup = 0
				Select gadget
						
					Case RuntimeWindow_hWnd	
						contextmenu_popup = contextmenu_RuntimeWindow_hWnd
					
					Case button,button3
						contextmenu_popup = contextmenu_button_hWnd
					
					Case listview,listbox
						contextmenu_popup = contextmenu_list_hWnd
					
					Case edit 
						contextmenu_popup = contextmenu_edit_hWnd
								
				End Select
				WB3D_TrackContextMenu(gadget,contextmenu_popup,WB3D_EventX(),WB3D_EventY())
			
		Case $503	; system tray
			
			eventtype = WB3D_EventData()
			
			Select eventtype
				
				Case 1
					WB3D_Notify "system tray","system tray left mouse double click",0

				Case 2,3
					WB3D_TrackContextMenu(WB3D_EventSource(),contextmenu,WB3D_EventX(),WB3D_EventY())
			End Select
		
		
;		Case $504	; drag and drop files
;			gadget = WB3D_EventSource()
			
			
;			For do_files = 0 To WB3D_CountDroppedFiles()
;				WB3D_Notify "",""+WB3D_DroppedFileName(do_files),0
;			Next
		
		Case $200
												
	Default
	
	WB3D_EnableGadget mainmenu
		
		; reset wheel move flag 	
		wheeldata = 0
		
	End Select
		
		If em0 > 0 Or em1 > 0 Or em2 > 0 Or em3 > 0 Or em4 > 0 Or em5 > 0 Or em6 > 0 Or em7 > 0 Or em8 > 0 Or em9 > 0 Or em10 > 0 Or em11 > 0 Then 

        If test Then UpdateParticles()

		EndIf
		
		If em0 Or em1 Or em2 Or em3 Or em4 Or em5 Or em6 Or em7 Or em8 Or em9 Or em10 Or em11
		 If em0 = 0 Or em1 = 0  Or em2 = 0 Or em3 = 0 Or em4 = 0 Or em5 = 0 Or em6 = 0 Or em7 = 0 Or em8 = 0 Or em9 = 0 Or em10 = 0 Or em11 = 0
		
		If em0 = 0 Or em1 = 0 Or em2 = 0 Or em3 = 0 Or em4 = 0 Or em5 = 0 Or em6 = 0 Or em7 = 0 Or em8 = 0 Or em9 = 0 Or em10 = 0 Then FreeParticleSystem()
		
    		EndIf
		
		EndIf
		
If fountain <> 0 Then particle_isOn = 1 Else particle_isOn = 0

If particle_isOn = 1 Then WaterAnimation(Water,1.5,30)
			
	UpdateWorld
	RenderWorld

update_banner(image)	

	; generate an internal blitz event
	Flip


	; process the playlist	
	
Wend

WB3D_EndGUI()
ClearWorld()
End

Function Songlist()

If loaded_song

song_list1$ = playlist$(0)

Else

song_list1$ = "No songs loaded yet."

EndIf

Return song_list1

End Function

;---------------------------------------------
;FUNCTION: WATER ANIMATION
;---------------------------------------------
Function WaterAnimation (Obj,speed#,height#)
	Local Surf%,i%,x#,y#,z#
	
	Surf = GetSurface(Obj,1)
	For i = 0 To CountVertices(Surf)-1
		x = VertexX(Surf,i)
		z = VertexZ(Surf,i)
		freq# = MilliSecs()/speed;/1 /2 / 10    ; WAVE SPEED
		y = Sin(freq + x*1.2 + z*1.6) * height  ; WAVE HEIGHT
		VertexCoords Surf,i,x,y,z
	Next

	UpdateNormals Obj
End Function

Function load_scene(scene$)

If scene$ = "waterfountain"

fountain = LoadAnimMesh("Media\fountain.b3d")

PositionEntity fountain, 0, 1, 0

Water% = FindChild (fountain, "Water")

If EM9 <> 0 Then PositionEntity EM9, EntityX(EM9), 20, EntityZ(EM9)

EndIf

End Function

Function load_banner()

image = LoadImage("Media\banner.png")

Return image

End Function

Function update_banner(image)

DrawImage image, GraphicsWidth()/2-ImageWidth(image)/4, GraphicsHeight()-ImageHeight(image)-ImageHeight(image)/2	

End Function

Function Check_Particle(extension$)

If sa = 1 And sa_type = EM0 Then Start_Particle(extension$, EM0)
If sa = 1 And sa_type = EM1 Then Start_Particle(extension$, EM1)
If sa = 1 And sa_type = EM2 Then Start_Particle(extension$, EM2)
If sa = 1 And sa_type = EM3 Then Start_Particle(extension$, EM3)
If sa = 1 And sa_type = EM4 Then Start_Particle(extension$, EM4)
If sa = 1 And sa_type = EM5 Then Start_Particle(extension$, EM5)
If sa = 1 And sa_type = EM6 Then Start_Particle(extension$, EM6)
If sa = 1 And sa_type = EM7 Then Start_Particle(extension$, EM7)
If sa = 1 And sa_type = EM8 Then Start_Particle(extension$, EM8)
If sa = 1 And sa_type = EM9 Then Start_Particle(extension$, EM9)
If sa = 1 And sa_type = EM10 Then Start_Particle(extension$, EM10)

End Function

Function Particle_IsPlaying(EM)

If Emitter_IsActive(EM) = True Then particle_playing = 1

Return particle_playing

End Function

Function Init_Particle()

p1=InitParticles(cam,"Media\particles.png", 3)
p2=SetParticleUpdateCycle(2)

End Function

Function Create_Particle()

EM0 = CreateEmitter_Test()
EM1 = CreateEmitter_Rocks()
EM2 = CreateEmitter_Explosion1()
EM3 = CreateEmitter_Explosion2()
EM4 = CreateEmitter_Smoke()
EM5 = CreateEmitter_Torch()
EM6 = CreateEmitter_Sparks()
EM7 = CreateEmitter_FlameThrower()
EM8 = CreateEmitter_Waterfall()
EM9 = CreateEmitter_WaterFontain()
EM10 = CreateEmitter_SmokeFlares()

End Function

Function Start_Particle(fileext$, EM)

For id = 0 To 28

play_timea = play_time(id)

Next

If fileext$ = "mp3"

If play_timea < mcimp3length(loaded_song) And Emitter_IsActive(EM) = False Then isactive = 1

Else

If fileext$ = "mid"

If play_timea < mcimidilength(loaded_song) And Emitter_IsActive(EM) = False Then isactive = 1

Else

If fileext$ = "wav"

If play_timea < mciwavlength(loaded_song) And Emitter_IsActive(EM) = False Then isactive = 1

EndIf

EndIf

EndIf

Return EM

End Function

Function CreateEmitter_Test% ()
	Local EM%,P1%

 	EM = CreateEmitter()

	; SIMPLE TEST PARTICLES
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,8
	ParticleType_SetSpeed    		  P1,7
	ParticleType_SetSize     		  P1,.25
	ParticleType_SetAlpha    		  P1,1
	ParticleType_SetWeight   		  P1,.5
	ParticleType_SetRotation 		  P1,0,0
	ParticleType_SetColor    		  P1,240,240,240,40,-50,-50,-50
	ParticleType_SetEmissionAngle P1,0,90
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,4000
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetAddedBlend    P1,0
	
	emitter_slot(0) = Emitter_AddParticleType(EM, P1, 0,play_time(0),985)

	Return EM
End Function


Function CreateEmitter_WaterFontain% ()
	Local EM%,P1%,P2%

 	EM = CreateEmitter()

	; MIST
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,2
	ParticleType_SetSpeed    		  P1,15,2
	ParticleType_SetSize     		  P1,.75,.75,3,3
	ParticleType_SetAlpha    		  P1,1,.5,-1
	ParticleType_SetWeight   		  P1,3,.5
	ParticleType_SetRotation 		  P1,2,0
	ParticleType_SetColor    		  P1,225,225,255,40,-125,-125,-100
	ParticleType_SetEmissionAngle P1,0,15
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,3000
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetAddedBlend    P1,0
	; BUBBLES
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,3
	ParticleType_SetSpeed    		  P2,5,2
	ParticleType_SetSize     		  P2,.7,.5
	ParticleType_SetAlpha    		  P2,1,.5,-1
	ParticleType_SetWeight   		  P2,3,.5
	ParticleType_SetRotation 		  P2,1,0
	ParticleType_SetColor    		  P2,210,210,255,20,-100,-100,-75
	ParticleType_SetEmissionAngle P2,0,25
	ParticleType_SetStartOffsets  P2,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,0
	
	Emitter_SetSound EM,soundPath$+"water.mp3",1
	emitter_slot(1) = Emitter_AddParticleType(EM, P1, 0,play_time(1),100)
	emitter_slot(2) = Emitter_AddParticleType(EM, P2, 0,play_time(2),50)

	Return EM
End Function


Function CreateEmitter_Waterfall% ()
	Local EM%,P1%,P2%,P3%
	
 	EM = CreateEmitter()

	; MIST
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,2
	ParticleType_SetSpeed    		  P1,4,2
	ParticleType_SetSize     		  P1,.75,.75,4,4
	ParticleType_SetAlpha    		  P1,1,.5,-1
	ParticleType_SetWeight   		  P1,3,2
	ParticleType_SetRotation 		  P1,0,90
	ParticleType_SetColor    		  P1,225,225,250,40,-125,-125,-100
	ParticleType_SetEmissionAngle P1,0,15
	ParticleType_SetStartOffsets  P1,-3,6,0,-1,0,0
	ParticleType_SetLifeTime 		  P1,3000
	ParticleType_SetBounce        P1,-12,0,0
	ParticleType_SetAddedBlend    P1,0
	; CLOUDS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,9
	ParticleType_SetSpeed    		  P2,2,2
	ParticleType_SetSize     		  P2,.75,.75,5,3
	ParticleType_SetAlpha    		  P2,.5,.5,-1.5
	ParticleType_SetWeight   		  P2,0,2
	ParticleType_SetRotation 		  P2,1,45
	ParticleType_SetColor    		  P2,225,225,250,40,-100,-100,-75
	ParticleType_SetEmissionAngle P2,0,15
	ParticleType_SetStartOffsets  P2,-3,6,-10.5,0,0,0
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,1
	; BUBBLES
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,3
	ParticleType_SetSpeed    		  P3,2.5,2
	ParticleType_SetSize     		  P3,.7,.5
	ParticleType_SetAlpha    		  P3,1,.5,-1
	ParticleType_SetWeight   		  P3,.5,.5
	ParticleType_SetRotation 		  P3,1,45
	ParticleType_SetColor    		  P3,210,210,250,20,-100,-100,-75
	ParticleType_SetEmissionAngle P3,0,15
	ParticleType_SetStartOffsets  P3,-3,6,1,0,0,0
	ParticleType_SetLifeTime 		  P3,1000
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetAddedBlend    P3,0
			
	   Emitter_SetSound EM,soundpath$+"water.mp3",1
	
	emitter_slot(3) = Emitter_AddParticleType(EM, P1, 0,play_time(3),115)
	emitter_slot(4) = Emitter_AddParticleType(EM, P2, 1000,play_time(4)-1000,40)
	emitter_slot(5) = Emitter_AddParticleType(EM, P3, 0,play_time(5),50)

	Return EM
End Function


Function CreateEmitter_FlameThrower% ()
	Local EM%,P1%,P2%

 	EM = CreateEmitter()
	; SMOKE
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,15,5
	ParticleType_SetSize     		  P1,2,1,5,6
	ParticleType_SetAlpha    		  P1,.7,.4,-1
	ParticleType_SetWeight   		  P1,-7,.5
	ParticleType_SetRotation 		  P1,1,90
	ParticleType_SetColor    		  P1,155,155,180,60,-100,-100,-105
	ParticleType_SetEmissionAngle P1,0,30
	ParticleType_SetLifeTime 		  P1,1500
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetAddedBlend    P1,0
	; FLAME
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,5
	ParticleType_SetSpeed    		  P2,24,5
	ParticleType_SetSize     		  P2,1,1,4,4
	ParticleType_SetAlpha    		  P2,1,.5,-1
	ParticleType_SetWeight   		  P2,-4,2
	ParticleType_SetRotation 		  P2,1,45
	ParticleType_SetColor    		  P2,250,250,200,40,-150,-300,-400
	ParticleType_SetEmissionAngle P2,0,15
	ParticleType_SetStartOffsets  P2,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,1
  	; SPARKS
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,1
	ParticleType_SetSpeed    		  P3,15,5
	ParticleType_SetSize     		  P3,.2,.2,-1
	ParticleType_SetAlpha    		  P3,1,.5,-1
	ParticleType_SetWeight   		  P3,3,1
	ParticleType_SetRotation 		  P3,2,90
	ParticleType_SetColor    		  P3,250,100,0,50,-100,-100,0
	ParticleType_SetEmissionAngle P3,0,360
	ParticleType_SetStartOffsets  P3,0,0,-.5,0,0,0
	ParticleType_SetLifeTime 		  P3,1000
	ParticleType_SetBounce        P3,0,.7,10
	ParticleType_SetAddedBlend    P3,1

	Emitter_SetSound EM,soundPath$+"flamethrower.mp3",1
	emitter_slot(6) = Emitter_AddParticleType(EM, P1, 0,play_time(5),15)
	emitter_slot(7) = Emitter_AddParticleType(EM, P2, 1000,play_time(6)-1000,35)
	emitter_slot(8) = Emitter_AddParticleType(EM, P3, 0,play_time(7),150)

	Return EM
End Function


Function CreateEmitter_Sparks% ()
	Local EM%,P1%,P2%,P3%

 	EM = CreateEmitter()
	; SMOKE
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,5,2
	ParticleType_SetSize     		  P1,1,1,2,3
	ParticleType_SetAlpha    		  P1,.4,.4,-1
	ParticleType_SetWeight   		  P1,-1,.5
	ParticleType_SetRotation 		  P1,1,90
	ParticleType_SetColor    		  P1,155,155,180,60,-100,-100,-105
	ParticleType_SetEmissionAngle P1,0,30
	ParticleType_SetLifeTime 		  P1,1500
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetAddedBlend    P1,0
	; SPARKS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,1
	ParticleType_SetSpeed    		  P2,8,5
	ParticleType_SetSize     		  P2,.15,.5,-1
	ParticleType_SetAlpha    		  P2,1,.5,-.5
	ParticleType_SetWeight   		  P2,3,2
	ParticleType_SetRotation 		  P2,2,90
	ParticleType_SetColor    		  P2,200,200,250,50,-100,-100,0
	ParticleType_SetEmissionAngle P2,0,360
	ParticleType_SetStartOffsets  P2,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P2,2000
	ParticleType_SetBounce        P2,-8,.4,3
	ParticleType_SetAddedBlend    P2,1
	; FLAME
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,7
	ParticleType_SetSpeed    		  P3,.1,0
	ParticleType_SetSize     		  P3,.5,.5,-.25
	ParticleType_SetAlpha    		  P3,1,.5,-.5
	ParticleType_SetWeight   		  P3,0,2
	ParticleType_SetRotation 		  P3,1,0
	ParticleType_SetColor    		  P3,200,200,250,40,-100,-100,0
	ParticleType_SetEmissionAngle P3,0,360
	ParticleType_SetStartOffsets  P3,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P3,500
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetPulsation     P3,3
	ParticleType_SetAddedBlend    P3,1

Emitter_SetSound EM,soundPath$+"lightning.mp3",1
	emitter_slot(9) = Emitter_AddParticleType(EM, P1, 0,play_time(8),15)
	emitter_slot(10) = Emitter_AddParticleType(EM, P2, 0,play_time(9),450)
	emitter_slot(11) = Emitter_AddParticleType(EM, P3, 0,play_time(10),10)

	Return EM
End Function

Function CreateEmitter_Torch% ()
	Local EM%,P1%,P2%

 	EM = CreateEmitter()
	; SMOKE
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,5,2
	ParticleType_SetSize     		  P1,1,1,2,3
	ParticleType_SetAlpha    		  P1,.7,.5,-1
	ParticleType_SetWeight   		  P1,-1,.5
	ParticleType_SetRotation 		  P1,1,90
	ParticleType_SetColor    		  P1,155,155,170,60,-100,-100,-105
	ParticleType_SetEmissionAngle P1,0,30
	ParticleType_SetLifeTime 		  P1,1500
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetAddedBlend    P1,0
	; FLAME
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,9
	ParticleType_SetSpeed    		  P2,5,2
	ParticleType_SetSize     		  P2,1,1,2,3
	ParticleType_SetAlpha    		  P2,.7,.5,-2
	ParticleType_SetWeight   		  P2,-2,.5
	ParticleType_SetRotation 		  P2,0,90
	ParticleType_SetColor    		  P2,250,150,50,50,-50,-50,-55
	ParticleType_SetEmissionAngle P2,0,75
	ParticleType_SetLifeTime 		  P2,1500
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetAddedBlend    P2,1
	; SPARKS
	P3 = CreateParticleType()
	ParticleType_SetImage    		  P3,1
	ParticleType_SetSpeed    		  P3,8,5
	ParticleType_SetSize     		  P3,.2,.2,-.5
	ParticleType_SetAlpha    		  P3,1,.5,-1
	ParticleType_SetWeight   		  P3,3,1
	ParticleType_SetRotation 		  P3,2,90
	ParticleType_SetColor    		  P3,250,100,0,50,-100,-100,0
	ParticleType_SetEmissionAngle P3,0,360
	ParticleType_SetStartOffsets  P3,0,0,-.5,0,0,0
	ParticleType_SetLifeTime 		  P3,1000
	ParticleType_SetBounce        P3,0,.7,10
	ParticleType_SetAddedBlend    P3,1

	Emitter_SetSound EM,soundPath$+"flames.mp3",1
	emitter_slot(12) = Emitter_AddParticleType(EM, P1, 0,play_time(11),0)
	emitter_slot(13) = Emitter_AddParticleType(EM, P2, 0,play_time(12),50)
	emitter_slot(14) = Emitter_AddParticleType(EM, P3, 0,play_time(13),45)

	Return EM
End Function


Function CreateEmitter_Smoke% ()
	Local EM%,P1%

 	EM = CreateEmitter()
	; SMOKE
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,5,2
	ParticleType_SetSize     		  P1,1,1,2,3
	ParticleType_SetAlpha    		  P1,.7,.5,-.8
	ParticleType_SetWeight   		  P1,-1,.5
	ParticleType_SetRotation 		  P1,1,90
	ParticleType_SetColor    		  P1,125,125,140,60,-50,-50,-55
	ParticleType_SetEmissionAngle P1,0,75
	ParticleType_SetLifeTime 		  P1,1500
	ParticleType_SetBounce        P1,-5,1,10
	ParticleType_SetAddedBlend    P1,0
	
	Emitter_SetSound EM,soundPath$+"smoke.mp3",1
	emitter_slot(15) = Emitter_AddParticleType(EM, P1, 0,play_time(14),75)

	Return EM
End Function


Function CreateEmitter_Rocks% ()
	Local EM%,P1%,P2%

 	EM = CreateEmitter()
	; ROCKS
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,8
	ParticleType_SetSpeed    		  P1,20,5
	ParticleType_SetSize     		  P1,.6,.5
	ParticleType_SetAlpha    		  P1,1,0,0
	ParticleType_SetWeight   		  P1,8,5
	ParticleType_SetRotation 		  P1,1,400
	ParticleType_SetColor    		  P1,240,240,240,40,0,0,0
	ParticleType_SetEmissionAngle P1,3,130
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,3000
	ParticleType_SetBounce        P1,-7,.5,16
	ParticleType_SetPulsation     P1,0
	ParticleType_SetAddedBlend    P1,0
	; SMOKE
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,5
	ParticleType_SetSpeed    		  P2,4,2
	ParticleType_SetSize     		  P2,1,1,5
	ParticleType_SetAlpha    		  P2,.5,.3,-1
	ParticleType_SetWeight   		  P2,-.5,.1
	ParticleType_SetRotation 		  P2,1,45
	ParticleType_SetColor    		  P2,125,125,130,20,-15,-15,-25
	ParticleType_SetEmissionAngle P2,3,180
	ParticleType_SetStartOffsets  P2,-3,6,-2,8,-3,6
	ParticleType_SetLifeTime 		  P2,1000
	ParticleType_SetBounce        P2,-5,1,10
	ParticleType_SetAddedBlend    P2,0

	Emitter_SetSound EM,soundPath$+"bang.mp3",0
	emitter_slot(16) = Emitter_AddParticleType(EM, P1, 0,play_time(15),400)
	emitter_slot(17) = Emitter_AddParticleType(EM, P2, 0,play_time(16),200)

	Return EM
End Function


Function CreateEmitter_SmokeFlares% ()
	Local EM%,P1%,P2%

 	EM = CreateEmitter()
	; SMOKE TRAIL
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,9
	ParticleType_SetSpeed    		  P1,4,2
	ParticleType_SetSize     		  P1,.5,.5,3,1
	ParticleType_SetAlpha    		  P1,.25,.25,-.45
	ParticleType_SetWeight   		  P1,-.5,.1
	ParticleType_SetRotation 		  P1,1,45
	ParticleType_SetColor    		  P1,125,125,135,20,-15,-15,-25
	ParticleType_SetEmissionAngle P1,3,180
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,3000
	;ParticleType_SetBounce        P1,-5,1,10
	ParticleType_SetAddedBlend    P1,0
	; ROCKS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,7
	ParticleType_SetSpeed    		  P2,20,5
	ParticleType_SetSize     		  P2,.6,.5
	ParticleType_SetAlpha    		  P2,1,0,0
	ParticleType_SetWeight   		  P2,8,5
	ParticleType_SetRotation 		  P2,1,400
	ParticleType_SetColor    		  P2,200,180,160,40,0,-50,-50
	ParticleType_SetEmissionAngle P2,3,130
	ParticleType_SetStartOffsets  P2,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P2,3000
	ParticleType_SetBounce        P2,-7,.5,16
	ParticleType_SetPulsation     P2,0
	ParticleType_SetAddedBlend    P2,1
	ParticleType_SetTrail         P2,P1,0,3000,45

	Emitter_SetSound EM,soundPath$+"bang.mp3",0
	emitter_slot(18) = Emitter_AddParticleType(EM, P2, 0,play_time(17),400)

	Return EM
End Function


; EXPLOSION
Function CreateEmitter_Explosion1% ()
	Local EM%,P1%,P2%,P3%,P4%,P5%
	
	EM = CreateEmitter()
	; SHORT FLASH
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,0,0
	ParticleType_SetSize     		  P1,2,0,-2
	ParticleType_SetAlpha    		  P1,1,0,0
	ParticleType_SetWeight   		  P1,0,0
	ParticleType_SetRotation 		  P1,1,0
	ParticleType_SetColor    		  P1,255,255,200,0,-200,-200,-200
	ParticleType_SetEmissionAngle P1,0,1
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,500
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetPulsation     P1,4
	ParticleType_SetAddedBlend    P1,1
	; RED CLOUDS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,5
	ParticleType_SetSpeed    		  P2,0,0
	ParticleType_SetSize     		  P2,1,.5,15,5
	ParticleType_SetAlpha    		  P2,1,.25,-.18
	ParticleType_SetWeight   		  P2,0,0
	ParticleType_SetRotation 		  P2,1,0
	ParticleType_SetColor    		  P2,255,246,149,0,-150,-200,-200
	ParticleType_SetEmissionAngle P2,0,360
	ParticleType_SetStartOffsets  P2,-3,6,-3,6,-3,6
	ParticleType_SetLifeTime 		  P2,2000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetPulsation     P2,0
	ParticleType_SetAddedBlend    P2,1
	; SMALL PARTICLES
	P3 = CreateParticleType()
  ParticleType_SetImage    		  P3,6
	ParticleType_SetSpeed    		  P3,10,1
	ParticleType_SetSize     		  P3,3,.5,-1
	ParticleType_SetAlpha    		  P3,1,.25,-.8
	ParticleType_SetWeight   		  P3,0,0
	ParticleType_SetRotation 		  P3,1,0
	ParticleType_SetColor    		  P3,255,246,149,0,0,0,0
	ParticleType_SetEmissionAngle P3,0,360
	ParticleType_SetStartOffsets  P3,-1,2,-1,2,-1,2
	ParticleType_SetLifeTime 		  P3,2000
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetPulsation     P3,0
	ParticleType_SetAddedBlend    P3,0
	; SMOKE
	P4 = CreateParticleType()
  ParticleType_SetImage    		  P4,5
	ParticleType_SetSpeed    		  P4,2,.5
	ParticleType_SetSize     		  P4,1,.5,15,4
	ParticleType_SetAlpha    		  P4,1,.25,-.15
	ParticleType_SetWeight   		  P4,0,0
	ParticleType_SetRotation 		  P4,1,0
	ParticleType_SetColor    		  P4,70,70,70,20,-30,-30,-30
	ParticleType_SetEmissionAngle P4,0,360
	ParticleType_SetStartOffsets  P4,-4,8,-4,8,-4,8
	ParticleType_SetLifeTime 		  P4,3000
	ParticleType_SetBounce        P4,0,0,0
	ParticleType_SetPulsation     P4,0
	ParticleType_SetAddedBlend    P4,1
	; SPARKS
	P5 = CreateParticleType()
	ParticleType_SetImage    		  P5,1
	ParticleType_SetSpeed    		  P5,15,5
	ParticleType_SetSize     		  P5,.5,.15,-.5
	ParticleType_SetAlpha    		  P5,1,.25,-.18
	ParticleType_SetWeight   		  P5,2,0
	ParticleType_SetRotation 		  P5,2,0
	ParticleType_SetColor    		  P5,255,246,149,20,-150,-200,-150
	ParticleType_SetEmissionAngle P5,3,360
	ParticleType_SetStartOffsets  P5,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P5,2000
	ParticleType_SetBounce        P5,0,0,0
	ParticleType_SetPulsation     P5,0
	ParticleType_SetAddedBlend    P5,1

	Emitter_SetSound EM,soundPath$+"explosion.mp3",0
	emitter_slot(19) = Emitter_AddParticleType(EM, P1, 0,play_time(18)-110,10)
	emitter_slot(20) = Emitter_AddParticleType(EM, P2, 100,play_time(19)-150,50)
	emitter_slot(21) = Emitter_AddParticleType(EM, P3, 150,play_time(20)-200,125)
	emitter_slot(22) = Emitter_AddParticleType(EM, P4, 250,play_time(21)-350,40)
	emitter_slot(23) = Emitter_AddParticleType(EM, P5, 100,play_time(22)-400,150)
	; RETURN EMITTER HANDLE
	Return EM	
End Function


; EXPLOSION 2
Function CreateEmitter_Explosion2% ()
	Local EM%,P1%,P2%,P3%,P4%,P5%,P6%
	
	EM = CreateEmitter()
	; SHORT FLASH
	P1 = CreateParticleType()
	ParticleType_SetImage    		  P1,5
	ParticleType_SetSpeed    		  P1,0,0
	ParticleType_SetSize     		  P1,2,0,-2
	ParticleType_SetAlpha    		  P1,1,0,0
	ParticleType_SetWeight   		  P1,0,0
	ParticleType_SetRotation 		  P1,1,0
	ParticleType_SetColor    		  P1,255,255,200,0,-200,-200,-200
	ParticleType_SetEmissionAngle P1,0,1
	ParticleType_SetStartOffsets  P1,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P1,500
	ParticleType_SetBounce        P1,0,0,0
	ParticleType_SetPulsation     P1,4
	ParticleType_SetAddedBlend    P1,1
	; RED CLOUDS
	P2 = CreateParticleType()
	ParticleType_SetImage    		  P2,5
	ParticleType_SetSpeed    		  P2,0,0
	ParticleType_SetSize     		  P2,1,.5,15,5
	ParticleType_SetAlpha    		  P2,1,.25,-.18
	ParticleType_SetWeight   		  P2,0,0
	ParticleType_SetRotation 		  P2,1,0
	ParticleType_SetColor    		  P2,255,246,149,0,-150,-200,-200
	ParticleType_SetEmissionAngle P2,0,360
	ParticleType_SetStartOffsets  P2,-3,6,-3,6,-3,6
	ParticleType_SetLifeTime 		  P2,2000
	ParticleType_SetBounce        P2,0,0,0
	ParticleType_SetPulsation     P2,0
	ParticleType_SetAddedBlend    P2,1
	; SPARKS
	P3 = CreateParticleType()
  ParticleType_SetImage    		  P3,1
	ParticleType_SetSpeed    		  P3,20,5
	ParticleType_SetSize     		  P3,.5,.5,-1
	ParticleType_SetAlpha    		  P3,1,.25,-.8
	ParticleType_SetWeight   		  P3,0,0
	ParticleType_SetRotation 		  P3,2,0
	ParticleType_SetColor    		  P3,255,246,149,50,-200,-300,-300
	ParticleType_SetEmissionAngle P3,0,360
	ParticleType_SetStartOffsets  P3,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P3,2000
	ParticleType_SetBounce        P3,0,0,0
	ParticleType_SetPulsation     P3,0
	ParticleType_SetAddedBlend    P3,1
	; SMOKE
	P4 = CreateParticleType()
  ParticleType_SetImage    		  P4,5
	ParticleType_SetSpeed    		  P4,2,.5
	ParticleType_SetSize     		  P4,1,.5,15,4
	ParticleType_SetAlpha    		  P4,1,.25,-.15
	ParticleType_SetWeight   		  P4,0,0
	ParticleType_SetRotation 		  P4,1,0
	ParticleType_SetColor    		  P4,70,70,70,20,-30,-30,-30
	ParticleType_SetEmissionAngle P4,0,360
	ParticleType_SetStartOffsets  P4,-4,8,-4,8,-4,8
	ParticleType_SetLifeTime 		  P4,3000
	ParticleType_SetBounce        P4,0,0,0
	ParticleType_SetPulsation     P4,0
	ParticleType_SetAddedBlend    P4,1
	; DEBRIS SMOKE TRAIL
	P5 = CreateParticleType()
	ParticleType_SetImage    		  P5,9
	ParticleType_SetSpeed    		  P5,4,2
	ParticleType_SetSize     		  P5,.5,.5,3,1
	ParticleType_SetAlpha    		  P5,.25,.25,-.45
	ParticleType_SetWeight   		  P5,0,.1
	ParticleType_SetRotation 		  P5,1,45
	ParticleType_SetColor    		  P5,125,125,135,20,-15,-15,-25
	ParticleType_SetEmissionAngle P5,3,180
	ParticleType_SetStartOffsets  P5,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P5,3000
	; DEBRIS
	P6 = CreateParticleType()
	ParticleType_SetImage    		  P6,7
	ParticleType_SetSpeed    		  P6,15,5
	ParticleType_SetSize     		  P6,1,.5,-1
	ParticleType_SetAlpha    		  P6,1,.25,-.15
	ParticleType_SetWeight   		  P6,1,0
	ParticleType_SetRotation 		  P6,0,0
	ParticleType_SetColor    		  P6,255,246,149,20,-150,-200,-150
	ParticleType_SetEmissionAngle P6,3,360
	ParticleType_SetStartOffsets  P6,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P6,2000
	ParticleType_SetBounce        P6,0,0,0
	ParticleType_SetPulsation     P6,0
	ParticleType_SetAddedBlend    P6,1
	ParticleType_SetTrail         P6,P5,0,1000,45
	; SPARKLES
	P7 = CreateParticleType()
	ParticleType_SetImage    		  P7,7
	ParticleType_SetSpeed    		  P7,1,.5
	ParticleType_SetRandomSpeed	  P7,.05,.05,.05
	ParticleType_SetSize     		  P7,.5,.5,-.5
	ParticleType_SetAlpha    		  P7,1,.25,-.15
	ParticleType_SetWeight   		  P7,1,0
	ParticleType_SetRotation 		  P7,0,0
	ParticleType_SetColor    		  P7,255,246,149,20,-150,-200,-150
	ParticleType_SetEmissionAngle P7,3,360
	ParticleType_SetStartOffsets  P7,0,0,0,0,0,0
	ParticleType_SetLifeTime 		  P7,2000
	ParticleType_SetBounce        P7,0,0,0
	ParticleType_SetPulsation     P7,0
	ParticleType_SetAddedBlend    P7,1

	Emitter_SetSound EM,soundPath$+"explosion.mp3",0
	emitter_slot(24) = Emitter_AddParticleType(EM, P1, 0,play_time(23)-110,10)
	emitter_slot(25) = Emitter_AddParticleType(EM, P2, 100,play_time(24)-150,50)
	emitter_slot(26) = Emitter_AddParticleType(EM, P3, 200,play_time(25)-250,150)
	emitter_slot(27) = Emitter_AddParticleType(EM, P4, 250,play_time(26)-350,40)
	emitter_slot(28) = Emitter_AddParticleType(EM, P6, 100,play_time(27)-300,125)
	emitter_slot(29) = Emitter_AddParticleType(EM, P7, 400,play_time(28)-600,150)
	; RETURN EMITTER HANDLE
	Return EM	
End Function

Function update_particle(EM)

For id = 0 To 28
az = play_time(id)
Next
If EM0 <> 0
a1 = Emitter_UpdateSlot(EM, emitter_slot(0), 0,az,985)
Else
If EM1 <> 0
For id = 0 To 28
a2 = Emitter_UpdateSlot(EM, emitter_slot(1), 0,az,100)
b2 = Emitter_UpdateSlot(EM, emitter_slot(2), 0,az,50)
Next
Else
If EM2 <> 0
a3=Emitter_UpdateSlot(EM, emitter_slot(3), 0,az,400)
b3=Emitter_UpdateSlot(EM, emitter_slot(4), 0,az,200)
Else
If EM3 <> 0
a4 = Emitter_UpdateSlot(EM, emitter_slot(5), 0,az-110,10)
b4 = Emitter_UpdateSlot(EM, emitter_slot(6), 100,az-150,50)
c4 = Emitter_UpdateSlot(EM, emitter_slot(7), 200,az-250,150)
d4 = Emitter_UpdateSlot(EM, emitter_slot(8), 250,az-350,40)
e4 = Emitter_UpdateSlot(EM, emitter_slot(9), 100,az-300,125)
f4 = Emitter_UpdateSlot(EM, emitter_slot(10), 400,az-600,150)
Else
If EM4 <> 0
a5 = Emitter_UpdateSlot(EM, emitter_slot(11), 0,az,75)
Else
If EM5 <> 0
a6 = Emitter_UpdateSlot(EM, emitter_slot(12),0,az,0)
b6 = Emitter_UpdateSlot(EM, emitter_slot(13),0,az,50)
c6 = Emitter_UpdateSlot(EM, emitter_slot(14),0,az,45)
Else
If EM6 <> 0
a7=Emitter_UpdateSlot(EM, emitter_slot(15), 0,az,15)
b7=Emitter_UpdateSlot(EM, emitter_slot(16), 0,az,450)
c7=Emitter_UpdateSlot(EM, emitter_slot(17), 0,az,10)
Else
If EM7 <> 0
a8 = Emitter_UpdateSlot(EM, emitter_slot(18), 0,az,15)
b8 = Emitter_UpdateSlot(EM, emitter_slot(19), 1000,az-1000,35)
c8 = Emitter_UpdateSlot(EM, emitter_slot(20), 0,az,150)
Else
If EM8 <> 0
a9=Emitter_UpdateSlot(EM, emitter_slot(21), 0, az, 115)
b9=Emitter_UpdateSlot(EM, emitter_slot(22), 1000, az, 40)
c9=Emitter_UpdateSlot(EM, emitter_slot(23), 0, az, 50)
Else
If EM9 <> 0
a10=Emitter_UpdateSlot(EM, emitter_slot(24), 0,az,100)
b10=Emitter_UpdateSlot(EM, emitter_slot(25), 0,az,50)
Else
If EM10 <> 0
a11 = Emitter_UpdateSlot(EM, emitter_slot(26), 0,az,400)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

End Function

Function playtime(snd%)

Local play_timeii

For id = 0 To 28

play_timeii = play_time(id)

Next

If FileExtension(playlist$(0)) = ".mp3" Then play_timeii = mcimp3length(snd%)
If FileExtension(playlist$(0)) = ".mid" Then play_timeii = mcimidilength(snd%)
If FileExtension(playlist$(0)) = ".wav" Then play_timeii = mciwavlength(snd%)

Return play_timeii

End Function

Function FileExtension$(File$)
If FileType(file$) = 1
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "." Return "."+Mid(File$, I% + 1)
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return ""
	Next
Else
Return "Unknown"
EndIf
End Function

Function Millisecs2Time$(m)
Local HourPart%, MinSecLeft%, MinPart%, SecLeft%, SecPart%
Local TimeStr$

   HourPart = Int(m / 3600000)
   MinSecLeft = m Mod 3600000
   MinPart = Int(MinSecLeft / 60000)
   SecLeft = m Mod 60000
   SecPart = SecLeft / 1000

   TimeStr=Str$(HourPart)+":"
   If HourPart<10 Then TimeStr="0"+TimeStr

   If MinPart<10 Then TimeStr=TimeStr+"0"
   TimeStr=TimeStr+Str$(MinPart)+":"
   
   If SecPart<10 Then TimeStr=TimeStr+"0"
   TimeStr=TimeStr+Str$(SecPart)
   
   Return TimeStr
End Function

Function mciplaying(snd)

If snd > 0 And FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav" Then playing = 1

Return playing

End Function

Function l_setAlpha(alpha#)

EntityAlpha l_surface,alpha#

End Function

Function l_update()

CopyRect 0,0,width,Height,0,0,BackBuffer(),TextureBuffer(l_texture)

End Function

Function notify()

WB3D_Notify "WARNING","Sorry, but file "+file1$+" is invalid.",0

End Function

Function stopm()

If FileExtension(file1$) = ".mp3" Or FileExtension(file1$) = ".mid" Or FileExtension(file1$) = ".midi" Or FileExtension(file1$) = ".wav" And mciplaying(snd) Then mciMP3free() : mciMidifree() : mciWavfree()

End Function

Function Write_BB(appname$, filedata$)

readme=WriteFile("README.txt")

WriteLine readme, "Please use Blitz3D to compile your project!"

file=WriteFile(filedata$)

WriteLine file, "AppTitle "+Chr$(34)+appname$+Chr$(34)

WriteLine file, ""

WriteLine file, "Graphics3D "+screenwidth+", "+screenheight+", "+screendepth+", "+screenmode

WriteLine file, ""

WriteLine file, "cam = CreateCamera()"

WriteLine file, "CameraRange cam, .1, 1000000"

WriteLine file, "PositionEntity cam, "+xcam+", 1, "+zcam

WriteLine file, ""

WriteLine file, "Land = CreatePlane()"

WriteLine file, ""

WriteLine file, "While Not Keyhit(1)"

WriteLine file, ""

WriteLine file, "If KeyDown(200) Or KeyDown(208) then MoveEntity cam, 0, 0, (KeyDown(200)-KeyDown(208))*1"

WriteLine file, "If KeyDown(203) Or KeyDown(205) TurnEntity cam, 0, (KeyDown(203)-KeyDown(205))*1, 0"

WriteLine file, ""

WriteLine file, "UpdateWorld()"

WriteLine file, "RenderWorld()"

WriteLine file, ""

WriteLine file, "Flip"

WriteLine file, ""

WriteLine file, "Wend"

CloseFile file

WB3D_Notify "Menu","Compilation Successful",0

WB3D_Notify "Menu","Compiled file in: "+CurrentDir$(),0

End Function

Function get_menu()

menu = menu + 1

If menu > 43 Then menu = 43

Return menu

End Function

Function File_Extension$(ext$)

For I% = Len(ext$) To 1 Step -1

If Mid$(ext$, I%,1) = "," Then Return "*"+Left(ext$, I%-1)+";"+"*"+ Right$(ext$, I%-1)

Next

End Function

Function FileName$(File$)
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return Mid(File$, I% + 1)
	Next
Return File$
End Function

Function FilePath$(File$)
For I% = Len(File$) To 1 Step -1
	If Mid(File$, I%, 1) = "" Or Mid(File$, I%, 1) = "/" Then Return Left(File$, I% - 1)
	Next
End Function

; Adds a file extention, if not exists. | F?Et eine Dateiendung hinzu falls noch keine da ist.
Function AddFileExtension$(File$, Extension$)
If FileExtension(File$) = "" Then Return File$ + "." + Extension$ Else Return File$
End Function

; plays the next loaded_song in the playlist, or reset to the first loaded_song.
Function process_playlist()

	; return if loaded_songs still playing
;	If ChannelPlaying(loaded_song_playing) = 1 
;		Return
;	Else
;	
;		; free the memory of the finished loaded_song
;		FreeSound loaded_song
;
;		; move to the next loaded_song in the playlist
;		current_loaded_song_index = current_loaded_song_index + 1
;
;		; check we have a loaded_song in the playlist, if we do play it
;		If playlist(current_loaded_song_index) <> "" Then
;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
;		Else
;			; loop playlist 
;			current_loaded_song_index = 0
;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
;		EndIf
;	EndIf

	; return if loaded_songs still playing
	If mciplaying(loaded_song_playing) = 1 
		Return
	Else
	
		; free the memory of the finished loaded_song
		mcimp3free() : mcimidifree() : mciwavfree()

		; move to the next loaded_song in the playlist
		current_loaded_song_index = current_loaded_song_index + 1

		; check we have a loaded_song in the playlist, if we do play it
		If playlist(current_loaded_song_index) <> "" Then

request(playlist(current_loaded_song_index))

;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
		
Else
			; loop playlist 
			current_loaded_song_index = 0

request(playlist(current_loaded_song_index))

;			loaded_song = LoadSound(playlist(current_loaded_song_index))
;			loaded_song_playing = PlaySound(loaded_song)
		EndIf
	EndIf
	
End Function

Function request(test1)
						 
If FileExtension(playlist$(0)) = ".mp3" Or FileExtension(playlist$(0)) = ".Mid" Or FileExtension(playlist$(0)) = ".midi" Or FileExtension(playlist$(0)) = ".wav" Then playa = 1

If FileExtension(playlist$(0)) = ".mid" Or FileExtension(playlist$(0)) = ".midi"

loaded_song = mciMidiOpen(playlist$(0)) : loaded_song_playing = mciMidiPlay(loaded_song)

Else

If FileExtension(playlist$(0)) = ".mp3"

loaded_song = mciMP3Open(playlist$(0)) : loaded_song_playing = mciMP3Play(loaded_song)

Else

If FileExtension(playlist$(0)) = ".wav"

loaded_song = mciWAVOpen(playlist$(0)) : loaded_song_playing = mciWAVPlay(loaded_song)

EndIf

EndIf

EndIf

End Function


These are the only 2 known problems left w/ my code. Please help 1 last time. Anyone who can help will get a free copy of my final project and all updates free afterwords if any =)

Thanks again! =)

~DarkShadowWing~

I will upload my project compiled.

Here's my compiled beta. I hope you guys understand what I'm trying to fix. =)

http://www.wikiupload.com/download_page.php?id=84801

ran the exe (sure hope i dont have any trojans because of it :p)
no matter what mp3 i load no particles appear and each time i click on a particle it says now load a song
"its playing the damn thing already"

If I dont get done by January, I'm gonna have to trash the project. I need to finish it on time, so I can start selling it. I want to hopefully get a patent for it. Or w/e I have to do to sell it on store shelves.


from what i could gather reading this thread you want some form of visualization ala windows media player
well thats the patent idea shot down for a start
and iir YOU would have to pay for the mp3 licence (perhaps even on freeware?)
edit: or was that only for encoding?

sell it?
not in that state
half of the menu's are just 'odd'
open
o
a>
quit

o and a are what exactly
and loop loops regardless if i click it on or off

seeing as you get windows media player 'free' with windows im always warey of buying something that does 'just the same' but better
so having seen 'it' what is 'it' meant to be if it isnt what i think it is, just a basic mp3 visualization program

edit:
and im not coming at this from a coding stand point as youve done more coding than i have (just ask anyone here ;) ) im coming at this from an end user/customer stand point
i want to know what you are 'selling' and what it can do

Well. What it can do is play 3D particles in different 3D scenes, such as a valley w/ a rocky waterfall, etc. And much more. As for the license, I already bought some mp3, midi & wav source from someone but right now I need some help to fix it. The menus are only in beta. I fix them whenever the program works correctly. The particles work on my end just not correctly. I'm gonna build a readme file today and recompile, so there won't be any more problems like this. As for the loop thing thanks for reminding me, that's another glitch I have NO idea how to fix.

I tried loop1 = 1-loop1 : loop1=wb3d_checkmenu() or w/e, and it acted up. so i took it out til it can be fixed.

Any more glitches, PLEASE let me know.

Also, can anyone help me fix these 2 glitches?

Thanks for all the help! =)

I really appreciate it =)

~DarkShadowWing~

I don't really get whats supposed to happen? I load the app. Choose a menu item, then have to go back into file, open an .mp3, then choose my particle type and it tells me again i have to load a song. The song plays anyway, but nothing happens. No particles?

Ok, i got the fountain one to work. If i click on fountain again, i get a lib error. TBH it looks like the particle candy demo.

I never said I was finished, lol. These are just tests. I'm gonna make my own particles when I'm done. Right now, I don't get why the particles are coming out wrong. The only thing I know, is if you change the play_time variable in CreateEmitter_blah() to an actual #, it looks right, but if u dont, then it looks messed up. For instance, try the spark particle. You shall see what I mean. Also, I dont get why waterfall wont work. I tried everything. Also, the particle only plays once per song loop. I need it to play everytime the song loops. And I tried loop1=1-loop : wb3d_checkmenuitem(loop, 5) and it wont turn on the loop if clicked once, then if clicked again , it wont turn off the loop.

~DarkShadowWing~

I'll recompile into debug mode, b/c it's not giving me an error.

Edit: Nvm. I found the lib error. Fixed.

~DarkShadowWing~

Ok. I fixed the particle problem. the only 3 problems left is clicking on the loop option, allowing the particle to loop as many times as the song, and clicking on a particle button more than once results in window message.

~DarkShadowWing~

Ah, so it isn't programmed to emit particles yet. Interesting app. What will it be used for?

Now it is. Lol. It is gonna be a media player capable of playing 3d particle while u listen to ur music (U can set the volume of the particle sound later on), among alot of other things. I'm HOPING if I can get blitz movie, it will play videos, although the particles wont activate during that. :P

Also, if u know a fix for Case 5 in the select code, (AKA Loop option), then PLEASE tell me. b/c loop1=1-loop1 : wb3d_checkmenuitem(loop, 5) didnt work.

Thanks again! =)

~DarkShadowWing~

I'm afraid i'm not familiar with the GUI system, so i can't help you too much.

loop1=1-loop1 << that obviously works perfectly, so it's a problem with the code used to operate the lib, or particles candy.

i know. its only supposed to checkmark the menu when the menu "loop" is selected. =/ What I need is a function that tells the gui when you select a menu option.

~DarkShadowWing~