wip 2 pointifying

This commit is contained in:
2026-08-11 01:02:38 -05:00
parent 3b5bf21ac5
commit 38c58a2c5f
25 changed files with 163 additions and 309 deletions
+4 -2
View File
@@ -14,6 +14,7 @@ use crate::glyph::Glyph;
use color::Rgba8;
use serde::{Deserialize, Serialize};
use tinyrand::{Probability, Rand, Seeded, StdRand};
use crate::utils::Point;
/// A board's floor: the cosmetic backdrop drawn beneath everything, replacing the
/// old dedicated floor *layer*. A board has exactly one [`Floor`] (see
@@ -62,11 +63,12 @@ impl Floor {
/// The floor glyph to draw at `(x, y)`, or `None` for [`Floor::Blank`].
///
/// `width` is the board width, needed to index a biome's row-major buffer.
pub(crate) fn glyph_at(&self, x: usize, y: usize, width: usize) -> Option<Glyph> {
pub(crate) fn glyph_at<P: Into<Point>>(&self, p: P, width: usize) -> Option<Glyph> {
let p = p.into();
match self {
Floor::Blank => None,
Floor::Fixed(g) => Some(*g),
Floor::Biome { glyphs, .. } => glyphs.get(y * width + x).copied(),
Floor::Biome { glyphs, .. } => glyphs.get(p.uy() * width + p.ux()).copied(),
}
}
}