Skip to content
Snippets Groups Projects
Commit fe8f4d02 authored by Florian Burgener's avatar Florian Burgener
Browse files

Scaled object name drawing distance

parent 57f0ea8f
No related branches found
No related tags found
No related merge requests found
...@@ -63,5 +63,11 @@ void celestial_object_draw_name(CelestialObject *object, Vector2 reference_frame ...@@ -63,5 +63,11 @@ void celestial_object_draw_name(CelestialObject *object, Vector2 reference_frame
return; 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)));
} }
...@@ -35,27 +35,30 @@ const double EARTH_SEMI_MAJOR_AXIS = 149.598262 * 1E9; ...@@ -35,27 +35,30 @@ const double EARTH_SEMI_MAJOR_AXIS = 149.598262 * 1E9;
const double MARS_SEMI_MAJOR_AXIS = 227.943824 * 1E9; const double MARS_SEMI_MAJOR_AXIS = 227.943824 * 1E9;
PlanetarySystem *planetary_system_create() { PlanetarySystem *planetary_system_create() {
PlanetarySystem *ps = (PlanetarySystem *)malloc(sizeof(PlanetarySystem)); PlanetarySystem *system = (PlanetarySystem *)malloc(sizeof(PlanetarySystem));
ps->objects_length = 9; system->objects_length = 9;
ps->objects = (CelestialObject **)malloc(sizeof(PlanetarySystem *) * ps->objects_length); system->objects = (CelestialObject **)malloc(sizeof(PlanetarySystem *) * system->objects_length);
ps->zoom_factor = 1; system->zoom_factor = 1;
ps->reference_frame_object_index = 0; 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"}; 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 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 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 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}; 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]); 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; system->objects[5]->current_position.x += system->objects[3]->current_position.x;
return ps; return system;
} }
CelestialObject *planetary_system_get_star(PlanetarySystem *planetary_system) { CelestialObject *planetary_system_get_star(PlanetarySystem *planetary_system) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment