DEV Community

Cover image for Bevy Minesweeper: Marking Tiles

Bevy Minesweeper: Marking Tiles

Qongzi on February 21, 2022

Check the repository Our minesweeper plugin is almost done, we still miss a very important feature: Marking tiles. Also, you may notice that the...
Collapse
 
hohenheim profile image
Jan Hohenheim • Edited

On nightly, we can simplify unmark_tile:

fn unmark_tile(&mut self, coordinates: Coordinates) -> Option<Coordinates> {
    self.marked_tiles
        .drain_filter(|marked_coordinates| *marked_coordinates == coordinates)
        .next()
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
qongzi profile image
Qongzi

I think we can simplify further by changing marked_tiles type to a HashSet which would make more sense and allow immediate access and removal

Collapse
 
leonidv profile image
Leonid Vygovskiy

github.com/leonidv/bevy-minesweepe... - full tutorial updated to 12.1. One chapter per commit.