New to C++ and I am trying to make a die mechanic in my game. I am trying to see if i can do what i did for the sides of the die(a) being able to make it as many sides as needed. Now i need to do the same with how many times the dice gets rolled. If there is a better way i would also like to see it.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int rDice(int a);
int main()
{
int z;
z = rDice(20);
cout << "The result is " << z;
}
// takes a value of sided dice (a) and returns the value through d int rDice(int a)
{
srand(time(0));
int d;
d = 1+(rand()%a);
return d;
}
Aucun commentaire:
Enregistrer un commentaire