Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | NVS_KEY_USER_HIGH_SCORE "user_high_score" |
#define | NVS_KEY_HIGH_SCORES "high_scores" |
#define | HIGH_SCORE_COUNT(hs) |
Functions | |
void | initHighScores (highScores_t *hs, const char *nvsNamespace) |
Load high score data from NVS. | |
bool | updateHighScores (highScores_t *hs, const char *nvsNamespace, score_t newScores[], uint8_t numNewScores) |
Update the high score table and user high score with new scores from the player or SwadgePass and persist to NVS. This function handles sorting and limiting the number of scores, so no preprocessing is necessary. | |
void | saveHighScoresFromSwadgePass (highScores_t *hs, const char *nvsNamespace, list_t swadgePasses, int32_t(*fnGetSwadgePassHighScore)(const swadgePassPacket_t *packet)) |
Extract high score data received from SwadgePass and save to the high score table. This should be called from your mode's fnEnterMode function after calling initHighScores(). | |
void | addHighScoreToSwadgePassPacket (const char *nvsNamespace, swadgePassPacket_t *packet, void(*fnSetSwadgePassHighScore)(swadgePassPacket_t *packet, int32_t highScore)) |
Write high score data to SwadgePass packet for sending to other swadges. This should be called from your mode's fnAddToSwadgePassPacket function. | |
#define NVS_KEY_USER_HIGH_SCORE "user_high_score" |
#define NVS_KEY_HIGH_SCORES "high_scores" |
#define HIGH_SCORE_COUNT | ( | hs | ) |
void initHighScores | ( | highScores_t * | hs, |
const char * | nvsNamespace ) |
Load high score data from NVS.
hs | The struct that contains the high scores. highScores_t.highScoreCount should be set; other fields will be overwritten |
nvsNamespace | The NVS namespace to read saved high score data from |
bool updateHighScores | ( | highScores_t * | hs, |
const char * | nvsNamespace, | ||
score_t | newScores[], | ||
uint8_t | numNewScores ) |
Update the high score table and user high score with new scores from the player or SwadgePass and persist to NVS. This function handles sorting and limiting the number of scores, so no preprocessing is necessary.
hs | The struct that contains the high scores |
nvsNamespace | The NVS namespace to write data to |
newScores | Array of scores to add to the table |
numNewScores | Count of scores in the array |
true
if the high score table changed, false
if it didn't void saveHighScoresFromSwadgePass | ( | highScores_t * | hs, |
const char * | nvsNamespace, | ||
list_t | swadgePasses, | ||
int32_t(* | fnGetSwadgePassHighScore )(const swadgePassPacket_t *packet) ) |
Extract high score data received from SwadgePass and save to the high score table. This should be called from your mode's fnEnterMode
function after calling initHighScores().
hs | The highScores_t struct that contains the high scores |
nvsNamespace | The NVS namespace to write data to |
swadgePasses | A list_t of SwadgePasses from getSwadgePasses() |
fnGetSwadgePassHighScore | Pointer to a function that returns your mode's high score from a SwadgePass packet |
void addHighScoreToSwadgePassPacket | ( | const char * | nvsNamespace, |
swadgePassPacket_t * | packet, | ||
void(* | fnSetSwadgePassHighScore )(swadgePassPacket_t *packet, int32_t highScore) ) |
Write high score data to SwadgePass packet for sending to other swadges. This should be called from your mode's fnAddToSwadgePassPacket
function.
nvsNamespace | The NVS namespace to read data from |
packet | The SwadgePass packet to modify |
fnSetSwadgePassHighScore | Pointer to a function that sets your mode's high score field in a SwadgePass packet |