void GobPlanet::calculate () { STACKTRACE; SpaceObject::calculate(); SpaceObject *o; Query a; a.begin(this, OBJECT_LAYERS, gravity_range); for (;a.currento;a.next()) { o = a.currento; if (o->mass > 0) { bool roswell = false; for (int i = 0; i < gobgame->gobplayers; i++) { if (o->ship == gobgame->gobplayer[i]->ship && gobgame->gobplayer[i]->upgrade_list[UpgradeIndex::roswelldevice]->num) roswell = true; } if (roswell) continue; double r = distance(o); if (r < gravity_mindist) r = gravity_mindist; double sr = 1; //gravity_power rounded up here if (gravity_power < 0) { r /= 40 * 5; for (int i = 0; i < -gravity_power; i += 1) sr *= r; o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force / sr, MAX_SPEED); } else { r = 1 - r/gravity_range; for (int i = 0; i < gravity_power; i += 1) sr *= r; o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force * sr, MAX_SPEED); } } } }
void Sun::calculate() { STACKTRACE; SpaceObject::calculate(); SpaceObject *o; Query a; a.begin(this, OBJECT_LAYERS, gravity_range); for (;a.currento;a.next()) { o = a.currento; if (o->mass > 0) { double r = distance(o); if (r < gravity_mindist) r = gravity_mindist; double sr = 1; //gravity_power truncated here if (gravity_power > 0) { r /= 40 * 4; for (int i = 0; i < gravity_power; i += 1) sr *= r; o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force / sr, MAX_SPEED); } else { r = 1 - r/gravity_range; for (int i = 0; i < -gravity_power; i += 1) sr *= r; o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force * sr, MAX_SPEED); } } } /*for (;a.currento;a.next()) { o = a.currento; if (o->mass > 0) { double r = distance(o); if (r < gravity_mindist) r = gravity_mindist; r = 1 - r / gravity_range; o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force * r / 40000., GLOBAL_MAXSPEED); } }*/ // return; }