general cleanup

This commit is contained in:
Alexander Bass 2023-06-07 16:07:03 -04:00
parent 993f608cfa
commit 864a9ca3d5
13 changed files with 184 additions and 166 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -32,7 +32,7 @@
<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script> <script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
<script> <script>
load("./minesweeper.wasm"); load("./minesweeper.wasm");
</script> <!-- Your compiled wasm file --> </script>
<script> <script>
document.addEventListener("contextmenu", (e) => { document.addEventListener("contextmenu", (e) => {
e.preventDefault(); e.preventDefault();

View file

@ -1,6 +1,7 @@
mod board_render; mod board_render;
mod highlighter; mod highlighter;
pub mod settings_menu; pub mod settings_menu;
mod seven_segment;
pub mod texture_store; pub mod texture_store;
mod tile_render; mod tile_render;
pub mod top_menu; pub mod top_menu;
@ -86,9 +87,6 @@ impl UIState {
self.letterbox.1 = 0f32; self.letterbox.1 = 0f32;
} }
} }
}
impl UIState {
pub fn pixel_screen_offset(&self, x: usize, y: usize) -> (f32, f32) { pub fn pixel_screen_offset(&self, x: usize, y: usize) -> (f32, f32) {
let (x, y) = self.pixel_screen_scale(x, y); let (x, y) = self.pixel_screen_scale(x, y);
let x = x + self.letterbox.0; let x = x + self.letterbox.0;

View file

@ -26,9 +26,11 @@ pub enum Highlight {
Wide, Wide,
} }
// The highlighter is responsible for the selection when a tile is clicked and held either with left or middle click
impl Highlighter { impl Highlighter {
pub fn events(&mut self, ui_state: &UIState, event_handler: &mut Events<GUIEvent>, game_board: &mut GameBoard) { pub fn events(&mut self, ui_state: &UIState, event_handler: &mut Events<GUIEvent>, game_board: &mut GameBoard) {
if !ui_state.frozen && ui_state.mouse_in_minefield { if !ui_state.frozen {
if ui_state.mouse_in_minefield {
if is_mouse_button_pressed(MouseButton::Left) { if is_mouse_button_pressed(MouseButton::Left) {
self.highlight = Highlight::Normal; self.highlight = Highlight::Normal;
} }
@ -39,17 +41,15 @@ impl Highlighter {
} }
if is_mouse_button_released(MouseButton::Left) { if is_mouse_button_released(MouseButton::Left) {
self.reset_highlight(ui_state, event_handler); self.reset_highlight(ui_state, event_handler);
if !ui_state.frozen {
event_handler.add(GUIEvent::SetSmileyState(SmileyState::Chillin)); event_handler.add(GUIEvent::SetSmileyState(SmileyState::Chillin));
} }
}
if is_mouse_button_released(MouseButton::Middle) { if is_mouse_button_released(MouseButton::Middle) {
self.reset_highlight(ui_state, event_handler); self.reset_highlight(ui_state, event_handler);
if !ui_state.frozen {
event_handler.add(GUIEvent::SetSmileyState(SmileyState::Chillin)); event_handler.add(GUIEvent::SetSmileyState(SmileyState::Chillin));
} }
} }
} }
fn check_reveal(&self, event_handler: &mut Events<GUIEvent>, interface: &UIState, game_board: &mut GameBoard) { fn check_reveal(&self, event_handler: &mut Events<GUIEvent>, interface: &UIState, game_board: &mut GameBoard) {
let (x, y) = interface.cursor; let (x, y) = interface.cursor;
if let Some(tile) = game_board.get_tile_mut(x, y) { if let Some(tile) = game_board.get_tile_mut(x, y) {

View file

@ -1,12 +1,24 @@
use crate::{logic::game_board::ModifyMode, util::Events}; use crate::{logic::game_board::ModifyMode, util::Events};
use super::{texture_store::TextureStore, GUIEvent, Language, UIState}; use super::{seven_segment::draw_seven_segment_unscaled, texture_store::TextureStore, GUIEvent, Language, UIState};
use macroquad::{ use macroquad::{
hash, hash,
prelude::*, prelude::*,
ui::{root_ui, widgets, Skin, Ui}, ui::{root_ui, widgets, Skin, Ui},
}; };
const NEW_GAME_HEIGHT: f32 = 40f32;
const NEW_GAME_WIDTH: f32 = 250f32;
const BUTTON_MENU_WIDTH: f32 = 250f32;
const BUTTON_SIZE: f32 = 100f32;
const BUTTON_MENU_Y: f32 = 400f32;
const BUTTON_MENU_LABEL_HEIGHT: f32 = 20f32;
const MIN_MINEFIELD_WIDTH: usize = 5;
const MAX_MINEFIELD_WIDTH: usize = 100;
const MIN_MINEFIELD_HEIGHT: usize = 5;
const MAX_MINEFIELD_HEIGHT: usize = 100;
pub struct SettingsMenu { pub struct SettingsMenu {
mines: usize, mines: usize,
width: usize, width: usize,
@ -46,16 +58,13 @@ impl SettingsMenu {
ui.pop_skin(); ui.pop_skin();
ui.push_skin(&skin); ui.push_skin(&skin);
let half_screen_width = screen_width * 0.5; let half_screen_width = screen_width * 0.5;
const MIN_MINEFIELD_WIDTH: usize = 5;
const MAX_MINEFIELD_WIDTH: usize = 100;
const MIN_MINEFIELD_HEIGHT: usize = 5;
// const MAX_MINEFIELD_HEIGHT: usize = 100;
render_counter( render_counter(
&mut self.width, &mut self.width,
ui, ui,
&textures, &textures,
vec2(half_screen_width, 100f32), vec2(half_screen_width, 100f32),
String::from("Minefield Width"), "Minefield Width",
MIN_MINEFIELD_WIDTH, MIN_MINEFIELD_WIDTH,
MAX_MINEFIELD_WIDTH, MAX_MINEFIELD_WIDTH,
); );
@ -64,21 +73,19 @@ impl SettingsMenu {
ui, ui,
&textures, &textures,
vec2(half_screen_width, 200f32), vec2(half_screen_width, 200f32),
String::from("Minefield Height"), "Minefield Height",
MIN_MINEFIELD_WIDTH,
MIN_MINEFIELD_HEIGHT, MIN_MINEFIELD_HEIGHT,
MAX_MINEFIELD_HEIGHT,
); );
render_counter( render_counter(
&mut self.mines, &mut self.mines,
ui, ui,
&textures, &textures,
vec2(half_screen_width, 300f32), vec2(half_screen_width, 300f32),
String::from("Mines"), "Mines",
1, 1,
self.width * self.height - 10, self.width * self.height - 10,
); );
const NEW_GAME_HEIGHT: f32 = 40f32;
const NEW_GAME_WIDTH: f32 = 250f32;
if widgets::Button::new("New Game") if widgets::Button::new("New Game")
.size(vec2(NEW_GAME_WIDTH, NEW_GAME_HEIGHT)) .size(vec2(NEW_GAME_WIDTH, NEW_GAME_HEIGHT))
.position(vec2((screen_width - NEW_GAME_WIDTH) * 0.5, 0.0)) .position(vec2((screen_width - NEW_GAME_WIDTH) * 0.5, 0.0))
@ -87,12 +94,9 @@ impl SettingsMenu {
event_handler.add(GUIEvent::CreateNewGame(self.width, self.height, self.mines)); event_handler.add(GUIEvent::CreateNewGame(self.width, self.height, self.mines));
event_handler.add(GUIEvent::CloseSettings); event_handler.add(GUIEvent::CloseSettings);
} }
const BUTTON_MENU_WIDTH: f32 = 250f32;
let language_button_x = (screen_width - BUTTON_MENU_WIDTH) * 0.5; let language_button_x = (screen_width - BUTTON_MENU_WIDTH) * 0.5;
const BUTTON_SIZE: f32 = 100f32;
const BUTTON_MENU_Y: f32 = 400f32;
let question_button_x = (screen_width - BUTTON_MENU_WIDTH) * 0.5 + (BUTTON_MENU_WIDTH - BUTTON_SIZE); let question_button_x = (screen_width - BUTTON_MENU_WIDTH) * 0.5 + (BUTTON_MENU_WIDTH - BUTTON_SIZE);
const BUTTON_MENU_LABEL_HEIGHT: f32 = 20f32;
widgets::Label::new("Language") widgets::Label::new("Language")
.position(vec2(language_button_x, BUTTON_MENU_Y - BUTTON_MENU_LABEL_HEIGHT)) .position(vec2(language_button_x, BUTTON_MENU_Y - BUTTON_MENU_LABEL_HEIGHT))
.size(vec2(BUTTON_SIZE, BUTTON_MENU_LABEL_HEIGHT)) .size(vec2(BUTTON_SIZE, BUTTON_MENU_LABEL_HEIGHT))
@ -141,36 +145,23 @@ impl SettingsMenu {
} }
} }
fn render_counter(
count: &mut usize,
ui: &mut Ui,
textures: &TextureStore,
position: Vec2,
title: String,
min: usize,
max: usize,
) {
let digits: Vec<usize> = {
let digits = count.to_string();
let digits = format!("{:0>3}", digits);
digits.chars().map(|i| (i.to_digit(10u32).unwrap_or(0)) as usize).collect()
};
const COUNTER_DIGIT_WIDTH: f32 = 13f32 * 2.0; const COUNTER_DIGIT_WIDTH: f32 = 13f32 * 2.0;
const COUNTER_DIGIT_HEIGHT: f32 = 23f32 * 2.0; const COUNTER_DIGIT_HEIGHT: f32 = 23f32 * 2.0;
const COUNTER_BUTTON_HEIGHT: f32 = 30f32; const COUNTER_BUTTON_HEIGHT: f32 = 30f32;
const COUNTER_BUTTON_MARGIN: f32 = 10f32; const COUNTER_BUTTON_MARGIN: f32 = 10f32;
const BUTTON_OFFSET_HEIGHT: f32 = (COUNTER_DIGIT_HEIGHT - COUNTER_BUTTON_HEIGHT) * 0.5; const BUTTON_OFFSET_HEIGHT: f32 = (COUNTER_DIGIT_HEIGHT - COUNTER_BUTTON_HEIGHT) * 0.5;
fn render_counter(count: &mut usize, ui: &mut Ui, textures: &TextureStore, position: Vec2, title: &str, min: usize, max: usize) {
let digits: Vec<usize> = {
let digits = count.to_string();
let digits = format!("{:0>3}", digits);
digits.chars().map(|i| (i.to_digit(10u32).unwrap_or(0)) as usize).collect()
};
let counter_width = digits.len() as f32 * COUNTER_DIGIT_WIDTH; let counter_width = digits.len() as f32 * COUNTER_DIGIT_WIDTH;
let position = position - vec2(counter_width * 0.5, 0.0); let position = position - vec2(counter_width * 0.5, 0.0);
for (x, digit) in digits.iter().enumerate() {
let position = vec2(COUNTER_DIGIT_WIDTH * x as f32, 0f32) + position; draw_seven_segment_unscaled(ui, textures, &digits, position.x as usize, position.y as usize);
widgets::Texture::new(textures.numbers[*digit])
.size(COUNTER_DIGIT_WIDTH, COUNTER_DIGIT_HEIGHT)
.position(position)
.ui(ui);
}
if widgets::Button::new("+") if widgets::Button::new("+")
.size(vec2(COUNTER_BUTTON_HEIGHT, COUNTER_BUTTON_HEIGHT)) .size(vec2(COUNTER_BUTTON_HEIGHT, COUNTER_BUTTON_HEIGHT))
.position(position + vec2(counter_width + COUNTER_BUTTON_MARGIN, BUTTON_OFFSET_HEIGHT)) .position(position + vec2(counter_width + COUNTER_BUTTON_MARGIN, BUTTON_OFFSET_HEIGHT))

31
src/gui/seven_segment.rs Normal file
View file

@ -0,0 +1,31 @@
use macroquad::{
prelude::vec2,
ui::{widgets, Ui},
};
pub const WIDTH: usize = 13 * 2;
pub const HEIGHT: usize = 23 * 2;
use super::{texture_store::TextureStore, UIState};
pub fn draw_seven_segment(ui_state: &UIState, ui: &mut Ui, textures: &TextureStore, val: &Vec<usize>, x: usize, y: usize) {
for (n, digit) in val.iter().enumerate() {
let (scaled_width, scaled_height) = ui_state.pixel_screen_scale(WIDTH as usize, HEIGHT);
let (pos_x, pos_y) = ui_state.pixel_screen_offset(n * WIDTH + x, y);
widgets::Texture::new(textures.numbers[*digit])
.size(scaled_width, scaled_height)
.position(vec2(pos_x, pos_y))
.ui(ui);
}
}
pub fn draw_seven_segment_unscaled(ui: &mut Ui, textures: &TextureStore, val: &Vec<usize>, x: usize, y: usize) {
for (n, digit) in val.iter().enumerate() {
let (pos_x, pos_y) = ((n * WIDTH + x) as f32, y as f32);
widgets::Texture::new(textures.numbers[*digit])
.size(WIDTH as f32, HEIGHT as f32)
.position(vec2(pos_x, pos_y))
.ui(ui);
}
}

View file

@ -22,12 +22,12 @@ impl Default for TextureStore {
impl TextureStore { impl TextureStore {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
numbers: load_sprites(include_bytes!("../../assets/numbers.png"), [26, 46], 1, 10).expect("Could not load sprites"), numbers: load_sprites(include_bytes!("../../assets/numbers.png"), (26, 46), 1, 10).expect("Could not load sprites"),
english_tiles: load_sprites(include_bytes!("../../assets/english_32x.png"), [32, 32], 2, 8) english_tiles: load_sprites(include_bytes!("../../assets/english_32x.png"), (32, 32), 2, 8)
.expect("Could not load Tile Sprites"), .expect("Could not load Tile Sprites"),
japanese_tiles: load_sprites(include_bytes!("../../assets/japanese_32x.png"), [32, 32], 2, 8) japanese_tiles: load_sprites(include_bytes!("../../assets/japanese_32x.png"), (32, 32), 2, 8)
.expect("Could not load Tile Sprites"), .expect("Could not load Tile Sprites"),
smilies: load_sprites(include_bytes!("../../assets/faces.png"), [48, 48], 1, 5).expect("Could not load face sprites"), smilies: load_sprites(include_bytes!("../../assets/faces.png"), (48, 48), 1, 5).expect("Could not load face sprites"),
cog: Texture2D::from_file_with_format(include_bytes!("../../assets/cog.png"), Some(ImageFormat::Png)), cog: Texture2D::from_file_with_format(include_bytes!("../../assets/cog.png"), Some(ImageFormat::Png)),
lang: Language::English, lang: Language::English,
} }

View file

@ -1,7 +1,8 @@
use crate::logic::tile::{Tile, TileModifier, TileState}; use crate::logic::tile::{Tile, TileModifier, TileState};
#[repr(usize)]
pub enum TileIndex { pub enum TileIndex {
Hidden, Unknown,
Revealed, Revealed,
Flag, Flag,
Question, Question,
@ -20,52 +21,46 @@ pub enum TileIndex {
} }
impl Tile { impl Tile {
pub fn render(self, show_all: bool) -> TileIndex { pub fn render(self, game_over: bool) -> TileIndex {
if self.swept && self.state == TileState::Mine { // Behold: the match statement from hell!
return TileIndex::Explosion; match (
} self.state,
if show_all { self.modifier,
if let Some(modifier) = self.modifier { self.adjacent,
if modifier == TileModifier::Flagged { game_over,
if self.state == TileState::Mine { self.swept,
return TileIndex::Flag; self.highlighted,
} else { ) {
return TileIndex::FalseFlagMine; // Has mine, clicked mine: BOOM!
} (TileState::Mine, _, _, _, true, _) => TileIndex::Explosion,
} // Has mine, has flag, and game is over: True Flag
} (TileState::Mine, Some(TileModifier::Flagged), _, true, _, _) => TileIndex::Flag,
if self.state == TileState::Mine { // Has flag, is not Mine, and game is over: False flag
return TileIndex::RevealedMine; (TileState::Empty, Some(TileModifier::Flagged), _, true, _, _) => TileIndex::FalseFlagMine,
} // Revealed mine after game is over
} (TileState::Mine, _, _, true, _, _) => TileIndex::RevealedMine,
if self.swept { // Revealed tiles with adjacent tile count
if self.state == TileState::Mine { (TileState::Empty, _, 0, _, true, _) => TileIndex::Revealed,
TileIndex::Explosion (TileState::Empty, _, 1, _, true, _) => TileIndex::One,
} else { (TileState::Empty, _, 2, _, true, _) => TileIndex::Two,
match self.adjacent { (TileState::Empty, _, 3, _, true, _) => TileIndex::Three,
0 => TileIndex::Revealed, (TileState::Empty, _, 4, _, true, _) => TileIndex::Four,
1 => TileIndex::One, (TileState::Empty, _, 5, _, true, _) => TileIndex::Five,
2 => TileIndex::Two, (TileState::Empty, _, 6, _, true, _) => TileIndex::Six,
3 => TileIndex::Three, (TileState::Empty, _, 7, _, true, _) => TileIndex::Seven,
4 => TileIndex::Four, (TileState::Empty, _, 8, _, true, _) => TileIndex::Eight,
5 => TileIndex::Five, // Flag modifier
6 => TileIndex::Six, (_, Some(TileModifier::Flagged), _, _, _, _) => TileIndex::Flag,
7 => TileIndex::Seven, // Question mark modifier
8 => TileIndex::Eight, (_, Some(TileModifier::Unsure), _, _, _, _) => TileIndex::Question,
_ => TileIndex::RevealedQuestion, // No modifier, not swept, but highlighted
} (_, None, _, _, false, true) => TileIndex::Revealed,
} // No modifier, Not swept, and not highlighted: Unknown tile
} else { (_, None, _, _, false, false) => TileIndex::Unknown,
if let Some(modif) = self.modifier { // unsigned 8 bit integer has too much range for the adjacent tiles count, creating an invalid state
match modif { // from 9 onward. This last clause is to catch if somehow this invalid state occurs, and display
TileModifier::Flagged => TileIndex::Flag, // the invalid tile in that case.
TileModifier::Unsure => TileIndex::Question, (TileState::Empty, _, 9..=u8::MAX, _, true, _) => TileIndex::RevealedQuestion,
}
} else if self.highlighted {
TileIndex::Revealed
} else {
TileIndex::Hidden
}
} }
} }
} }

View file

@ -1,9 +1,9 @@
use macroquad::{ use macroquad::ui::Ui;
prelude::*,
ui::{widgets, Ui},
};
use crate::gui::texture_store::TextureStore; use crate::gui::{
seven_segment::{self, draw_seven_segment},
texture_store::TextureStore,
};
use super::UIState; use super::UIState;
@ -33,18 +33,13 @@ impl GUIFlagCounter {
self.old_count = remaining; self.old_count = remaining;
} }
let top = ui_state.top_offset; draw_seven_segment(
const WIDTH: usize = 13 * 2; ui_state,
const HEIGHT: usize = 23 * 2; ui,
let (scaled_width, scaled_height) = ui_state.pixel_screen_scale(WIDTH, HEIGHT); textures,
&self.digits,
// let length = self.digits.len() as f32; seven_segment::WIDTH * 2,
for (x, digit) in self.digits.iter().enumerate() { (ui_state.top_offset - seven_segment::HEIGHT) / 2,
let (pos_x, pos_y) = ui_state.pixel_screen_offset((x + 2) * WIDTH, (top - HEIGHT) / 2); );
widgets::Texture::new(textures.numbers[*digit])
.size(scaled_width, scaled_height)
.position(vec2(pos_x, pos_y))
.ui(ui);
}
} }
} }

View file

@ -1,9 +1,9 @@
use macroquad::{ use macroquad::{prelude::*, ui::Ui};
prelude::*,
ui::{widgets, Ui},
};
use crate::gui::texture_store::TextureStore; use crate::gui::{
seven_segment::{self, draw_seven_segment},
texture_store::TextureStore,
};
use super::UIState; use super::UIState;
@ -31,18 +31,15 @@ impl GUITimer {
let digits: Vec<usize> = time_1.chars().map(|i| (i.to_digit(10u32).unwrap_or(0)) as usize).collect(); let digits: Vec<usize> = time_1.chars().map(|i| (i.to_digit(10u32).unwrap_or(0)) as usize).collect();
self.digits = digits; self.digits = digits;
} }
let top = ui_state.top_offset;
const WIDTH: usize = 13 * 2;
const HEIGHT: usize = 23 * 2;
let (scaled_width, scaled_height) = ui_state.pixel_screen_scale(WIDTH as usize, HEIGHT);
let board_width = ui_state.width * ui_state.tile_size; let board_width = ui_state.width * ui_state.tile_size;
let length = self.digits.len();
for (x, digit) in self.digits.iter().enumerate() { draw_seven_segment(
let (pos_x, pos_y) = ui_state.pixel_screen_offset(WIDTH * x + board_width - WIDTH * (length + 2), (top - HEIGHT) / 2); ui_state,
widgets::Texture::new(textures.numbers[*digit]) ui,
.size(scaled_width, scaled_height) textures,
.position(vec2(pos_x, pos_y)) &self.digits,
.ui(ui); board_width - seven_segment::WIDTH * (self.digits.len() + 2),
} (ui_state.top_offset - seven_segment::HEIGHT) / 2,
);
} }
} }

View file

@ -159,12 +159,13 @@ impl GameBoard {
let mut revealed: usize = 0; let mut revealed: usize = 0;
while scan_list.len() > 0 { while scan_list.len() > 0 {
for &scan_location in ADJACENT_WITHOUT_CENTER.iter() { for &scan_location in ADJACENT_WITHOUT_CENTER.iter() {
if let Some(old_tile) = self.get_tile(scan_list[0].0, scan_list[0].1) { if let Some((x, y)) = scan_list.front() {
if let Some(old_tile) = self.get_tile(*x, *y) {
if old_tile.adjacent > 0 { if old_tile.adjacent > 0 {
continue; continue;
} }
let x = scan_list[0].0 as isize + scan_location.0; let x = *x as isize + scan_location.0;
let y = scan_list[0].1 as isize + scan_location.1; let y = *y as isize + scan_location.1;
if x < 0 || y < 0 { if x < 0 || y < 0 {
continue; continue;
@ -182,6 +183,7 @@ impl GameBoard {
} }
} }
} }
}
scan_list.pop_front(); scan_list.pop_front();
} }
self.revealed_tiles += revealed; self.revealed_tiles += revealed;

View file

@ -2,13 +2,11 @@ use std::error::Error;
use image::{load_from_memory, EncodableLayout}; use image::{load_from_memory, EncodableLayout};
use macroquad::texture::{FilterMode, Texture2D}; use macroquad::texture::{FilterMode, Texture2D};
pub fn load_sprites(bytes: &[u8], tile_size: [usize; 2], rows: usize, columns: usize) -> Result<Vec<Texture2D>, Box<dyn Error>> { pub fn load_sprites(bytes: &[u8], tile_size: (u32, u32), rows: usize, columns: usize) -> Result<Vec<Texture2D>, Box<dyn Error>> {
let sprite_sheet = load_from_memory(bytes)?.to_rgba8(); let sprite_sheet = load_from_memory(bytes)?.to_rgba8();
let mut sprite_list: Vec<Texture2D> = vec![]; let mut sprite_list: Vec<Texture2D> = vec![];
let [tile_width, tile_height] = tile_size; let (tile_width, tile_height) = tile_size;
let tile_width = tile_width as u32;
let tile_height = tile_height as u32;
for i in 0..(rows * columns) { for i in 0..(rows * columns) {
let x = (i % columns) as u32; let x = (i % columns) as u32;

View file

@ -1,7 +1,18 @@
#[rustfmt::skip]
pub const ADJACENT_WITH_CENTER: [(isize, isize); 9] = pub const ADJACENT_WITH_CENTER: [(isize, isize); 9] =
[(-1, -1), (0, -1), (1, -1), (-1, 0), (0, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]; [
(-1, -1), (0, -1), (1, -1),
(-1, 0), (0, 0), (1, 0),
(-1, 1), (0, 1), (1, 1)
];
pub const ADJACENT_WITHOUT_CENTER: [(isize, isize); 8] = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]; #[rustfmt::skip]
pub const ADJACENT_WITHOUT_CENTER: [(isize, isize); 8] =
[
(-1, -1), (0, -1), (1, -1),
(-1, 0), (1, 0),
(-1, 1), (0, 1), (1, 1)
];
// Event Queue // Event Queue
pub struct Events<E> { pub struct Events<E> {