void Game::Init() { // Add random mVertices for(int i = 0; i < AMOUNT; i++) { mVertices.push_back( float2( Rand(SCRWIDTH), Rand(SCRHEIGHT) ) ); } float2 center; int radius; for(int i = 0; i < mVertices.size(); i++) for(int j = 0; j < mVertices.size(); j++) for(int k = 0; k < mVertices.size(); k++) if(i != j && i != k && j != k) { bool valid = true; // A valid triangle? GetCircle(mVertices[i], mVertices[j], mVertices[k], center, radius); // For drawing the circle mCenter.push_back(center); mRadius.push_back(radius); for(int l = 0; l < mVertices.size(); l++) if(l != i) { // Check if it is a valid triangle by checking for points inside the circle float d = (mVertices[l].x - center.x) * (mVertices[l].x - center.x) + (mVertices[l].y - center.y) * (mVertices[l].y - center.y); if(sqrtf(d) < radius) { valid = false; break; } } // Not a valid triangle if(!valid) continue; // Valid triangle else { std::vector triangle; triangle.push_back(mVertices[i]); triangle.push_back(mVertices[j]); triangle.push_back(mVertices[k]); mConnectionPoints.push_back(triangle); } } }