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

Username:   Password: 
 RegisterRegister   
 How can I play an audio file during a for statement that stops playing when the for statement ends?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
asdfasdf123




PostPosted: Tue Jan 06, 2015 11:47 am   Post subject: How can I play an audio file during a for statement that stops playing when the for statement ends?

What is it you are trying to achieve?
I'm trying to make a slot machine game where the sound of a spinning slot machine plays when it spins in the game.


What is the problem you are having?
The sound starts playing at the right time, but it keeps playing over and over again after that.


Describe what you have tried to solve this problem
I moved the fork statement to different places in the code and tried the command Music.PlayFileStop.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:

process playfile
    loop
        Music.PlayFile ("filename.wav")
    end loop
end playfile
fork playfile
for i : 1 .. 10
                % Top (yellow)
                drawfilloval (CENTREX - 160, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX - 120, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX - 80, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX - 40, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX + 40, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX + 80, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX + 120, CENTREY + 95, 15, 15, 0)
                drawfilloval (CENTREX + 160, CENTREY + 95, 15, 15, 0)
                % Bottom (yellow)
                drawfilloval (CENTREX - 160, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX - 120, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX - 80, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX - 40, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX + 40, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX + 80, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX + 120, CENTREY - 100, 15, 15, 0)
                drawfilloval (CENTREX + 160, CENTREY - 100, 15, 15, 0)
                if i = 1 or i = 3 or i = 5 or i = 7 or i = 9 or i = 10 then
                    % Top (yellow)
                    drawfilloval (CENTREX - 160, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX - 120, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX - 80, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX - 40, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX + 40, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX + 80, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX + 120, CENTREY + 95, 15, 15, yellow)
                    drawfilloval (CENTREX + 160, CENTREY + 95, 15, 15, yellow)
                    % Bottom (yellow)
                    drawfilloval (CENTREX - 160, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX - 120, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX - 80, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX - 40, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX + 40, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX + 80, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX + 120, CENTREY - 100, 15, 15, yellow)
                    drawfilloval (CENTREX + 160, CENTREY - 100, 15, 15, yellow)
                elsif i = 2 or i = 4 or i = 6 or i = 8 then
                    drawfilloval (CENTREX - 160, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX - 120, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX - 80, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX - 40, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX + 40, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX + 80, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX + 120, CENTREY + 95, 15, 15, 41)
                    drawfilloval (CENTREX + 160, CENTREY + 95, 15, 15, 41)
                    % Bottom (yellow)
                    drawfilloval (CENTREX - 160, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX - 120, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX - 80, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX - 40, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX + 40, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX + 80, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX + 120, CENTREY - 100, 15, 15, 41)
                    drawfilloval (CENTREX + 160, CENTREY - 100, 15, 15, 41)
                end if
                left := Rand.Int (1, 100)
                middle := Rand.Int (1, 100)
                right := Rand.Int (1, 100)
                if i not= 10 then
                    % Left reel
                    if left < 50 then
                        include "BarLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "BarLeftMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "BarLeftBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                    elsif left < 80 then
                        include "LemonLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "LemonLeftMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "LemonLeftBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                    elsif left < 99 then
                        include "PlumLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "PlumLeftMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "PlumLeftBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                    elsif left = 100 then
                        include "CherryLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "CherryLeftMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "CherryLeftBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                    end if
                    % Middle reel
                    if middle < 50 then
                        include "LemonMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "LemonMiddleMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "LemonMiddleBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                    elsif middle < 80 then
                        include "PlumMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "PlumMiddleMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "PlumMiddleBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                    elsif middle < 99 then
                        include "BarMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "BarMiddleMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "BarMiddleBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                    elsif middle = 100 then
                        include "CherryMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "CherryMiddleMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "CherryMiddleBottom.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                    end if
                    % Right reel
                    if right < 50 then
                        include "PlumRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "PlumRightMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "PlumRightBottom.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                    elsif right < 80 then
                        include "BarRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "BarRightMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "BarRightBottom.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                    elsif right < 99 then
                        include "LemonRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "LemonRightMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "LemonRightBottom.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                    elsif right = 100 then
                        include "CherryRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "CherryRightMiddle.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "CherryRightBottom.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                    end if
                    % Machine stops spinning
                elsif i = 10 then
                    % Left reel
                    if left < 50 then
                        left2 := 50
                        include "BarLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "BarLeftMiddle.t"
                    elsif left < 80 then
                        left2 := 80
                        include "LemonLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "LemonLeftMiddle.t"
                    elsif left < 99 or left = 99 then
                        left2 := 99
                        include "PlumLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "PlumLeftMiddle.t"
                    elsif left = 100 then
                        left2 := 100
                        include "CherryLeftTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 150, CENTREY - 70, CENTREX - 60, CENTREY + 70, white)
                        include "CherryLeftMiddle.t"
                    end if
                    % Middle reel
                    if middle < 50 then
                        middle2 := 80
                        include "LemonMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "LemonMiddleMiddle.t"
                    elsif middle < 80 then
                        middle2 := 99
                        include "PlumMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "PlumMiddleMiddle.t"
                    elsif middle < 99 or middle = 99 then
                        middle2 := 50
                        include "BarMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "BarMiddleMiddle.t"
                    elsif middle = 100 then
                        middle2 := 100
                        include "CherryMiddleTop.t"
                        delay (50)
                        drawfillbox (CENTREX - 40, CENTREY - 70, CENTREX + 40, CENTREY + 70, white)
                        include "CherryMiddleMiddle.t"
                    end if
                    % Right reel
                    if right < 50 then
                        right2 := 99
                        include "PlumRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "PlumRightMiddle.t"
                    elsif right < 80 then
                        right2 := 50
                        include "BarRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "BarRightMiddle.t"
                    elsif right < 99 or right = 99 then
                        right2 := 80
                        include "LemonRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "LemonRightMiddle.t"
                    elsif right = 100 then
                        right2 := 100
                        include "CherryRightTop.t"
                        delay (50)
                        drawfillbox (CENTREX + 60, CENTREY - 70, CENTREX + 150, CENTREY + 70, white)
                        include "CherryRightMiddle.t"
                    end if
                end if
            end for


Please specify what version of Turing you are using
4.1 1.0.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Jan 06, 2015 12:01 pm   Post subject: RE:How can I play an audio file during a for statement that stops playing when the for statement ends?

You'll want to look into Music.PlayFileStop.
asdfasdf123




PostPosted: Tue Jan 06, 2015 12:09 pm   Post subject: RE:How can I play an audio file during a for statement that stops playing when the for statement ends?

Like I said, I tried adding it, but it didn't work. Could you specify where I should put it?
asdfasdf123




PostPosted: Tue Jan 06, 2015 12:26 pm   Post subject: RE:How can I play an audio file during a for statement that stops playing when the for statement ends?

Nevermind, it works now. I removed the loop from the process.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: