I need some tips from a pro for my newbie game.
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.:)
Here is my little "dice rolling" widget from my personal library.
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.
# 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
Popular Topics
Advertisement