Refactor/game over screen (#468)
* Move game over (win/lose) state functions to their own file * remove unused enum * clang format * Implement suggestions from @ricfehr3 * Fixing lack of highlighted button after skipping ablind * factorize as much game over state code as possible --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
This commit is contained in:
@@ -8,6 +8,6 @@ DEF_STATE_INFO(GAME_STATE_PLAYING, game_round_on_init, game_playing
|
||||
DEF_STATE_INFO(GAME_STATE_ROUND_END, noop, game_round_end_on_update, game_round_end_on_exit )
|
||||
DEF_STATE_INFO(GAME_STATE_SHOP, noop, game_shop_on_update, game_shop_on_exit )
|
||||
DEF_STATE_INFO(GAME_STATE_BLIND_SELECT, game_blind_select_on_init, game_blind_select_on_update, game_blind_select_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_LOSE, game_lose_on_init, game_lose_on_update, game_over_on_exit )
|
||||
DEF_STATE_INFO(GAME_STATE_WIN, game_win_on_init, game_win_on_update, game_over_on_exit )
|
||||
DEF_STATE_INFO(GAME_STATE_LOSE, game_lose_on_init, game_over_on_update, game_over_on_exit )
|
||||
DEF_STATE_INFO(GAME_STATE_WIN, game_win_on_init, game_over_on_update, game_over_on_exit )
|
||||
// clang-format on
|
||||
|
||||
@@ -134,6 +134,17 @@ typedef struct
|
||||
|
||||
// Game functions
|
||||
void game_init();
|
||||
|
||||
/**
|
||||
* @brief Called when exiting the Game Over screen (both win or lose) to reset game variables
|
||||
* and start a fresh new run.
|
||||
*
|
||||
* WARNING: This function is currently only meant to be called from the "GAME_OVER" state
|
||||
* and shouldn't be called from other states, otherwise some data such as shop jokers
|
||||
* may not be properly reset.
|
||||
*/
|
||||
void game_reset();
|
||||
|
||||
void game_update();
|
||||
void game_change_state(enum GameState new_game_state);
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file game_over.h
|
||||
*
|
||||
* @brief Game Over screen state functions
|
||||
*/
|
||||
#ifndef GAME_OVER_H
|
||||
#define GAME_OVER_H
|
||||
|
||||
/**
|
||||
* @brief Game Over screen state initialization when losing
|
||||
*/
|
||||
void game_lose_on_init(void);
|
||||
|
||||
/**
|
||||
* @brief Game Over screen state initialization when winning
|
||||
*/
|
||||
void game_win_on_init(void);
|
||||
|
||||
/**
|
||||
* @brief Game Over screen state update
|
||||
*/
|
||||
void game_over_on_update(void);
|
||||
|
||||
/**
|
||||
* @brief Game Over screen cleanup, common to both losing and winning
|
||||
*/
|
||||
void game_over_on_exit(void);
|
||||
|
||||
#endif // GAME_OVER_H
|
||||
Reference in New Issue
Block a user