Randomly generate x,y coord for png's

Hey everyone. I got some help here before with regards to collision detection, but now I require some more help. I'm looking to allocate certain x/y coordinates that would draw png's (in the form of a rock or a tree), but I need to implement the random header to randomly pick WHICH png would be drawn.

Is that even possible?

Yes. Generating random numbers is a standard C++ function.
I have no idea how to do it though.
Here is how to generate a random int from 10 to 100, with uniform random distribution. Requires a C++11 compliant compiler.

1
2
3
4
5
6
7
8
9
10
11
#include <random>
#include <iostream>

int main()
{
    int low_end_of_random_range = 10;
    int high_end_of_random_range = 100;
    std::uniform_int_distribution<> d(low_end_of_random_range, high_end_of_random_range);
    std::mt19937 gen;
    std::cout << d(gen) << '\n';
}
Thank you so much!!!
Topic archived. No new replies allowed.