Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
highScores.h
Go to the documentation of this file.
1
26
27#pragma once
28
29#include "linked_list.h"
30#include "swadgePass.h"
31
32#include <stdbool.h>
33#include <stdint.h>
34
35#define MAX_HIGH_SCORE_COUNT 20
36
48
59
67void initHighScores(highScores_t* hs, const char* nvsNamespace);
68
79bool updateHighScores(highScores_t* hs, const char* nvsNamespace, score_t newScores[], uint8_t numNewScores);
80
90void saveHighScoresFromSwadgePass(highScores_t* hs, const char* nvsNamespace, list_t swadgePasses,
91 int32_t (*fnGetSwadgePassHighScore)(const swadgePassPacket_t* packet));
92
101void addHighScoreToSwadgePassPacket(const char* nvsNamespace, swadgePassPacket_t* packet,
102 void (*fnSetSwadgePassHighScore)(swadgePassPacket_t* packet, int32_t highScore));
103
114
#define NVS_KEY_NAME_MAX_SIZE
Definition hdw-nvs.h:59
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 per...
Definition highScores.c:22
#define MAX_HIGH_SCORE_COUNT
Definition highScores.h:35
char spKey[NVS_KEY_NAME_MAX_SIZE]
Definition highScores.h:43
int32_t userHighScore
Definition highScores.h:55
int32_t score
The point value of this score. This will be 0 for uninitialized scores.
Definition highScores.h:40
score_t highScores[MAX_HIGH_SCORE_COUNT]
High score list, sorted from high to low.
Definition highScores.h:57
swadgesonaCore_t swadgesona
Definition highScores.h:46
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....
Definition highScores.c:102
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 y...
Definition highScores.c:123
void initHighScores(highScores_t *hs, const char *nvsNamespace)
Load high score data from NVS.
Definition highScores.c:15
void initHighScoreSonas(highScores_t *hs, swadgesona_t sonas[])
Load the usernames and Swadgesona images for the high score table into memory. When you are finished ...
Definition highScores.c:131
uint8_t highScoreCount
Number of high scores to save. Defaults to MAX_HIGH_SCORE_COUNT if not set.
Definition highScores.h:52
void freeHighScoreSonas(highScores_t *hs, swadgesona_t sonas[])
Free memory used for Swadgesona images.
Definition highScores.c:161
Definition highScores.h:50
Definition highScores.h:38
A doubly linked list with pointers to the first and last nodes.
Definition linked_list.h:87
struct swadgePassPacket swadgePassPacket_t
A SwadgePass packet which is transmitted over ESP NOW.
This struct is saved to the NVS. It should contain the bare minimum required to reconstruct a swadges...
Definition swadgesona.h:509
Larger data for use of use.
Definition swadgesona.h:536