I am using Windows/MinGW. I have the following code to generate random ranges whenever I need:
random_device rd;
mt19937 eng(rd());
int get_random_int(int from, int to){
uniform_int_distribution<int> dist(from, to);
return dist(rd);
}
How do I feed the engine with a random seed like the current time or whatever? (I've tried to replace rd with time, but it's not possible). In my game, the enemies spawn in random positions in all directions and start moving towards you. It happens that, every time I start the game, they spawn in the same places (And that's exactly the opposite of what I want, since they're going to feel predictable).
EDIT (The procedure that generates the enemies):
void generate_enemies(int q, int speed) {
for (int i = 0; i < q; i++) {
Actor a;
a.facing = get_random_int(0, 3);
a.speed = speed;
if (a.facing == UP) {
a.x = get_random_int(0, SCREEN_WIDTH);
a.y = -get_random_int(SCREEN_HEIGHT, SCREEN_HEIGHT + get_random_int(0, ENEMY_DISTANCE_FACTOR * get_random_int(0, ENEMY_DISTANCE_MULTIPLICATIVE_FACTOR)));
} else if (a.facing == DOWN) {
a.x = get_random_int(0, SCREEN_WIDTH);
a.y = get_random_int(SCREEN_HEIGHT, SCREEN_HEIGHT + get_random_int(0, ENEMY_DISTANCE_FACTOR * get_random_int(0, ENEMY_DISTANCE_MULTIPLICATIVE_FACTOR)));
} else if (a.facing == LEFT) {
a.x = -get_random_int(SCREEN_WIDTH, SCREEN_WIDTH + get_random_int(0, ENEMY_DISTANCE_FACTOR * get_random_int(0, ENEMY_DISTANCE_MULTIPLICATIVE_FACTOR)));
a.y = get_random_int(0, SCREEN_HEIGHT);
} else if (a.facing == RIGHT) {
a.x = get_random_int(SCREEN_WIDTH, SCREEN_WIDTH + get_random_int(0, ENEMY_DISTANCE_FACTOR * get_random_int(0, ENEMY_DISTANCE_MULTIPLICATIVE_FACTOR)));
a.y = get_random_int(0, SCREEN_HEIGHT);
}
enemies.push_back(a);
}
}