Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AddRandomSatellite(int id) {
- if (PlanetOption temp = GetPlanet(id))
- {
- Planet parent = temp;
- const int angles = (360 * 8);
- const int steps = 1000;
- const float min_dis = 500.f;
- const float max_dis = 10000.f;
- const float dif_dis = max_dis - min_dis;
- const float min_prop = 0.05;
- const float max_prop = 0.5f;
- const float dif_prop = max_prop - min_prop;
- const int mas_step = 1000;
- float new_mass = min_prop + float(rand() % mas_step) / mas_step * dif_prop * (*parent.mass);
- float angle = float(rand() % angles) / float(angles);
- float magni = (min_dis + float(rand() % steps) / float(steps) * dif_dis) * (*parent.mass);
- float new_x = (*parent.x) + cos(angle * 2.f * pi) * magni;
- float new_y = (*parent.y) + sin(angle * 2.f * pi) * magni;
- float new_dx;
- float new_dy;
- if (rand() & 1)
- {
- new_dx = (*parent.dx) + cos(angle * 2.f * pi + pi * 0.5f) * 2.f;
- new_dy = (*parent.dy) + sin(angle * 2.f * pi + pi * 0.5f) * 2.f;
- }
- else
- {
- new_dx = (*parent.dx) + cos(angle * 2.f * pi + pi * 0.5f) * 2.f;
- new_dy = (*parent.dy) + sin(angle * 2.f * pi + pi * 0.5f) * 2.f;
- }
- AddPlanet(new_x, new_y, new_dx, new_dy, new_mass);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement