v1.0.0
Lets make a final change and only render the score after we start the game.
In main.ts modify the frame() function:
main.ts
frame()
src/main.ts1// ...2 3const 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.21requestAnimationFrame(frame);
1// ...2 3const 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.21requestAnimationFrame(frame);
This will remove a little clutter from the title screen in preparation for the title screen graphic.