@@ -41,7 +41,7 @@ std::vector<std::string> split(std::string &str) {
4141
4242class Display {
4343 int height;
44- typedef std::pair<int , int > Point; // x, y
44+ typedef std::pair<double , double > Point; // x, y
4545 #define _x first
4646 #define _y second
4747 std::vector<std::pair<Point, Point> > lines;
@@ -76,8 +76,8 @@ class Display {
7676
7777 void action_forward (int len) {
7878 Point next = current;
79- next._x += std::round ( len*std::cos (angle) );
80- next._y -= std::round ( len*std::sin (angle) ); // graphics and maths y coordinates are flipped
79+ next._x += len*std::cos (angle);
80+ next._y -= len*std::sin (angle); // graphics and maths y coordinates are flipped
8181 action_move (next);
8282 }
8383
@@ -236,8 +236,10 @@ class Display {
236236 std::graphics::setcolor (BLACK);
237237
238238 for (const auto &line: lines) {
239- std::graphics::line (line.first .first , line.first .second ,
240- line.second .first , line.second .second );
239+ std::graphics::line (std::round (line.first .first ),
240+ std::round (line.first .second ),
241+ std::round (line.second .first ),
242+ std::round (line.second .second ));
241243 }
242244
243245 if (turtle_visiblity) {
@@ -250,10 +252,26 @@ class Display {
250252 Point e2 = at_distance (current, turtle_len, angle + M_PI*7 /6 );
251253 Point eb = at_distance (current, turtle_len/2 , angle + M_PI);
252254
253- std::graphics::line (e1 ._x , e1 ._y , current._x , current._y );
254- std::graphics::line (e1 ._x , e1 ._y , eb._x , eb._y );
255- std::graphics::line (e2 ._x , e2 ._y , current._x , current._y );
256- std::graphics::line (e2 ._x , e2 ._y , eb._x , eb._y );
255+ std::graphics::line (
256+ std::round (e1 ._x ),
257+ std::round (e1 ._y ),
258+ std::round (current._x ),
259+ std::round (current._y ));
260+ std::graphics::line (
261+ std::round (e1 ._x ),
262+ std::round (e1 ._y ),
263+ std::round (eb._x ),
264+ std::round (eb._y ));
265+ std::graphics::line (
266+ std::round (e2 ._x ),
267+ std::round (e2 ._y ),
268+ std::round (current._x ),
269+ std::round (current._y ));
270+ std::graphics::line (
271+ std::round (e2 ._x ),
272+ std::round (e2 ._y ),
273+ std::round (eb._x ),
274+ std::round (eb._y ));
257275 }
258276
259277 std::graphics::graphflush ();
@@ -341,7 +359,7 @@ class Console {
341359 }
342360 const int char_per_line = (WINDOW_WIDTH-2 *border)/text_width;
343361 for (std::size_t i = 0 ; i < line_count; i++) {
344- int _y = y_offset+(i+1 )*text_height;
362+ int _y = y_offset+(i+1 )*text_height ;
345363 int _x = border;
346364 int str_start = char_per_line*i;
347365 int str_end = char_per_line*(i+1 ); // excluding
0 commit comments