Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trouble with music file and "play again" in Tetris game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
falloutboysimpleplan




PostPosted: 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)



tetrissummative.t
 Description:
Turing 4.1.1

Download
 Filename:  tetrissummative.t
 Filesize:  10.62 KB
 Downloaded:  153 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cezna




PostPosted: 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
Monduman11




PostPosted: 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
Turing:

Music.PlayFileLoop ("songhere.jpg")
% and to stop it
Music.PlayFileStop
% thats all you need

it doesnt get easier than that, plus you dont need a process
Cezna




PostPosted: Tue Jun 22, 2010 3:05 pm   Post subject: RE:Trouble with music file and "play again" in Tetris game

Oops Embarassed
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.
falloutboysimpleplan




PostPosted: 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!
Monduman11




PostPosted: 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
TWizard




PostPosted: 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.
TheGuardian001




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: