June 2021
Beginner
344 pages
8h 9m
English
Currently, the Heads-Up Display shows the player’s health and current inventory, but it doesn’t indicate the player’s current level. Adding the current level to the HUD can help players feel a sense of achievement when they see the number go up, so let’s add it.
The hud_system handles Heads-Up Display rendering. Open systems/hud.rs, and add the following code (just before you start displaying the player’s inventory):
| ① | let (player, map_level) = <(Entity, &Player)>::query() |
| | .iter(ecs) |
| | .find_map(|(entity, player)| Some((*entity, player.map_level))) |
| | .unwrap(); |
| | |
| ② | draw_batch.print_color_right( |
| | Point::new(SCREEN_WIDTH*2, 1), |
| ③ | format!( ... |
Read now
Unlock full access