[][src]Struct elma::lev::Level

pub struct Level {
    pub version: Version,
    pub link: u32,
    pub integrity: [f64; 4],
    pub title: String,
    pub lgr: String,
    pub ground: String,
    pub sky: String,
    pub polygons: Vec<Polygon>,
    pub objects: Vec<Object>,
    pub pictures: Vec<Picture>,
    pub best_times: BestTimes,
    pub path: Option<PathBuf>,
}

Level struct that contains all level information.

Fields

version: Version

Elma or Across level.

link: u32

Random number that links level file to replay files.

integrity: [f64; 4]

Contains four integrity checks.

title: String

Level title.

lgr: String

LGR file name.

ground: String

Ground texture name.

sky: String

Sky texture name.

polygons: Vec<Polygon>

Vector with all polygons (See Polygon).

objects: Vec<Object>

Vector with all objects (See Object).

pictures: Vec<Picture>

Vector with all pictures (See Picture).

best_times: BestTimes

Best times lists.

path: Option<PathBuf>

Level path, if loaded/saved.

Methods

impl Level[src]

pub fn new() -> Self[src]

Returns a new Level struct.

Examples

let level = Level::new();

pub fn load<P: Into<PathBuf>>(path: P) -> Result<Self, ElmaError>[src]

Loads a level file and returns a Level struct.

Examples

let level = Level::load("tests/assets/levels/test_1.lev").unwrap();

pub fn from_bytes<B: AsRef<[u8]>>(buffer: B) -> Result<Self, ElmaError>[src]

Load a level from bytes.

Examples

let lev = Level::from_bytes(&[0,1,2]).unwrap();

pub fn to_bytes(&self, top_10: Top10Save) -> Result<Vec<u8>, ElmaError>[src]

Converts all struct fields into raw binary form and returns the raw data.

Arguments

  • top10 - Specifies whether to keep the top10 list (true), or write an empty list (false).

Examples

let mut level = Level::new();
let raw_bytes = level.to_bytes(Top10Save::No).unwrap();

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

Width of level based on left- and right-most vertices.

pub fn height(&self) -> f64[src]

Height of level based on top and bottom-most vertices.

pub fn check_topology(&self) -> Result<(), TopologyError>[src]

Check topology of level.

Generate a random link number. When you save a level, it will keep the original link number unless explicitly changed manually or by running this function before saving.

Examples

let mut level = Level::new();
level.generate_link();
level.save("newlink.lev", Top10Save::No).unwrap();

pub fn save<P: Into<PathBuf>>(
    &mut self,
    path: P,
    top10: Top10Save
) -> Result<(), ElmaError>
[src]

Saves level as a file.

Arguments

  • path - Path to save as.
  • top10 - Specifies whether to keep the top10 list (true), or write an empty list (false).

Examples

let mut level = Level::new();
level.save("newlevel.lev", Top10Save::No).unwrap();

Trait Implementations

impl BoundingBox for Level[src]

impl PartialEq<Level> for Level[src]

impl Default for Level[src]

impl Debug for Level[src]

Auto Trait Implementations

impl Send for Level

impl Sync for Level

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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<T> Any for T where
    T: 'static + ?Sized
[src]