Author |
Message |
falloutboysimpleplan
|
Posted: Tue Jun 22, 2010 11:42 am Post subject: Trouble with music file and "play again" in Tetris game |
|
|
My game works fine, I'm just trying to go back after a while and add some stuff in. I would like to put in a music file that I have saved, it seems to work until it's "game over" then instead of going to that screen, the game just stops and the music keeps playing. When I had the music code out, the "game over" screen came up as supposed to.
I would also like to add a "play again" in the "game over" screen so players don't have to close and reopen the game to play again.
I am using Turing 4.1.1, can anyone help?
(Code should be attached)
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
tetrissummative.t |
Filesize: |
10.62 KB |
Downloaded: |
153 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cezna
![](http://compsci.ca/v3/uploads/user_avatars/9406831824c097251d4bb4.gif)
|
Posted: Tue Jun 22, 2010 2:52 pm Post subject: Re: Trouble with music file and "play again" in Tetris game |
|
|
You can replace this:
Turing: |
%%%%%%%%%%%%%%%%%%%%%%%%%Music Plays%%%%%%%%%%%%%%%%%%%%%%%%%
%process playstuff
%loop
%gameOver := false
%Music.PlayFile ("Tetris.wav")
%exit when gameOver
%end loop
%end playstuff
%fork playstuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
With this:
Turing: |
%%%%%%%%%%%%%%%%%%%%%%%%%Music Plays%%%%%%%%%%%%%%%%%%%%%%%%%
process playstuff
loop
gameOver := false
Music.PlayFileLoop ("Tetris.wav")
exit when gameOver
end loop
end playstuff
fork playstuff
|
and the music file will start over every time it stops.
Also, for future reference, instead of putting % in front of every line, just do this to have an entire section of code be a comment:
Turing: |
var the : int
the := 10
/*
comments here
*/
put the
|
|
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Tue Jun 22, 2010 2:58 pm Post subject: Re: Trouble with music file and "play again" in Tetris game |
|
|
even easier than that you can just do
it doesnt get easier than that, plus you dont need a process
|
|
|
|
|
![](images/spacer.gif) |
Cezna
![](http://compsci.ca/v3/uploads/user_avatars/9406831824c097251d4bb4.gif)
|
Posted: Tue Jun 22, 2010 3:05 pm Post subject: RE:Trouble with music file and "play again" in Tetris game |
|
|
Oops
Monduman is right, I forgot to include the line to stop the file, and I was paying so little attention that I didn't realize you had it in a loop.
You do not need to put Music.PlayFileLoop in a loop, only call it once, as Monduman has done in his code.
|
|
|
|
|
![](images/spacer.gif) |
falloutboysimpleplan
|
Posted: Tue Jun 22, 2010 9:11 pm Post subject: RE:Trouble with music file and "play again" in Tetris game |
|
|
It was simple after all! Thanks a lot for your help guys, the music works great!
|
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Tue Jun 22, 2010 9:13 pm Post subject: RE:Trouble with music file and "play again" in Tetris game |
|
|
your welcome glad to be of help
|
|
|
|
|
![](images/spacer.gif) |
TWizard
![](http://compsci.ca/v3/uploads/user_avatars/14193012864c2cdeb3237c3.jpg)
|
Posted: Fri Jul 02, 2010 8:20 pm Post subject: RE:Trouble with music file and "play again" in Tetris game |
|
|
Would'nt you want to make the music file more flexible and keep the process ?
Turing: |
process Music
Music.PlayFileLoop ("music name.mp3")
end Music
fork music
/*
then use
Music.PlayFileStop
to stop it ?
*/
|
Because then its easyer to use where you need it. Say if you needed to change the file name.
Just wondering why you would get rid of it.
|
|
|
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: Fri Jul 02, 2010 8:39 pm Post subject: Re: Trouble with music file and "play again" in Tetris game |
|
|
1) Processes are messy, and this one would be pointless (There's no need to fork a PlayFileLoop, a procedure would be more appropriate.)
2) Whether this is in a procedure or not, the call will still be one line. Technically you could use a parameter on a procedure to keep it flexible, however:
3) There's only one song in Tetris.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|