lundi 5 octobre 2015

std::uniform_int_distribution placed into a function or am I using it wrong?

I am a new user of C++ and currently I am trying a challenge on YouTube of making a 1d console prompt game; I am trying to make it so that I have weapons that have different damage ranges and when the console opens it gives a random number between a set range e.g., 40 - 80.

However, when I try to run it to see what I have so far the number generator just keeps giving me the same number over and over again. Now, I am going to take a guess and think that there is something wrong with my seed generator but if I stick the code in the function into main everything runs smoothly. Can std::mt19937 and std::uniform_int_distribution go into function with parameters or am I going about it completely wrong, is the return wrong?

I would post an image but as I am new to stackOverflow and have < 10 rep I am unable to do so.

Any help would be greatly appreciated, kind regards, Shane.

Aucun commentaire:

Enregistrer un commentaire