I need some tips from a pro for my newbie game.

Started by
10 comments, last by Matt Apple 19 years, 2 months ago
If ya check out my DICE() function it works great. Like when playing RPG's we are always saying 2d4 or 3d6 my funtion does that. DICE(2,4)gives a roll of 3 four sided dice or DICE(3,6) will give a roll of 3 six sided dice. Thanks for all of the neat random stuff. Keep it coming.:)
Advertisement
Here is my little "dice rolling" widget from my personal library.

# include <iostream># include <cstdlib># include <ctime>using namespace std;int random(int,int);int main(){        srand((unsigned int)time(NULL));        int randInt;        randInt = random(1,6);        cout << randInt << endl;        return 0;}int random(int min, int max){		return (int)((max - min) * rand()/(float)RAND_MAX + min);}


Outputs a random integer with customizable upper and lower bounds. For example this one outputs a random integer between 1 and 6 inclusive. This method provides a more uniform distribution than modulus(%) methods.

This topic is closed to new replies.

Advertisement