Trait babalcore::LevelQuery[][src]

pub trait LevelQuery {
    fn width(&self) -> usize;
fn len(&self) -> usize;
fn first(&self) -> isize;
fn last(&self) -> isize;
fn item(&self, col: isize, row: isize, boost: bool) -> i64;
fn find_start_spot(&self, col: isize, row: isize) -> Option<(isize, isize)>;
fn skill(&self) -> Skill; }

Required methods

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

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

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

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

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

fn find_start_spot(&self, col: isize, row: isize) -> Option<(isize, isize)>[src]

fn skill(&self) -> Skill[src]

Loading content...

Implementors

impl LevelQuery for Level[src]

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, Skill::Easy);
assert_eq!(9, level.width());

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, Skill::Easy);
assert_eq!(0, level.len());

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

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

Examples

use babalcore::*;

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

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, Skill::Easy);
assert_eq!(0, level.last());

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

Get a level content, returns a plain integer.

Examples

use babalcore::*;

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

fn find_start_spot(&self, col: isize, row: isize) -> Option<(isize, isize)>[src]

Find a starting spot on a level.

Examples

use babalcore::*;

let mut level = Level::new(42, Skill::Easy);
assert_eq!(None, level.find_start_spot(2, 1));
level.generate(100);
assert_eq!(Some((2,1)), level.find_start_spot(2, 1));

fn skill(&self) -> Skill[src]

Get the level skill.

Examples

use babalcore::*;

let level = Level::new(42, Skill::Easy);
assert_eq!(Skill::Easy, level.skill());
Loading content...