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

Username:   Password: 
 RegisterRegister   
 Using Sound in turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
D_homes




PostPosted: Sun Nov 08, 2009 1:59 pm   Post subject: Using Sound in turing

What is it you are trying to achieve?
Stop the music file from playing if the variable "ammo" is equal to zero.


What is the problem you are having?
I can't get it to work.


Relevant code

Turing:


    %check to see if mouse is clicked
    if button = 1 then
        delay (100)
        Music.PlayFile ("fire1.wav")
        ammo := ammo - 1
        %If ammo is equal to or less than 0, then it equals 0
        if ammo <= 0 then
            ammo  := 0
        end if
        cls
    end if
    cls



Version of Turing:
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Superskull85




PostPosted: Sun Nov 08, 2009 2:27 pm   Post subject: RE:Using Sound in turing

You can use Music.PlayFileStop () to stop the playback of music files. If you want your program to continue while playing music, than use Music.PlayFileReturn (FileName : string) instead of Music.PlayeFile (FileName : string).
D_homes




PostPosted: Sun Nov 08, 2009 2:45 pm   Post subject: RE:Using Sound in turing

This still doesnt fix my problem.
Do you mean to change it to this?


if button = 1 then
delay (100)
Music.PlayFileReturn ("fire1.wav")
ammo := ammo - 1

if ammo <= 0 then
Music.PlayFileStop
ammo := 0
end if
cls
end if

I want the .wav to not play when the variable ammo = 0
D_homes




PostPosted: Sun Nov 08, 2009 3:29 pm   Post subject: RE:Using Sound in turing

Anyone?
Tony




PostPosted: Sun Nov 08, 2009 3:46 pm   Post subject: RE:Using Sound in turing

In your current code, you are playing the sound first, then checking to see if ammo is empty. You probably want to have it the other way around.
code:

if button = 1 then
        if ammo <= 0 then
            ammo  := 0
        else
             Music.PlayFile ("fire1.wav")
             ammo -= 1
        end if
    end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: