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 678)
674fn demo_dialog() {
675 println!("\n╔══ NPC DIALOG ═══════════════════════════╗");
676 let provider = HelloConfig::new();
677 let mut engine = DialogEngine::new(provider);
678 let mut buffer = TileBuffer::new(20, 18);
679
680 // "Greetings, young hero!" + DONE
681 let text: &[u8] = b"Greetings, young hero!";
682 let mut full = text.to_vec();
683 full.push(0xFF); // DONE
684
685 engine.open_dialog(&full);
686 while engine.is_active() {
687 engine.update(&mut buffer);
688 }
689
690 print!("║ Merlin: \"");
691 for i in 0..20usize {
692 let t = buffer.tiles[i].tile_id;
693 if (0x20..=0x7E).contains(&t) {
694 print!("{}", t as u8 as char);
695 }
696 }
697 println!("\"");
698 println!("╚══════════════════════════════════════════╝");
699}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