Struct tcod::bsp::Bsp
[−]
[src]
pub struct Bsp<'a> { /* fields omitted */ }
This struct encapsulates TCOD_bsp_t
. It mirrors original's fields (x
, y
, etc.)
with the exception of horizontal
. See example.
Examples
let mut bsp = Bsp::new_with_size(0, 0, 50, 60); assert_eq!(bsp.x, 0); assert_eq!(bsp.y, 0); assert_eq!(bsp.w, 50); assert_eq!(bsp.h, 60); assert_eq!(bsp.horizontal(), false); bsp.x = 10; bsp.y = 20; bsp.set_horizontal(true);
Methods
impl<'a> Bsp<'a>
[src]
fn new_with_size(x: i32, y: i32, w: i32, h: i32) -> Self
fn remove_sons(&mut self)
fn split_once(&mut self, horizontal: bool, position: i32)
fn split_recursive(&mut self,
randomizer: Option<Rng>,
nb: i32,
min_h_size: i32,
min_v_size: i32,
max_h_ratio: f32,
max_v_ratio: f32)
randomizer: Option<Rng>,
nb: i32,
min_h_size: i32,
min_v_size: i32,
max_h_ratio: f32,
max_v_ratio: f32)
fn resize(&mut self, x: i32, y: i32, w: i32, h: i32)
fn left(&self) -> Option<Self>
Returns Some(Bsp)
with left subtree, or None
if the BSP has not been split.
fn right(&self) -> Option<Self>
Returns Some(Bsp)
with right subtree, or None
if the BSP has not been split.
fn father(&self) -> Option<Self>
Returns Some(Bsp)
with father, or None
if the node is root.
fn is_leaf(&self) -> bool
fn contains(&self, cx: i32, cy: i32) -> bool
fn find_node(&self, cx: i32, cy: i32) -> Option<Self>
fn horizontal(&self) -> bool
fn set_horizontal(&mut self, h: bool)
fn traverse<F>(&self, order: TraverseOrder, callback: F) -> bool where F: FnMut(&mut Bsp) -> bool
Instead of 5 traverse*
functions as in original API, Rust binding
provides a single traverse
function with an order
parameter.
Examples
let bsp = Bsp::new_with_size(0, 0, 50, 50); let mut counter = 0; bsp.traverse(TraverseOrder::PreOrder, |node| { counter += 1; true }); assert_eq!(counter, 1);
Trait Implementations
impl<'a> Deref for Bsp<'a>
[src]
type Target = TCOD_bsp_t
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value