amethyst / amethyst/rustrogueliketutorial

C30 DLASymmetry::Both is incorrectly calculated

Open
#130 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
970
Forks
166
PR merge metrics
No merged PRs in 30d

Description

```rust
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:
```rust
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);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.