2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
16 #include "simple_window.h"
22 scalar_t _width, _height;
24 int _nb_max_polygons, _nb_polygons;
27 inline scalar_t width() { return _width; }
28 inline scalar_t height() { return _height; }
30 Universe(int nb_max_polygons, scalar_t width, scalar_t height);
31 // The destructor deletes all the added polygons
34 void initialize_polygon(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_gravity(scalar_t dt, scalar_t fx, scalar_t fy);
43 void apply_collision_forces(scalar_t dt);
44 bool update(scalar_t dt);
46 Polygon *pick_polygon(scalar_t x, scalar_t y);
49 void print_xfig(XFigTracer *tracer);
53 void draw(SimpleWindow *window);
57 void draw(Canvas *canvas);