• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Question Or Two

This topic is 6578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m making a game and want to add sound effects I have read everywhere that I will be needing the FMOD library etc... Well I have all those but can do nothing with them! Does any of you have some source code which loads a *.wav and/or *.mp3 files. Also does any of you know how to generate a random number in C++, the reason being, for my game I want power-ups to pop-up every now and then and I need to generate random positions for them. Many Thanks Alan IF YA SMELL... WHAT THE BEZZ IS COOKIN''''

##### Share on other sites
Cant answer the FMOD thing but this is the C library function for generating a random number:
int rand( void );

And the funtion to seed the generator is this
void srand( unsigned int seed );

This little lot was copied from the MSDN

The srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

rand returns a pseudorandom number, as described above. There is no error return.

Remarks

The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand.

Example
/* RAND.C: This program seeds the random-number generator * with the time, then displays 10 random integers. */#include #include #include void main( void ){   int i;   /* Seed the random-number generator with current time so that    * the numbers will be different every time we run.    */   srand( (unsigned)time( NULL ) );   /* Display 10 numbers. */   for( i = 0;   i < 10;i++ )      printf( "  %6d\n", rand() );}

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634092
• Total Posts
3015448
×