wip 2 pointifying
This commit is contained in:
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user