Beginning of sudoku chapter 7 with SDM loading
This commit is contained in:
@@ -20,7 +20,7 @@ impl GameboardController {
|
||||
}
|
||||
|
||||
pub fn event<E: GenericEvent>(&mut self, pos: [f64; 2], size: f64, e: &E) {
|
||||
use piston::input::{Button, MouseButton};
|
||||
use piston::input::{Button, Key, MouseButton};
|
||||
|
||||
if let Some(pos) = e.mouse_cursor_args() {
|
||||
self.cursor_pos = pos;
|
||||
@@ -36,5 +36,22 @@ impl GameboardController {
|
||||
self.selected_cell = Some([cell_x, cell_y]);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(Button::Keyboard(key)) = e.press_args() {
|
||||
if let Some(ind) = self.selected_cell {
|
||||
match key {
|
||||
Key::D1 => self.gameboard.set(ind, 1),
|
||||
Key::D2 => self.gameboard.set(ind, 2),
|
||||
Key::D3 => self.gameboard.set(ind, 3),
|
||||
Key::D4 => self.gameboard.set(ind, 4),
|
||||
Key::D5 => self.gameboard.set(ind, 5),
|
||||
Key::D6 => self.gameboard.set(ind, 6),
|
||||
Key::D7 => self.gameboard.set(ind, 7),
|
||||
Key::D8 => self.gameboard.set(ind, 8),
|
||||
Key::D9 => self.gameboard.set(ind, 9),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user