Author |
Message |
junkpro11
|
Posted: Sun May 09, 2004 10:34 am Post subject: playing sound when any button is pressed |
|
|
how do u play a sound whenever anything on the keyboard is pressed? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Sun May 09, 2004 11:18 am Post subject: (No subject) |
|
|
This works
code: |
setscreen ("nocursor")
var key : string (1)
loop
getch (key)
Music.Play ("a")
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Sun May 09, 2004 11:43 am Post subject: (No subject) |
|
|
How about this instead?
code: |
setscreen ("nocursor")
var key : string (1)
loop
if hasch then
getch (key)
Music.Play ("a")
end if
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
junkpro11
|
Posted: Sun May 09, 2004 2:58 pm Post subject: (No subject) |
|
|
can u explain how the code works?
it would help alot |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Sun May 09, 2004 3:40 pm Post subject: (No subject) |
|
|
code: |
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 |
|
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
s_climax
|
Posted: Sun May 09, 2004 4:37 pm Post subject: (No subject) |
|
|
It works better to do this.
code: |
var key : string (1)
loop
getch (key)
Music.Play ("16a")
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Sun May 09, 2004 5:38 pm Post subject: (No subject) |
|
|
But that halts the program waiting for the user to give input, that's why I had the if statement with hasch. |
|
|
|
|
![](images/spacer.gif) |
recneps
![](http://www.fcpocanada.com/canada1.gif)
|
Posted: Sun May 09, 2004 6:42 pm Post subject: (No subject) |
|
|
whgen i run that and hit the key before it stop, my comp bluscreens, wtf? :/ |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Sun May 09, 2004 11:13 pm Post subject: (No subject) |
|
|
both verson work fine for me, dose your comp have a sound card? |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
|