Hi. I'm having a problem trying to add the amount of song play time to the particle's life time.
Optimized Code:
The line of the particle life:
Inside CreateEmitter_Waterfall()
Basically, I want the songs play time to be the particle's life time =)
Any help would be GREATLY appreciated =)
~DarkShadowWing~
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~