Skip to content

Commit

Permalink
cursor position update
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Jul 12, 2023
1 parent 38ffc51 commit af8095e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Bumped `glam` dependency to 0.24
* Bumped `bevy_reflect` optional dependency to 0.11
* Bumped `bevy` dev dependency to 0.11
* Renamed `fov` example to `field_of_view`

## 0.8.0

Expand Down
2 changes: 1 addition & 1 deletion examples/a_star.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let hex_pos = grid.layout.world_pos_to_hex(pos);
let Some(entity) = grid.entities.get(&hex_pos).copied() else { return };
if buttons.just_pressed(MouseButton::Left) {
Expand Down
2 changes: 1 addition & 1 deletion examples/field_of_movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let hex_pos = grid.layout.world_pos_to_hex(pos);

if hex_pos == *current {
Expand Down
2 changes: 1 addition & 1 deletion examples/field_of_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let hex_pos = grid.layout.world_pos_to_hex(pos);
let Some(entity) = grid.entities.get(&hex_pos).copied() else { return };
if buttons.just_pressed(MouseButton::Left) {
Expand Down
2 changes: 1 addition & 1 deletion examples/hex_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let coord = map.layout.world_pos_to_hex(pos);
if let Some(entity) = map.entities.get(&coord).copied() {
if coord == highlighted_hexes.selected {
Expand Down
2 changes: 1 addition & 1 deletion examples/scroll_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let hex_pos = grid.layout.world_pos_to_hex(pos);
for h in hex_pos.range(grid.bounds.radius) {
let wrapped = grid.bounds.wrap(h);
Expand Down
2 changes: 1 addition & 1 deletion examples/wrap_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn handle_input(
) {
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = pos - Vec2::new(window.width(), window.height()) / 2.0;
let pos = Vec2::new(pos.x - window.width() / 2.0, window.height() / 2.0 - pos.y);
let hex_pos = grid.layout.world_pos_to_hex(pos);
if hex_pos == *current_hex {
return;
Expand Down

0 comments on commit af8095e

Please sign in to comment.