X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=universe.h;h=a48a3ba6b1dc8446b166cd45b22f0a407fe5479b;hb=4e550948439a6cd6f318c230ed53adfabcd2ba43;hp=3775daf19cde894f5e335181e4cc1252fd540bde;hpb=ba46b057f3e2613a86f2dea7fa8022990482c735;p=universe.git diff --git a/universe.h b/universe.h index 3775daf..a48a3ba 100644 --- a/universe.h +++ b/universe.h @@ -1,19 +1,6 @@ -//////////////////////////////////////////////////////////////////////////////// -// This program is free software; you can redistribute it and/or // -// modify it under the terms of the GNU General Public License // -// version 2 as published by the Free Software Foundation. // -// // -// This program is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// General Public License for more details. // -// // -// Written and (C) by François Fleuret // -// Contact for comments & bug reports // -//////////////////////////////////////////////////////////////////////////////// - -// $Id: universe.h,v 1.21 2006-12-17 19:22:19 fleuret Exp $ +// Written and (C) by Francois Fleuret +// Contact for comments & bug reports #ifndef UNIVERSE_H #define UNIVERSE_H @@ -21,32 +8,51 @@ #include #include -using namespace std; - #include "misc.h" -#include "simple_window.h" +#include "canvas.h" #include "polygon.h" +#ifdef X11_SUPPORT +#include "simple_window.h" +#endif + +using namespace std; + class Universe { - scalar_t _xmax, _ymax; + scalar_t _width, _height; public: int _nb_max_polygons, _nb_polygons; Polygon **_polygons; - Universe(int nb_max_polygons, scalar_t xmax, scalar_t ymax); + + inline scalar_t width() { return _width; } + inline scalar_t height() { return _height; } + + Universe(int nb_max_polygons, scalar_t width, scalar_t height); // The destructor deletes all the added polygons ~Universe(); - void initialize(Polygon *p); + + void initialize_polygon(Polygon *p); void clear(); void add_polygon(Polygon *p); bool collide(Polygon *p); + // Compute collisions between projections of the polygons on a few // axis to speed up the computation void compute_pseudo_collisions(int nb_axis, int *nb_colliding_axis); void apply_collision_forces(scalar_t dt); bool update(scalar_t dt); + Polygon *pick_polygon(scalar_t x, scalar_t y); - void print_fig(ostream &os); + +#ifdef XFIG_SUPPORT + void print_xfig(XFigTracer *tracer); +#endif + +#ifdef X11_SUPPORT void draw(SimpleWindow *window); +#endif + + void draw(Canvas *canvas); }; #endif