Stone_Development/createCube.cpp
2025-11-23 13:31:24 +01:00

72 lines
1.8 KiB
C++

#include "createCube.h"
#include <iostream>
std::vector<Vec3> createCubes(int pairs)
{
//zwei bis zehn paare
if (pairs >10 || pairs <= 1)
{
// 6 Karten-Positionen im 3x2 Raster
return {{-2, 0, -2}, {0, 0, -2}, {2, 0, -2},{-2, 0, 0}, {0, 0, 0}, {2, 0, 0}}; // Default field
}
std::vector<int> fieldSize = calculateFieldSize(pairs);
std::vector<Vec3> cubePositions;
//std::cout<<(fieldSize[0])<<std::endl;
//std::cout<<(fieldSize[1]) <<std::endl;
int start_x = (fieldSize[0]/2) * -2;
int start_y = (fieldSize[1]/2) * -2;
for (int i = 0; i < fieldSize[0]; i++)
{
for (int j = 0; j < fieldSize[1]; j++)
{
cubePositions.push_back(Vec3(start_x + 2*i, 0, start_y + 2*j));
}
}
return cubePositions;
};
std::vector<int> calculateFieldSize(int pairs)
{
std::vector<int> best_field = {pairs, 2};
int cube_count = pairs *2;
int test_count = 3;
while (test_count < pairs)
{
for (int i = 3; i < pairs; i++)
{
if (test_count * i == cube_count && test_count + i < best_field[0] + best_field[1])
{
best_field[1] = test_count;
best_field[0] = i;
}
}
test_count++;
}
return best_field;
};
std::vector<Color> getColors(int pairs)
{
if (pairs >10) pairs = 10;
std::vector<Color> returnColors;
Color colors[] = {
{230, 25, 75, 255}, // Red
{60, 180, 75, 255}, // Green
{0, 130, 200, 255}, // Blue
{245, 130, 48, 255}, // Orange
{145, 30, 180, 255}, // Purple
{255, 225, 25, 255}, // Yellow
{70, 240, 240, 255}, // Cyan
{240, 50, 230, 255}, // Magenta
{210, 245, 60, 255}, // Lime
{250, 190, 190, 255} // Pink
};
for (int i = 0; i < pairs; i++)
{
returnColors.push_back(colors[i]);
}
std::cout << returnColors.size() << std::endl;
return returnColors;
};