From af8095e2370f61fdb5f70243c4994eaedd0748eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Lescaudey=20de=20Maneville?= Date: Wed, 12 Jul 2023 12:46:27 +0200 Subject: [PATCH] cursor position update --- CHANGELOG.md | 1 + examples/a_star.rs | 2 +- examples/field_of_movement.rs | 2 +- examples/field_of_view.rs | 2 +- examples/hex_grid.rs | 2 +- examples/scroll_map.rs | 2 +- examples/wrap_map.rs | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea9abdc..d34468b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/examples/a_star.rs b/examples/a_star.rs index 0307d08..0902f7d 100644 --- a/examples/a_star.rs +++ b/examples/a_star.rs @@ -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) { diff --git a/examples/field_of_movement.rs b/examples/field_of_movement.rs index 900a3ad..5109a9f 100644 --- a/examples/field_of_movement.rs +++ b/examples/field_of_movement.rs @@ -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 { diff --git a/examples/field_of_view.rs b/examples/field_of_view.rs index 19c935d..4aaf10d 100644 --- a/examples/field_of_view.rs +++ b/examples/field_of_view.rs @@ -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) { diff --git a/examples/hex_grid.rs b/examples/hex_grid.rs index dd43422..5177783 100644 --- a/examples/hex_grid.rs +++ b/examples/hex_grid.rs @@ -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 { diff --git a/examples/scroll_map.rs b/examples/scroll_map.rs index 8d11292..792361b 100644 --- a/examples/scroll_map.rs +++ b/examples/scroll_map.rs @@ -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); diff --git a/examples/wrap_map.rs b/examples/wrap_map.rs index 2fc6f1f..c56cfd9 100644 --- a/examples/wrap_map.rs +++ b/examples/wrap_map.rs @@ -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;