Advertisement Jump to content


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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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.


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.


/* RAND.C: This program seeds the random-number generator
* with the time, then displays 10 random integers.


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() );

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!