summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 4df4fa7..bb65f81 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -281,6 +281,33 @@ pub fn setup(
}
}
+fn mouse_system(
+ windows: Res<Windows>,
+ mut cell_query: Query<(&Cell, &mut Transform, &mut TextureAtlasSprite)>,
+) {
+ if let Some(mut cursor_position) = windows
+ .get_primary()
+ .and_then(|window| window.cursor_position())
+ {
+ cursor_position.x -= 400.0 - 16.0 * 3.5 * 0.5;
+ cursor_position.y -= 300.0 - 16.0 * 3.5 * 0.5;
+
+ for (_, _, mut sprite) in cell_query.iter_mut() {
+ sprite.color.set_a(1.0);
+ }
+
+ for (_, transform, mut sprite) in cell_query.iter_mut() {
+ if transform.translation.x < cursor_position.x
+ && transform.translation.x + 16.0 * 3.5 > cursor_position.x
+ && transform.translation.y < cursor_position.y
+ && transform.translation.y + 16.0 * 3.5 > cursor_position.y
+ {
+ sprite.color.set_a(0.5);
+ }
+ }
+ }
+}
+
pub struct GemsPlugin;
impl Plugin for GemsPlugin {
fn build(&self, app: &mut AppBuilder) {
@@ -289,6 +316,7 @@ impl Plugin for GemsPlugin {
app.add_system(cell_falling_system.system());
app.add_system(cell_check_system.system());
app.add_system(explosion_animation_system.system());
+ app.add_system(mouse_system.system());
}
}