Enum poke_a_mango::ops::GameState
[−]
[src]
pub enum GameState {
MainMenu,
ChooseDifficulty,
Playing {
difficulty: Difficulty,
score: u64,
fruit: Option<usize>,
},
GameOver {
difficulty: Difficulty,
score: u64,
name: String,
},
GameEnded {
name: String,
score: u64,
},
LoadLeaderboard,
DisplayLeaderboard(Vec<Leader>),
Exit,
}Game's all possible states.
Widgets::update() takes care of proper state transformation.
Variants
MainMenuDisplay the main menu.
Main menu contains a Start button, a button to Display Highscores, an Exit button.
Can transform into:
ChooseDifficultyDisplayHighscoresExit
ChooseDifficultyDisplay the screen where the player chooses the difficulty.
The screen contains one button for each difficulty and the Back button.
Can transform into:
PlayingMainMenu
PlayingThe game is currently in progress.
This also contains the game's difficulty, the player's current score and whether the current fruit is a mango.
Can transform into GameOver.
Fields of Playing
difficulty: Difficulty | The game difficulty, as chosen in the |
score: u64 | The user's current score. |
fruit: Option<usize> | The current fruit index. If |
GameOverThe game was lost after a valiant battle.
Contains the game's difficulty, the player's final score and the Back button.
In this stage the player enters its name.
Can transform into:
GameEndedMainMenu
Fields of GameOver
difficulty: Difficulty | The game difficulty, as same as in the |
score: u64 | The user's final score. |
name: String | The user's name, mostly partial. |
GameEndedThe game cycle has ended. Semi-meta-state
Contains the game's difficulty and the players final score.
In this stage the player enters its name.
Transforms into MainMenu.
Fields of GameEnded
name: String | The user's name. |
score: u64 | User's final score, weighted. |
LoadLeaderboardMeta-state indicating that the leaderboard needs to be loaded.
Needs to be handled in usercode, place the leaderboard into DisplayLeaderboard after loading it.
Leaderboards are loaded via Leader::load().
Transforms into DisplayLeaderboard
DisplayLeaderboard(Vec<Leader>)Display top 10 high scores.
This screen also contains the Back button.
Can transform into MainMenu
ExitPseudo-state, signifying that the game window should be closed.
Can transform into: nothing. This is the final state all others seek.
Methods
impl GameState[src]
pub fn should_exit(&self) -> bool[src]
Check whether this state currently means that the game has ended.
Examples
assert!(GameState::Exit.should_exit());
pub fn should_load_leaderboard(&self) -> bool[src]
Check whether this state requires usercode to load the leaderboard.
Examples
assert!(GameState::LoadLeaderboard.should_load_leaderboard());
Trait Implementations
impl Debug for GameState[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl Clone for GameState[src]
fn clone(&self) -> GameState[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl PartialEq for GameState[src]
fn eq(&self, __arg_0: &GameState) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &GameState) -> bool[src]
This method tests for !=.
impl Eq for GameState[src]
impl PartialOrd for GameState[src]
fn partial_cmp(&self, __arg_0: &GameState) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, __arg_0: &GameState) -> bool[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, __arg_0: &GameState) -> bool[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, __arg_0: &GameState) -> bool[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, __arg_0: &GameState) -> bool[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for GameState[src]
fn cmp(&self, __arg_0: &GameState) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more