+// -*- compile-command:"g++ -lX11 -Wall -g -O3 -o art misc.o simple_window.o universe.o polygon.o map.o task.o retina.o manipulator.o approximer.o intelligence.o art.cc -L/usr/X11R6/lib/"; -*-
+
#include <iostream>
#include <fstream>
#include <cmath>
nice(19);
scalar_t xs[] = { -28, 28, 28, -28 };
scalar_t ys[] = { -28, -28, 28, 28 };
- Universe universe(1000);
int w = 20, h = 20;
+ Universe universe(w * h * 10, w * 60, h * 60);
Polygon *p;
for(int x = 0; x < w; x++) for(int y = 0; y < h; y++) {
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);