1

I'm creating a game that makes map randomly. The problem is that the update functions call are so fast that even using:

srand(time(NULL));
rand()%2;

It generates the same group of tiles every time. There is my code:

void setTex(){
    srand((unsigned)time(NULL));
    switch(rand()%2){
        case 0:
            texture = TextureManager::LoadTexture("assets/ground_1.png");
            break;
        case 1:
            texture = TextureManager::LoadTexture("assets/ground_2.png");
            break;
        case 2:
            texture = TextureManager::LoadTexture("assets/water.png");
            break;
    }
}

I'm looking for a Pseudo-Random algorithm that can provide me enough randomness to change tile each call of the function.

Yeste
  • 135
  • 10

0 Answers0