Expand description
§Falling Tetromino Engine
falling_tetromino_engine is an implementation of a tetromino game engine, able to handle numerous modern
mechanics.
§Example
use falling_tetromino_engine::*;
// Starting up a game - note that in-game time starts at 0s.
let mut game = Game::builder()
.seed(1234)
/* ...Further optional configuration possible... */
.build();
// Updating the game with the info that 'left' should be pressed at second 4.2;
// If a piece is in the game, it will try to move left.
let input = Input::Activate(Button::MoveLeft);
game.update(InGameTime::from_secs_f64(4.2), Some(input));
// ...
// Updating the game with the info that no input change has occurred up to second 6.79;
// This updates the game, e.g., pieces fall and lock.
game.update(InGameTime::from_secs_f64(13.37), None);
// Read most recent game state;
// This is how a UI can know how to render the board, etc.
let State { board, .. } = game.state();[FIXME: Document all features in detail (including IRS, etc., cargo feature serde etc.).]
Re-exports§
pub use extduration::ExtDuration;pub use extnonnegf64::ExtNonNegF64;pub use modding::GameAccess;pub use modding::GameModifier;pub use randomization::TetrominoGenerator;pub use rotation::RotationSystem;
Modules§
- extduration
- A module that implements a minimalistic wrapper around
Duration, adding that it may be infinite. - extnonnegf64
- A module that implements a minimalistic wrapper around
f64, asserting that it is in the range+0.0 ≤ f ≤ +∞. - modding
- This module handles the modding facilities of the engine.
- randomization
- This module handles random generation of
Tetrominos. - rotation
- This module handles rotation of
Pieces.
Structs§
- Configuration
- Configuration options of the game, which can be modified without hurting internal invariants.
- Delay
Parameters - A struct holding information on how certain time ‘delay’ values progress during a game’s lifetime.
- Game
- Main game struct representing a round of play.
- Game
Builder - This builder exposes the ability to configure a new
Gameto varying degrees. - Game
Limits - Certain statistics for which an instance of
Gamecan be checked against. - Piece
- An active tetromino in play.
- State
- Struct storing internal game state that changes over the course of play.
- State
Initialization - Some values that were used to help initialize the game.
Enums§
- Button
- Represents an abstract game input.
- Game
EndCause - Represents how a game can end.
- Input
- A change in button state, between being held down or unpressed.
- Notification
- A number of feedback notifications that can be returned by the game.
- Notification
Level - The amount of feedback information that is to be generated.
- Orientation
- Represents the orientation an active piece can be in.
- Phase
- An event that is scheduled by the game engine to execute some action.
- Stat
- Certain statistics for which an instance of
Gamecan be checked against. - Tetromino
- Represents one of the seven “Tetrominos”;
- Update
Game Error - An error that can be thrown by
Game::update.
Functions§
- add
- Adds an offset to a coordinate, failing if the result overflows (negative or positive).
Type Aliases§
- Board
- The type of the entire two-dimensional playing grid.
- Buttons
State - Type describing the state that is stored about buttons.
- Coord
- Coordinates conventionally used to index into the
Board, starting in the bottom left. - Coord
Offset - Coordinates offsets that can be
added toCoordinates. - GameRng
- The internal RNG used by a game.
- InGame
Time - The type used to identify points in time in a game’s internal timeline.
- Line
- The type of horizontal lines of the playing grid.
- Notification
Feed - Type alias for a stream of notifications with timestamps.
- Tile
TypeID - Abstract identifier for which type of tile occupies a cell in the grid.