[][src]Struct babalcore::Level

pub struct Level { /* fields omitted */ }

Implementations

impl Level[src]

pub fn new(seed: u64, width: usize, skill: Skill) -> Level[src]

Create a new level, with a given size

Examples

use babalcore::*;

let _level = Level::new(0, 10, Skill::Easy);

pub fn push(&mut self, row: Row)[src]

Push a row at the end of the level.

Examples

use babalcore::*;

let mut level = Level::new(0, 10, Skill::Easy);
level.push(Row::new(SlabDef::Floor));
assert_eq!(1, level.len());

pub fn generate(&mut self, n: usize)[src]

Generate new rows and append them to the level.

Examples

use babalcore::*;

let mut level = Level::new(0, 10, Skill::Easy);
level.generate(2);
assert_eq!(2, level.len());
level.generate(3);
assert_eq!(5, level.len());

pub fn slab_kind(&self, col: isize, row: isize, now_msec: i64) -> SlabKind[src]

Get a level content, at a given time.

Examples

use babalcore::*;

let mut level = Level::new(0, 10, Skill::Easy);
level.generate(2);
assert_eq!(SlabKind::Floor, level.slab_kind(5, 1, 3000));

Trait Implementations

impl Display for Level[src]

impl LevelQuery for Level[src]

pub fn width(&self) -> usize[src]

Get the level width. It is fixed for a given game session.

Examples

use babalcore::*;

let level = Level::new(0, 10, Skill::Easy);
assert_eq!(10, level.width());

pub fn len(&self) -> usize[src]

Get the level length. Length typically increases as the ball rolls on. However it is capped at some point and history at the beginning of the level is removed. View this as a sliding window.

Examples

use babalcore::*;

let level = Level::new(0, 10, Skill::Easy);
assert_eq!(0, level.len());

pub fn first(&self) -> isize[src]

Get the level first row, the row with the lowest index.

Examples

use babalcore::*;

let level = Level::new(0, 10, Skill::Easy);
assert_eq!(0, level.len());

pub fn last(&self) -> isize[src]

Get the level last row, more precisely its index plus one. So if last is equal to first, then len is 0 an there are no rows at all.

Examples

use babalcore::*;

let level = Level::new(0, 10, Skill::Easy);
assert_eq!(0, level.len());

pub fn item(&self, col: isize, row: isize, now_msec: i64) -> i64[src]

Get a level content, returns a plain integer.

Examples

use babalcore::*;

let mut level = Level::new(0, 10, Skill::Easy);
level.generate(2);
assert_eq!(0, level.item(5, 1, 3000));

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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