Sign in to follow this  

C++ Help

This topic is 4216 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

Hello, I am using Bloodshed Dev C++ and I have a question. If I am making a DOS text-based RPG, how would I add an experience thing. Such as.. say you fight a monster, then how do I add it to where it will add a random number between 1-10 to my experience and display it?

Share this post


Link to post
Share on other sites
Here are 2 functions that calculate a random int and float between 2 values:


int RandomInt(int iMin, int iMax)
{
int iDiff = iMax - iMin;
return ( rand() % (iDiff+1) ) + iMin;
}

float RandomFloat(float fMin, float fMax)
{
float fRandom = (float)rand() / RAND_MAX;
return ( (fMax - fMin) * fRandom ) + fMin;
}


Share this post


Link to post
Share on other sites
Sign in to follow this