This application state is closely related to the class score. It is therefore necessary to develop them together. Start with the code for the application state:
bool scoreUpdate() {
return true;
}
5void scoreDraw() {}
State ScoreState(scoreUpdate, scoreDraw);
Create a separate code file for the class score. The framework for this class looks like this:
class score
{
private:
int points;
5 int level ;
bool won ;
float speed ;
void checkWin() {}
10
public:
void init ( ) {}
void addPoints (int value) {}
float getSpeed ( ) C {}
15 int getPoints ( ) C {}
int getLevel ( ) C {}
bool hasWon ( ) C {}
void gameIsLost( ) {}
20}
score Score;
As you can see, this class contains four values: points, level, won and speed. The latter does not really have anything to do with the score. But because the speed depends on the level, it is convenient to put it together with the rest. For example, the score object may also increase the speed when needed.