pub struct TileBuffer {
pub tiles: Vec<TileEntry>,
pub width_tiles: u16,
pub height_tiles: u16,
pub cursor: TilePos,
}Expand description
A configurable-width tile grid representing the text rendering surface.
Each cell carries a tile ID and ink colour. The cursor tracks the
current write position for the next character. Dimensions are set at
construction time via TileBuffer::new.
Fields§
§tiles: Vec<TileEntry>Row-major tile entries. tiles[y * width_tiles + x].
width_tiles: u16Width of the buffer in tiles.
height_tiles: u16Height of the buffer in tiles.
cursor: TilePosCurrent text cursor position.
Implementations§
Source§impl TileBuffer
impl TileBuffer
Sourcepub fn new(width_tiles: u16, height_tiles: u16) -> Self
pub fn new(width_tiles: u16, height_tiles: u16) -> Self
Creates a new, empty tile buffer with the cursor at (0, 0).
Examples found in repository?
examples/hello_dotzuki.rs (line 464)
460fn demo_dialog() {
461 println!("\n╔══ NPC DIALOG ═══════════════════════════╗");
462 let provider = HelloConfig::new();
463 let mut engine = DialogEngine::new(provider);
464 let mut buffer = TileBuffer::new(20, 18);
465
466 // "Greetings, young hero!" + DONE
467 let text: &[u8] = b"Greetings, young hero!";
468 let mut full = text.to_vec();
469 full.push(0xFF); // DONE
470
471 engine.open_dialog(&full);
472 while engine.is_active() { engine.update(&mut buffer); }
473
474 print!("║ Merlin: \"");
475 for i in 0..20usize {
476 let t = buffer.tiles[i].tile_id;
477 if (0x20..=0x7E).contains(&t) { print!("{}", t as u8 as char); }
478 }
479 println!("\"");
480 println!("╚══════════════════════════════════════════╝");
481}Sourcepub fn set_tile(&mut self, pos: TilePos, tile_id: u16, ink: u8)
pub fn set_tile(&mut self, pos: TilePos, tile_id: u16, ink: u8)
Writes a tile at the given position. Silently does nothing if the position is out of bounds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TileBuffer
impl RefUnwindSafe for TileBuffer
impl Send for TileBuffer
impl Sync for TileBuffer
impl Unpin for TileBuffer
impl UnsafeUnpin for TileBuffer
impl UnwindSafe for TileBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more