Level

Struct Level 

Source
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,
}
Expand description

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.

Implementations§

Source§

impl Level

Source

pub fn new() -> Self

Returns a new Level struct.

§Examples
let level = Level::new();
Source

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

Loads a level file and returns a Level struct.

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

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

Load a level from bytes.

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

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

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();
Source

pub fn width(&self) -> f64

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

Source

pub fn height(&self) -> f64

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

Source

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

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();
Source

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

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§

Source§

impl BoundingBox for Level

Source§

fn bounding_box(&self) -> [Position<f64>; 4]

Bounding box of &self, going from top-left, top-right, bottom-left to bottom-right.
Source§

impl Clone for Level

Source§

fn clone(&self) -> Level

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Level

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Level

Source§

fn default() -> Level

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Level

Source§

fn eq(&self, other: &Level) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Level

Auto Trait Implementations§

§

impl Freeze for Level

§

impl RefUnwindSafe for Level

§

impl Send for Level

§

impl Sync for Level

§

impl Unpin for Level

§

impl UnwindSafe for Level

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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