amethyst / amethyst/rustrogueliketutorial

C30 DLASymmetry::Both is incorrectly calculated

Offen
#130 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
970
Forks
166
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.