game_toolkit_platformer/sim/custom_tile.rs
1//! [`CustomTile`]: what a [`Tile::Custom`](super::Tile::Custom) is to the movement, set
2//! per id with [`Level::define`](super::Level::define).
3
4use super::{Hold, Surface};
5
6/// How the movement treats one kind of custom tile. The default is air.
7#[derive(Clone, Copy, Debug, Default, PartialEq)]
8pub struct CustomTile {
9 /// Whether and how it holds the character.
10 pub hold: Hold,
11 /// The surface it is, when it holds the character (solid or a platform).
12 pub surface: Surface,
13}
14
15impl CustomTile {
16 /// A solid tile with `surface`.
17 pub const fn solid(surface: Surface) -> Self {
18 Self {
19 hold: Hold::Solid,
20 surface,
21 }
22 }
23
24 /// A one-way platform with `surface`: a bouncy, icy or moving-belt ledge.
25 pub const fn platform(surface: Surface) -> Self {
26 Self {
27 hold: Hold::Platform,
28 surface,
29 }
30 }
31}