I am currently able to build nice beautiful circles like this:
void resetPlanetVertexes (sf::VertexArray* planet, sf::Vector2f* center, float size, sf::Color* color)
{
int i;
int count = (int)(planet->getVertexCount());
for (i = 1; i < count-1; i ++) {
float angle = ((float)(i) / (float)(count-2) * 360.f) * 3.14f / 180.f;
((*planet)[i]).position = *center + sf::Vector2f(
(float)(std::cos(angle) * size),
(float)(std::sin(angle) * size)
);
((*planet)[i]).color = *color;
}
((*planet)[count-1]).position = ((*planet)[1]).position;
((*planet)[count-1]).color = ((*planet)[1]).color;
}
void buildPlanet (sf::VertexArray* planet, sf::RenderWindow* window)
{
int width = (int)(window->getSize().x);
int height = (int)(window->getSize().y);
sf::Color planetcolor = getPlanetColor();
float size = getPlanetSize();
std::cout << "Planet Size: " << size << std::endl;
sf::Vertex* planetcenter = &((*planet)[0]);
planetcenter->position = sf::Vector2f
((float)(rand() % (width + (PLANET_BORDER<<1)))-PLANET_BORDER,
(float)(rand() % (height + (PLANET_BORDER<<1)))-PLANET_BORDER);
planetcenter->color = planetcolor;
resetPlanetVertexes(planet, &(planetcenter->position), size, &(planetcenter->color));
}
However, they look obviously flat and not like planets at all. They look like someone cut perfect circles out of construction paper.
If we look at a planet like Neptune, we see that the bottom right fades towards black, while the top left fades towards a slightly brighter color to create the appearance of a sphere and not a circle.
I think I can probably do something with the coloring to darken or lighten it. (Not sure the best way to do that.) Do I really have to modify each of the three rgb values to lighten/darken a colour?
I also thought there might be a way to build a 3D planet or something similar to that as well.
I want to make each planet random and different so I don't want to use a standard sprite.