You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Handles events.
pub fn event<E: GenericEvent>(&mut self, pos: [f64; 2], size: f64, e: &E) {
use piston::input::{Button, MouseButton};
if let Some(pos) = e.mouse_cursor_args() {
______________________________________________________________________________________________________________
///////// Did not run here, SOMEBODY can help me? thank you.///////!!!!!!!!!!!
------------------------------------------------------------------------------------------------------------------
self.cursor_pos = pos;
}
if let Some(Button::Mouse(MouseButton::Left)) = e.press_args() {
// Find coordinates relative to upper left corner.
let x = self.cursor_pos[0] - pos[0];
let y = self.cursor_pos[1] - pos[1];
// Check that coordinates are inside board boundaries.
if x >= 0.0 && x < size && y >= 0.0 && y < size {
// Compute the cell position.
let cell_x = (x / size * 9.0) as usize;
let cell_y = (y / size * 9.0) as usize;
self.selected_cell = Some([cell_x, cell_y]);
}
}
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: