January 2018
Beginner to intermediate
454 pages
10h 8m
English
The next two being strongly bound (the level depends directly on the number of lines sent), we'll implement them at the same time.
Before doing anything else, let's define the two following const:
const LEVEL_TIMES: [u32; 10] = [1000, 850, 700, 600, 500, 400, 300, 250, 221, 190]; const LEVEL_LINES: [u32; 10] = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200];
The first one corresponds to the times before the current tetrimino descends by one block. Each case being a different level.
The second one corresponds to how many lines the player needs before getting to the next level.
Next, let's add the following method in our Tetris type:
fn increase_line(&mut self) { self.nb_lines += 1; if self.nb_lines > LEVEL_LINES[self ...
Read now
Unlock full access