retina.set_location(manipulator.hand_x(), manipulator.hand_y());
SimpleWindow *window_main = 0, *window_brain = 0;
+ int window_main_fd = -1;
+
#ifdef CAIRO_SUPPORT
- cairo_t *cairo_cr = 0;
+ cairo_t *window_main_cairo_cr = 0;
#endif
- int window_main_fd = -1;
-
MapConcatener sensory_map(2);
sensory_map.add_map(&retina);
sensory_map.add_map(&manipulator);
window_main_fd = window_main->file_descriptor();
window_main->map();
#ifdef CAIRO_SUPPORT
- cairo_cr = window_main->get_cairo_context_resource();
+ window_main_cairo_cr = window_main->get_cairo_context_resource();
#endif
cout << "When the main window has the focus, press `q' to quit and click and drag to move" << endl
<< "objects." << endl;
window_main->color(0.0, 0.0, 0.0);
window_main->color(1.0, 1.0, 1.0);
window_main->fill();
- task->draw(window_main);
#ifdef CAIRO_SUPPORT
- universe.draw(cairo_cr);
+ universe.draw(window_main_cairo_cr);
#else
universe.draw(window_main);
#endif
+ task->draw(window_main);
manipulator.draw_on_universe(window_main);
retina.draw_on_universe(window_main);
int random_action();
-// void force_grab(Universe *universe, scalar_t x, scalar_t y);
+ // void force_grab(Universe *universe, scalar_t x, scalar_t y);
void force_move(scalar_t x, scalar_t y);
void force_release();
};
x[n] = int(_x[n]);
y[n] = int(_y[n]);
}
- // window->color(0.0, 0.0, 0.0);
- window->color(1.0, 1.0, 1.0);
+ window->color(0.0, 0.0, 0.0);
+ // window->color(1.0, 1.0, 1.0);
for(int n = 0; n < _nb_vertices; n++) {
window->draw_line(x[n], y[n], x[(n+1)%_nb_vertices], y[(n+1)%_nb_vertices]);
}
void Polygon::draw_contours(cairo_t* context_resource) {
cairo_set_line_width(context_resource, 1.0);
- // cairo_set_source_rgb (context_resource, 0.0, 0.0, 0.0);
- cairo_set_source_rgb (context_resource, 1.0, 1.0, 1.0);
+ cairo_set_source_rgb (context_resource, 0.0, 0.0, 0.0);
+ // cairo_set_source_rgb (context_resource, 1.0, 1.0, 1.0);
cairo_move_to(context_resource, _x[0], _y[0]);
for(int n = 0; n < _nb_vertices; n++) {
cairo_line_to(context_resource, _x[n], _y[n]);
#include "universe.h"
Universe::Universe(int nb_max_polygons,
- scalar_t xmax, scalar_t ymax) : _xmax(xmax), _ymax(ymax),
+ scalar_t width, scalar_t height) : _width(width), _height(height),
_nb_max_polygons(nb_max_polygons), _nb_polygons(0) {
_polygons = new Polygon *[_nb_max_polygons];
for(int n = 0; n < _nb_max_polygons; n++) _polygons[n] = 0;
bool result = false;
apply_collision_forces(dt);
for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) {
- _polygons[n]->apply_border_forces(dt, _xmax, _ymax);
+ _polygons[n]->apply_border_forces(dt, _width, _height);
result |= _polygons[n]->update(dt);
}
return result;
using namespace std;
class Universe {
- scalar_t _xmax, _ymax;
+ scalar_t _width, _height;
public:
int _nb_max_polygons, _nb_polygons;
Polygon **_polygons;
- inline scalar_t width() { return _xmax; }
- inline scalar_t height() { return _ymax; }
+ inline scalar_t width() { return _width; }
+ inline scalar_t height() { return _height; }
- Universe(int nb_max_polygons, scalar_t xmax, scalar_t ymax);
+ Universe(int nb_max_polygons, scalar_t width, scalar_t height);
// The destructor deletes all the added polygons
~Universe();