21 lines
661 B
C++
21 lines
661 B
C++
// 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
|
|
};
|