2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
18 #include "simple_window.h"
22 scalar_t _xmax, _ymax;
24 int _nb_max_polygons, _nb_polygons;
27 inline scalar_t width() { return _xmax; }
28 inline scalar_t height() { return _ymax; }
30 Universe(int nb_max_polygons, scalar_t xmax, scalar_t ymax);
31 // The destructor deletes all the added polygons
34 void initialize(Polygon *p);
36 void add_polygon(Polygon *p);
37 bool collide(Polygon *p);
39 // Compute collisions between projections of the polygons on a few
40 // axis to speed up the computation
41 void compute_pseudo_collisions(int nb_axis, int *nb_colliding_axis);
42 void apply_collision_forces(scalar_t dt);
43 bool update(scalar_t dt);
45 Polygon *pick_polygon(scalar_t x, scalar_t y);
47 void print_xfig(XFigTracer *tracer);
48 void draw(SimpleWindow *window);
51 void draw(cairo_t *context_resource);