Introduction

Welcome! Today, we’re diving into the world of classic games with a modern twist. Why Rust and Slint? Because I wanted to try Slint and already implemented Snake in Go+HTMX.

Repository: https://github.com/Erik7354/slint_minesweeper

Project Structure

slint_minesweeper/
├── src/
│   ├── main.rs
│   ├── minesweeper.rs
│   └── ui.rs
├── ui/
│   ├── icon/
│   ├── main.slint
│   └── tile.slint
├── build.rs
├── Cargo.toml
├── index.html
└── README

src/

main.rs contains two entry points for our app - one for the desktop and one for the web. The web version uses web_sys to read the query parameters as settings for the game. The parameters are width, height and mine_count. minesweeper.rs contains all game logic.

ui/

main.slint contains the ui definitions for the main window, mine counter, timer and game field. The field consists of tiles which are founed in tile.slint.

Some Screenshots

“desktop Version” Running natively…

“solved” Solved!

“WASM Version.” Final version running on WASM.