numples 1.2.0

Yet another colourful sudoku playing game.
Documentation
use bevy::prelude::*;

use crate::consts::CELL_SIZE;
use crate::game::Board;

use super::clock::ClockDisplay;

pub fn mouse_system(
    window: Single<&Window>,
    click_event: Res<ButtonInput<MouseButton>>,
    mut board: Single<&mut Board>,
    mut clock: Single<&mut Visibility, With<ClockDisplay>>,
) {
    if let Some(mouse) = window.cursor_position() {
        let x = (mouse.x / CELL_SIZE - 0.5) as i32;
        let y = 9 - (mouse.y / CELL_SIZE + 0.75) as i32;

        **clock = if y < 0 {
            Visibility::Visible
        } else {
            Visibility::Hidden
        };

        if click_event.just_pressed(MouseButton::Left) {
            if x >= 0 && x < 9 && y >= 0 && y < 9 {
                board.set_highlight(x, y);
                return;
            }
        }
    }
}