Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AbrahamR, 7th_zorro, dr_panther, 1 invisible), 702 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Random audio player #417311
02/11/13 14:29
02/11/13 14:29
Joined: Jan 2013
Posts: 41
Redoine Offline OP
Newbie
Redoine  Offline OP
Newbie

Joined: Jan 2013
Posts: 41
hello guys

i finshed working on my litle FPS game thanx to you guys

but i still don't know how to make a random audio player

because when i shoot the enemy or enemy shoots me i hear the same

thing (the voice that player say when he gets heard)

so i want to add deferent sounds and make a program that plays

those sounds randomly

thank you very much

Re: Random audio player [Re: Redoine] #417312
02/11/13 14:35
02/11/13 14:35
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
That will be pretty simple, you'll need to use "integer" and "random", as in this example:
Code:
var randomSound = integer(random(2)); // two random sounds
if(randomSound == 0){ 
     // play first sound here 
}
if(randomSound == 1){
     // play second sound here
}

But, you have to understand, that the value, which is returned by "integer(random(2));", will be always smaller than "2"!
So if you'll try something like this:
Code:
if(randomSound == 2){
    // play something here
}

It won't work! Good luck!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Random audio player [Re: Redoine] #417313
02/11/13 14:35
02/11/13 14:35
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
Just off the top of my head probably a better way

Code:
var num_songs = 2;
var sound_handle;

function switch_sound(snd)
{
     switch(snd)
     {
        CASE 0:
        sound_handle = snd_play(sound1, 100, 0);
        break;

        CASE 1:
        sound_handle = snd_play(sound2, 100, 0);
        break;

     }
}

void main()
{
   random_seed(0);
   var random_sound = integer(random(num_songs ));
   switch_sound(random_sound );
}



Just typed this have not tested it


John C Leutz II

Re: Random audio player [Re: lostzac] #417314
02/11/13 14:40
02/11/13 14:40
Joined: Jan 2013
Posts: 41
Redoine Offline OP
Newbie
Redoine  Offline OP
Newbie

Joined: Jan 2013
Posts: 41
Thank you guys very much


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1