title: Algorithm to spawn objects randomly
body: <p>so I'm making a snowboarding game, and as the player rides down I want the terrain to randomly generate. Right now, I'm using this code:</p>
  
  <pre><code>void Biome::draw()
  {
      srand(seed); // seed is generated elsewhere
      for (int x = 0; x &lt; maxObstAmount; x++)
      {
          int xLoc = rand() % 640;
          int yLoc = rand() % 480;
          int obst = rand()%obstsInBiome.size();
          obstsInBiome[obst].drawObstacle(xLoc, yLoc);
      }
  }
  </code></pre>
  
  <p>The function chooses random obstacle in the biome, and spawns it at a random location on the screen, which is essentially what I want. However, this causes objects to overlap, and so forth, so I was just wondering if anyone could help me come up with a better algorithm to spawn them so they don't overlap? Thanks</p>