amethyst / rustrogueliketutorial

Roguelike Tutorial in Rust - using RLTK
MIT License
898 stars 156 forks source link

C30 DLASymmetry::Both is incorrectly calculated #130

Open smokku opened 4 years ago

smokku commented 4 years ago
let dist_x = i32::abs(center_x - x);
let dist_y = i32::abs(center_y - y);
self.apply_paint(center_x + dist_x, y);
self.apply_paint(center_x - dist_x, y);
self.apply_paint(x, center_y + dist_y);
self.apply_paint(x, center_y - dist_y);

This will give only 3 symetric points, as one of the calculations center_x + dist_x or center_x - dist_x will be the same as x (or center_y + dist_y/center_y - dist_y will be the same as y).

Correct formula is:

self.apply_paint(center_x + dist_x, center_y + dist_y);
self.apply_paint(center_x - dist_x, center_y - dist_y);
self.apply_paint(center_x - dist_x, center_y + dist_y);
self.apply_paint(center_x + dist_x, center_y - dist_y);
smokku commented 4 years ago

This is visible in C31 map:

drunkard symmetry