Levels
In this lesson, we will add levels with faster gameplay and more points to the Tetris game. Additionally, we will help the players by adding a Canvas showing the next piece.
We'll cover the following...
When we get better at Tetris, the start speed becomes too easy. Too easy means boring, so we need to increase the level of difficulty. We can do this by increasing the gravity so that the tetromino drops faster.
Let’s start by declaring some constants. First, we can configure how many lines it takes to advance to the next level. Next, we can add an object in which we match each level to the number of milliseconds it takes for each drop:
// const.js
const LINES_PER_LEVEL = 10;
const LEVEL = {
0: 800,
1: 720,
2: 630,
3: 550,
// ...
}
Object.freeze(LEVEL);
Another option here could be to increase the level of ...
Ask