Search⌘ K
AI Features

Levels

Explore how to implement a level system in your JavaScript Tetris game by increasing drop speed as players clear lines. Understand how to track and display levels, reset game states, and introduce the next tetromino piece for strategic gameplay improvements.

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,  
  // ... 
...