X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=flatland.git;a=blobdiff_plain;f=universe.cc;h=ad3ebf7356cfa3c6a2d425e36102581132b65923;hp=32e6f335bb7a2c9203e0cdd4ca3783c5220fcdad;hb=90d1c5704c30e7f1d041e32eacbc2893741110e1;hpb=1f91ec6f67da83525115f49dcc7d535ff2e71ef0 diff --git a/universe.cc b/universe.cc index 32e6f33..ad3ebf7 100644 --- a/universe.cc +++ b/universe.cc @@ -159,6 +159,14 @@ void Universe::draw(Canvas *canvas) { } } +void Universe::apply_gravity(scalar_t dt, scalar_t fx, scalar_t fy) { + for(int n = 0; n < _nb_polygons; n++) + if(_polygons[n]) + _polygons[n]->apply_force(dt, + _polygons[n]->_center_x, _polygons[n]->_center_y, + fx, fy); +} + void Universe::apply_collision_forces(scalar_t dt) { const int nb_axis = 2; int nb_collision[_nb_polygons * _nb_polygons];