Computer Science Canada Random music |
Author: | upthescale [ Fri May 12, 2006 5:39 pm ] |
Post subject: | Random music |
im making a game haqt iwill post so shortly...i have two sounds when i shoot the guys i want the sound to either do the siren sound, or the guy dying, is there that turing can randomly pick a sound? (siren or dieing) |
Author: | [Gandalf] [ Fri May 12, 2006 5:58 pm ] | ||||
Post subject: | |||||
This shouldn't be a problem for any programmer... You have got to think more generic when you look at a language, you can't expect every possible code for every possible function will be written for you. Why don't just use something like:
or better yet, if you want many more songs:
Also what does "haqt" mean? |
Author: | AzureFire [ Fri May 12, 2006 7:42 pm ] | ||||||||||||
Post subject: | |||||||||||||
Another easy way is to use a simple number file system. Say file number one is called death.wav so...
Then you'll need to use String Concatenation. This is simply joining two strings together. You can do this with the + operator. eg;
You can also do it this way;
The only problem is that when you call the sound file, you cannot use an integer. You will need to use intstr(). Like this;
Simple right? So let's make the code;
There, nice one-liner with no variables. I really hope that this is easily understandable. This is one of the simplest ways to do this, if this is hard to figure out, time to do some reading and fiddling. Learn by making mistakes and fixing them, and also help files do as the name suggests. P.S. I haven't tested any of this. Feel free to do so. |
Author: | [Gandalf] [ Fri May 12, 2006 11:00 pm ] | ||
Post subject: | |||
Yep, the number to string method will work. It's what I meant with: [Gandalf] wrote:
|
Author: | AzureFire [ Sun May 14, 2006 8:45 am ] | ||
Post subject: | |||
[Gandalf] wrote: Yep, the number to string method will work. It's what I meant with:
[Gandalf] wrote:
Ahhh, I read it wrong, I thought you were talking about making a for loop and playing each one, one after another. |