Need help with fork command.. possibly?
Author |
Message |
Krol23
|
Posted: Mon Jun 13, 2011 6:12 pm Post subject: Need help with fork command.. possibly? |
|
|
What is it you are trying to achieve?
Hi there. I am trying to play an mp3 file when my frog clears a stage in the frogger game I have created but having some troubles; please help.
What is the problem you are having?
My song file plays first, and then the screen is cleared and my Draw.Font text is displayed after, whereas I want both of these things to happen simultaneously.
Describe what you have tried to solve this problem
I have tried messing around with processes, procedures, and the fork command but I don`t really know what I`m doing.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Basically I'm saying that when the coordinates of my frog character collide with the colour 54 then the screen is cleared, and my font is displayed saying "success" and such. However the music is played before all of this while still in game. I want the screen to be cleared, my font to be displayed, and the music to play all at the same time. Please note that my "failure:= true" is simply so that an irrelevant loop is exited when the frog reaches colour 54.
Please specify what version of Turing you are using
Version 4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Mon Jun 13, 2011 6:23 pm Post subject: RE:Need help with fork command.. possibly? |
|
|
Create a process for the music instead of calling it directly.
code: | process playMusic (musicFile : string)
Music.PlayFile (musicFile)
end playMusic
%now, any time you want music, just fork playMusic()
fork playMusic ("stage_completed.mp3")
|
You can also use Music.PlayFileLoop(), but I think this, as obviously implied, loops the music, therefore requiring Music.PlayFileStop() to, well, stop it. That can get very inconvenient if you're playing lots of files of variable length, so just stick with the process approach. |
|
|
|
|
|
Tony
|
|
|
|
|
Krol23
|
Posted: Mon Jun 13, 2011 8:16 pm Post subject: Re: Need help with fork command.. possibly? |
|
|
Thanks for you help guys, but I'm still stuck. Now I'm forking the music and I have the same problem. The screen is only cleared and "success" is only printed when the mp3 file finishes playing. I have also made additions so that my background music during gameplay stops when the frog collides, but I'm not having problems with that.
My process for the music that is to play when the frog collides is simply this:
process complete
Music.PlayFile ("stage_completed.mp3")
end complete
And here is my new code:
Any help is greatly appreciated. Again, all I need is everything above to occur at the same time. Thanks. |
|
|
|
|
|
Tony
|
Posted: Mon Jun 13, 2011 8:26 pm Post subject: RE:Need help with fork command.. possibly? |
|
|
Are you using offscreenonly? If so, you might have forgotten to update the screen. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Krol23
|
Posted: Tue Jun 14, 2011 6:45 am Post subject: Re: Need help with fork command.. possibly? |
|
|
I am using offscreenonly, Tony. Where might I have to throw a view.update in there to get this to work? |
|
|
|
|
|
Krol23
|
Posted: Tue Jun 14, 2011 6:58 am Post subject: Re: Need help with fork command.. possibly? |
|
|
Nevermind actually, I put a View.Update in and got everything to work properly. Thanks very much for your help Tony |
|
|
|
|
|
|
|