Skip to content

Commit

Permalink
circularise celestial indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
thombruce committed Oct 9, 2023
1 parent 2a8b411 commit 1bd786b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Indicators now appear in circle close to player ship for better readability
- Renamed AppState to GameState for better clarity
- Improved readability and versatility of assets with bevy_asset_loader
- Moved menu music loading from main to menu module
Expand Down
46 changes: 26 additions & 20 deletions src/hud/indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,35 @@ fn indicators_system(
let bounds = bounds_query.single().size();
let extents = Vec2::from(bounds / 2.0);

/* Circular indicators */
let normalized = real_to_entity.normalize() * 200.0;
indicator_style.left = Val::Px(extents.x + normalized.x);
indicator_style.top = Val::Px(extents.y - normalized.y);

/* Edge-of-screen indicators */
// reposition indicator relative to the direction of the entity
// we're using the non-normalized real_to_entity for this in order
// to get the actual size of the player-entity vector's x and y values
match real_to_entity.x > 0. {
true => {
indicator_style.right = Val::Px((extents.x - real_to_entity.x).max(0.));
indicator_style.left = Val::Auto;
}
false => {
indicator_style.left = Val::Px((extents.x + real_to_entity.x).max(0.));
indicator_style.right = Val::Auto;
}
}
match real_to_entity.y > 0. {
true => {
indicator_style.top = Val::Px((extents.y - real_to_entity.y).max(0.));
indicator_style.bottom = Val::Auto;
}
false => {
indicator_style.bottom = Val::Px((extents.y + real_to_entity.y).max(0.));
indicator_style.top = Val::Auto;
}
}
// match real_to_entity.x > 0. {
// true => {
// indicator_style.right = Val::Px((extents.x - real_to_entity.x).max(0.));
// indicator_style.left = Val::Auto;
// }
// false => {
// indicator_style.left = Val::Px((extents.x + real_to_entity.x).max(0.));
// indicator_style.right = Val::Auto;
// }
// }
// match real_to_entity.y > 0. {
// true => {
// indicator_style.top = Val::Px((extents.y - real_to_entity.y).max(0.));
// indicator_style.bottom = Val::Auto;
// }
// false => {
// indicator_style.bottom = Val::Px((extents.y + real_to_entity.y).max(0.));
// indicator_style.top = Val::Auto;
// }
// }
}
}
}

0 comments on commit 1bd786b

Please sign in to comment.