X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=art.cc;h=b2e8af981b04273b1ffa808bc4d5a370435c3cee;hb=8697ab57c9138aa2bb1657a971e4c2cc5e4a1606;hp=d71f266dd27581c82276aaf0ff583a430493fa1b;hpb=ba46b057f3e2613a86f2dea7fa8022990482c735;p=universe.git diff --git a/art.cc b/art.cc index d71f266..b2e8af9 100644 --- a/art.cc +++ b/art.cc @@ -1,3 +1,5 @@ +// -*- 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 #include #include @@ -22,17 +24,18 @@ int main(int argc, char **argv) { 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++) { @@ -51,18 +54,21 @@ int main(int argc, char **argv) { // 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);