Sidequest

Title State

Lets make a final change and only render the score after we start the game.

In main.ts modify the frame() function:

1
// ...
2
3
const frame = (hrt: DOMHighResTimeStamp) => {
4
// ...
5
6
bird.draw(context);
7
pipeManager.draw(context);
8
ground.draw(context);
-
scoreManager.draw(context);
10
+
if (game.state !== GameState.Title) {
+
scoreManager.draw(context);
+
}
14
15
last = hrt;
16
17
requestAnimationFrame(frame);
18
};
19
20
// Start the game loop.
21
requestAnimationFrame(frame);

This will remove a little clutter from the title screen in preparation for the title screen graphic.