I'm using c ++ with the openGL library, I'm having a bit of trouble creating a method. I need to create some buildings randomly, but not to create one inside the other I need to compare the 4 points of the building. If anyone can help me.
string localizacaoPredio[150];
int ultimaPos = 0;
for (int i = 0; i < 150; i++){
int x = rand() % 10 + 1;
int z = rand() % 10 + 1;
string coordenada = x + ";" + z;
for (int j = 0; j < ultimaPos; j++){
if (localizacaoPredio[j].compare(coordenada)){
x = rand() % 10 + 1;
z = rand() % 10 + 1;
coordenada = x + ";" + z;
j = -1;
}
}
localizacaoPredio[ultimaPos] = coordenada;
ultimaPos++;
}
int andares[150];
for (int i = 0; i < 150; i++){
andares[i] = rand() % 10 + 1;
}
int numDivisoes[150];
for (int i = 0; i < 150; i++){
numDivisoes[i] = rand() % 10 + 1;
}
for (int i = 0; i < 150; i++){
Building b1(localizacaoPredio[i], y1, andares[i], numDivisoes[i], 1, 1);
planos.push_back(b1.predio[0].plano);
planos.push_back(b1.predio[1].plano);
planos.push_back(b1.predio[2].plano);
planos.push_back(b1.predio[3].plano);
planos.push_back(b1.predio[4].plano);
city.push_back(b1);
}