Updated game structure
This commit is contained in:
20
src/persistence/Scores.h
Normal file
20
src/persistence/Scores.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Scores.h - High score persistence manager
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
struct ScoreEntry { int score{}; int lines{}; int level{}; double timeSec{}; std::string name{"PLAYER"}; };
|
||||
|
||||
class ScoreManager {
|
||||
public:
|
||||
explicit ScoreManager(size_t maxScores = 12);
|
||||
void load();
|
||||
void save() const;
|
||||
void submit(int score, int lines, int level, double timeSec);
|
||||
const std::vector<ScoreEntry>& all() const { return scores; }
|
||||
private:
|
||||
std::vector<ScoreEntry> scores;
|
||||
size_t maxEntries;
|
||||
std::string filePath() const; // resolve path (SDL pref path or local)
|
||||
void createSampleScores(); // create sample high scores
|
||||
};
|
||||
Reference in New Issue
Block a user