In my current situation I have a game world, in that game world I want to place loads of tree models. It is a waste of time for me to actually explicitly define the x y and z values of each tree model, so I want to do this with the help of random logic, so that it can just set the values for me. I don't want true randomness, so I do not need to seed the random logic, I want to generate the positions of all the trees randomly so that I don't need to type each one myself, but each time I run the game the trees are in the same position, so it is not truly random but that is what I want.
My current attempt is as follows:
for (int i = 0; i < numOfTrees; i++) {
treeObjects.push_back(
(new Entity(Vector3f(//x, y and z position value of each tree
rand() % 200 + (-200), //random value for x
0.0f, //y value kept as 0.0f
rand() % 200 + (-200)) //random value for z
//above code positions the trees, the rest of the code is irrelevant
}
The issue with this is that all the trees are very tightly packed together, so I am very skeptical that they are getting a value between -200 and 200, because if they were they would be much more spread out. Does someone know of a better solution to produce what i'm after? maybe there is an issue with the way I am doing it?