
-----------------------------------
junkpro11
Sun May 09, 2004 10:34 am

playing sound when any button is pressed
-----------------------------------
how do u play a sound whenever anything on the keyboard is pressed?

-----------------------------------
Paul
Sun May 09, 2004 11:18 am


-----------------------------------
This works :P

setscreen ("nocursor")
var key : string (1)
loop
getch (key)
Music.Play ("a")
end loop


-----------------------------------
Mazer
Sun May 09, 2004 11:43 am


-----------------------------------
:shock: 
How about this instead?

setscreen ("nocursor")
var key : string (1)
loop
    if hasch then
        getch (key)
        Music.Play ("a")
    end if
end loop


-----------------------------------
junkpro11
Sun May 09, 2004 2:58 pm


-----------------------------------
can u explain how the code works? 

it would help alot

-----------------------------------
Dan
Sun May 09, 2004 3:40 pm


-----------------------------------

setscreen ("nocursor")

var key : string (1) %a char to store the keyinput

%main loop that keeps the progame runing
loop
    
    if hasch then %if a key has been hit on the key borad

        getch (key) %input the key in to the char var

        Music.Play ("a") %plays the note A like on a paino

    end if

end loop 

-----------------------------------
s_climax
Sun May 09, 2004 4:37 pm


-----------------------------------
It works better to do this.


var key : string (1) 
loop 
getch (key) 
Music.Play ("16a") 
end loop 


-----------------------------------
Mazer
Sun May 09, 2004 5:38 pm


-----------------------------------
But that halts the program waiting for the user to give input, that's why I had the if statement with hasch.

-----------------------------------
recneps
Sun May 09, 2004 6:42 pm


-----------------------------------
whgen i run that and hit the key before it stop, my comp bluscreens, wtf? :/

-----------------------------------
Dan
Sun May 09, 2004 11:13 pm


-----------------------------------
both verson work fine for me, dose your comp have a sound card?
