From 8697ab57c9138aa2bb1657a971e4c2cc5e4a1606 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Mon, 29 Aug 2016 09:16:32 +0200 Subject: [PATCH] Update. --- main.cc | 12 ++++++------ manipulator.h | 2 +- polygon.cc | 8 ++++---- universe.cc | 4 ++-- universe.h | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/main.cc b/main.cc index 1d618d8..bbea852 100644 --- a/main.cc +++ b/main.cc @@ -218,12 +218,12 @@ int main(int argc, char **argv) { 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); @@ -255,7 +255,7 @@ int main(int argc, char **argv) { 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; @@ -347,14 +347,14 @@ int main(int argc, char **argv) { 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); diff --git a/manipulator.h b/manipulator.h index 20e8b92..cd44a6d 100644 --- a/manipulator.h +++ b/manipulator.h @@ -57,7 +57,7 @@ public: 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(); }; diff --git a/polygon.cc b/polygon.cc index 1d2b3dd..e121e2c 100644 --- a/polygon.cc +++ b/polygon.cc @@ -73,8 +73,8 @@ void Polygon::draw_contours(SimpleWindow *window) { 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]); } @@ -96,8 +96,8 @@ void Polygon::draw(cairo_t* context_resource) { 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]); diff --git a/universe.cc b/universe.cc index b0c28dd..92b7a1b 100644 --- a/universe.cc +++ b/universe.cc @@ -7,7 +7,7 @@ #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; @@ -104,7 +104,7 @@ bool Universe::update(scalar_t dt) { 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; diff --git a/universe.h b/universe.h index f87f112..a9f55d7 100644 --- a/universe.h +++ b/universe.h @@ -22,15 +22,15 @@ 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(); -- 2.39.5