p = new Polygon(1.0, 1.0, 1.0, 0.0, xs, ys, 4);
p->set_position(30 + 60 * x, 30 + 60 * y, 0);
p->set_speed(0, 0, 0);
+ universe.initialize(p);
universe.add_polygon(p);
}
- const int nb_projectiles = 15;
+ const int nb_projectiles = 1;
Polygon *projectiles[nb_projectiles];
for(int b = 0; b < nb_projectiles; b++) {
// projectiles[b]->set_position(67 + 60 * 6, -60, 0);
projectiles[b]->set_speed(0, 0, 0);
+ universe.initialize(projectiles[b]);
universe.add_polygon(projectiles[b]);
}
- for(int n = 0; n < 20000; n++) {
+ scalar_t dt = 0.01;
+
+ for(int n = 0; n < 1000; n++) {
if(n%100 == 0) cout << n << endl;
- for(int b = 0; b < nb_projectiles; b++)
- projectiles[b]->apply_force(0.01, p->_center_x, p->_center_y, 1, 5);
-// projectiles[b]->apply_force(0.01, p->_center_x, p->_center_y, 1, 10);
- universe.update(0.01);
+ for(int b = 0; b < nb_projectiles; b++) {
+ projectiles[b]->apply_force(dt, p->_center_x, p->_center_y, 1, 5);
+ }
+ universe.update(dt);
}
- for(int n = 0; n < 10000; n++) universe.update(0.01);
+ for(int n = 0; n < 10000; n++) universe.update(dt);
ofstream os("/tmp/universe.fig");
universe.print_fig(os);
}
void Polygon::print_fig(ostream &os) {
- os << "2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
+ // os << "2 3 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
+ int c;
+ do { c = int(drand48() * 32); } while(c == 7);
+ os << "2 3 0 1 0 6 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
+ // os << "2 3 0 0 0 " << c << " 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
+ // os << "2 3 0 2 7 " << c << " 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl;
os << " ";
for(int n = 0; n < _nb_vertices; n++) os << " " << int(_x[n]*10) << " " << int(_y[n]*10);
os << " " << int(_x[0]*10) << " " << int(_y[0]*10);