}
Universe::~Universe() {
- for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) delete _polygons[n];
+ clear();
delete[] _polygons;
}
-void Universe::initialize(Polygon *p) {
+void Universe::initialize_polygon(Polygon *p) {
p->initialize(_nb_max_polygons);
}
return 0;
}
+#ifdef XFIG_SUPPORT
void Universe::print_xfig(XFigTracer *tracer) {
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
}
}
}
+#endif
#ifdef X11_SUPPORT
void Universe::draw(SimpleWindow *window) {
}
}
+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];