Cosmetics + started to add support for cairo drawing to eventually replace the X...
[universe.git] / art.cc
diff --git a/art.cc b/art.cc
index d71f266..b2e8af9 100644 (file)
--- 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 <iostream>
 #include <fstream>
 #include <cmath>
 #include <iostream>
 #include <fstream>
 #include <cmath>
@@ -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 };
     nice(19);
     scalar_t xs[] = { -28,  28,  28, -28 };
     scalar_t ys[] = { -28, -28,  28,  28 };
-    Universe universe(1000);
     int w = 20, h = 20;
     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);
     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);
     }
 
       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++) {
     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);
 //       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]);
     }
 
       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;
       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);
 
     ofstream os("/tmp/universe.fig");
     universe.print_fig(os);