November 2019
Beginner
436 pages
8h 52m
English
In the update calls, we have been incrementing the position of the ship sprite by 2. In real life, however, you may want to store that value as a global constant or a centralized setting. In this case, changing the overall speed means that we need to update a single constant or variable, instead of refactoring the whole game.
We have already moved the screen size into constants; let's do the same with the speed:
const screenWidth = 800; const screenHeight = 600; const shipSpeed = 2;
Read now
Unlock full access