BSPMap

Struct BSPMap 

Source
pub struct BSPMap { /* private fields */ }
Expand description

Map generated with binary search partitioning. The map must have a size of atleast (20,20).

Credit to https://gamedevelopment.tutsplus.com/tutorials/how-to-use-bsp-trees-to-generate-game-maps–gamedev-12268 and https://github.com/whostolemyhat/dungeon for algorithm and rust implementation help.

Implementations§

Source§

impl BSPMap

Source

pub fn new( size: Point, seed: StdRng, min_room_size: Point, max_room_size: Point, ) -> Result<Self, Error>

Examples found in repository?
examples/bsp-map.rs (line 4)
3fn main() {
4    let map = BSPMap::new(Point::new(30,50), SeedableRng::seed_from_u64(1), Point::new(3,5), Point::new(10,15)).unwrap();
5    println!("{}", map);
6}
Source

pub fn get_tiles(&self) -> &HashMap<Point, Tile>

Source

pub fn get_size(&self) -> &Point

Source

pub fn get_rooms(&self) -> &Vec<Room>

Source

pub fn add_room(&mut self, room: &Room)

Trait Implementations§

Source§

impl Display for BSPMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for BSPMap

§

impl RefUnwindSafe for BSPMap

§

impl Send for BSPMap

§

impl Sync for BSPMap

§

impl Unpin for BSPMap

§

impl UnwindSafe for BSPMap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V