Let's start with the UI rendering first and then add the font management in order to display the game information in real time.
With the current code base, very few changes are required in order to be able to have a fully working Tetris.
For now, the main
function is very small. First, let's add the following lines at the top of the function:
let sdl_context = sdl2::init().expect("SDL initialization failed"); let video_subsystem = sdl_context.video().expect("Couldn't get SDL video subsystem"); let width = 600; let height = 800;
No need for explanations, we've already explained everything in the previous chapters, so let's continue.
Just after the following lines:
let sdl_context = sdl2::init().expect("SDL initialization failed"); let mut tetris = Tetris::new(); let mut timer = SystemTime::now(); let mut event_pump = sdl_context.event_pump().expect("Failed to get SDL...