
-----------------------------------
darrenl
Thu May 05, 2011 8:43 am

I Cant Make The Sound Stop In A Loop
-----------------------------------
What is it you are trying to achieve?
setscreen ("graphics:600;650;nobuttonbar")
const B : int := 494
const A : int := 440
const G : int := 392
const D : int := 587
var counter : int
var key : array char of boolean


 
loop
    loop
        Input.KeyDown (key)
        counter := 0
        if key (KEY_RIGHT_ARROW) then
            sound (D, 1)

            put "right key" ..
        else
            put "exiting"
            counter := 1

        end if
        exit when counter >= 1

    end loop
end loop




What is the problem you are having?
This is a test program for a bigger project (tap tap game using turing sounds).
as you can see the loop ends when the right arrow key is not pressed, so the sound should stop then. the loop then restarts, checks the key again and repeats quickly. what i want is the sound to play when the button is pressed elsif be quiet.


Describe what you have tried to solve this problem
i have tried sound (0,1) hoping it would make no sound but it doesnt work. please hellp so i can continue with the project.   :x 


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
Tony
Thu May 05, 2011 1:42 pm

RE:I Cant Make The Sound Stop In A Loop
-----------------------------------
Looks like this works just fine. Replace

i have tried sound (0,1) hoping...

You should read the documentation on [tdoc]sound[/tdoc] to see exactly how it works.
