diff --git a/CelestialObject.c b/CelestialObject.c index be5a585f49afd604d922e3b6e743c65fa9ae7e01..7f51146a9250a8bedf0c7a3dd57f6f663ee8c45e 100644 --- a/CelestialObject.c +++ b/CelestialObject.c @@ -63,5 +63,11 @@ void celestial_object_draw_name(CelestialObject *object, Vector2 reference_frame return; } - draw_text(object->name, vector2_add(scaled_position, vector2_create(object->drawing_disc_radius + 8, 7))); + uint32_t drawing_disc_radius = object->drawing_disc_radius; + + if (zoom_factor < 1) { + drawing_disc_radius *= zoom_factor; + } + + draw_text(object->name, vector2_add(scaled_position, vector2_create(drawing_disc_radius + 8, 7))); } diff --git a/PlanetarySystem.c b/PlanetarySystem.c index 5e244b763f315afcbaf43dcb07d0306310e8fc2d..3418957a16b34597a8739f6a23078f113816279e 100644 --- a/PlanetarySystem.c +++ b/PlanetarySystem.c @@ -35,27 +35,30 @@ const double EARTH_SEMI_MAJOR_AXIS = 149.598262 * 1E9; const double MARS_SEMI_MAJOR_AXIS = 227.943824 * 1E9; PlanetarySystem *planetary_system_create() { - PlanetarySystem *ps = (PlanetarySystem *)malloc(sizeof(PlanetarySystem)); + PlanetarySystem *system = (PlanetarySystem *)malloc(sizeof(PlanetarySystem)); - ps->objects_length = 9; - ps->objects = (CelestialObject **)malloc(sizeof(PlanetarySystem *) * ps->objects_length); - ps->zoom_factor = 1; - ps->reference_frame_object_index = 0; + system->objects_length = 9; + system->objects = (CelestialObject **)malloc(sizeof(PlanetarySystem *) * system->objects_length); + system->zoom_factor = 1; + system->reference_frame_object_index = 0; + // The moon is initialized with real life values. + // Naboo, Jupiter and Endor are all fake planets. + // Note that Jupitaire follows the orbit of Jupyter but its mass is different. char names[][100] = {"Sun", "Mercury", "Venus", "Earth", "Mars", "Moon", "Naboo", "Jupitaire", "Endor"}; double masses[] = {SUN_MASS, MERCURY_MASS, VENUS_MASS, EARTH_MASS, MARS_MASS, 7.34767309 * 1E22, 1000000, 1898.6 * 1E10, 1E23, 100 * 1E9}; double semi_major_axes[] = {0, MERCURY_SEMI_MAJOR_AXIS, VENUS_SEMI_MAJOR_AXIS, EARTH_SEMI_MAJOR_AXIS, MARS_SEMI_MAJOR_AXIS, 384.399 * 1E6, 800.598262 * 1E9, 778.340821 * 1E9, 100 * 1E9}; double eccentricities[] = {0, MERCURY_ECCENTRICITY, VENUS_ECCENTRICITY, EARTH_ECCENTRICITY, MARS_ECCENTRICITY, 0.0549, 0.8, 0.04839266, 0.34}; double disc_radiuses[] = {50, 10, 20, 10, 12, 5, 12, 12, 12}; - int32_t colors[] = {0xFFFFFF, 0xDBCECA, 0x8B7D82, 0x6b93d6, 0xBC2732, 0x7D7B67, 0x005500, 0x005500, 0x005500}; + int32_t colors[] = {0xFFCC33, 0xDBCECA, 0x8B7D82, 0x6b93d6, 0xBC2732, 0x7D7B67, 0x007700, 0x007700, 0x007700}; - for (int32_t i = 0; i < ps->objects_length; i += 1) { + for (int32_t i = 0; i < system->objects_length; i += 1) { CelestialObject *object = celestial_object_create(names[i], masses[i], semi_major_axes[i], eccentricities[i], disc_radiuses[i], colors[i]); - ps->objects[i] = object; + system->objects[i] = object; } - ps->objects[5]->current_position.x += ps->objects[3]->current_position.x; - return ps; + system->objects[5]->current_position.x += system->objects[3]->current_position.x; + return system; } CelestialObject *planetary_system_get_star(PlanetarySystem *planetary_system) {