- for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) _polygons[n]->draw(window);
- for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) _polygons[n]->draw_contours(window);
+ for(int n = 0; n < _nb_polygons; n++) {
+ if(_polygons[n]) {
+ _polygons[n]->draw(window);
+ }
+ }
+
+ for(int n = 0; n < _nb_polygons; n++) {
+ if(_polygons[n]) {
+ _polygons[n]->draw_contours(window);
+ }
+ }
+}
+#endif
+
+#ifdef CAIRO_SUPPORT
+void Universe::draw(Canvas *canvas) {
+ for(int n = 0; n < _nb_polygons; n++) {
+ if(_polygons[n]) {
+ _polygons[n]->draw(canvas);
+ }
+ }
+
+ for(int n = 0; n < _nb_polygons; n++) {
+ if(_polygons[n]) {
+ _polygons[n]->draw_contours(canvas);
+ }
+ }
+}
+#endif
+
+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);