This page shows two classics as are the minesweeper
and the snake
. The key feature here is that they logic behind them it's done in Rust
and binded with SvelteKit
using Web Assembly!
Welcome to the classic MineSweeper
! Just click the cells to open them! In case you want to put a red flag to mark a box, you can do it by pressing the right click (or long press in mobile devices). The big red button does what you could imagine, it resets the board.
The game is initialized and controlled by Rust code that is bridged to the JS world using the wasm_bindgen crate. Each time the component that contais the board, is mounted, it instantiates the wasm module.
Click the launch button to start the Snake
game! In this case, you need to use the AWSD keys to move the Snake and get the apples!
For this game, the HTML
code that renders the board is directly called from the Rust side. Same thing applies for the timer that moves the snake to the next position every 200ms.
The source code for both projects can be found clicking in the Snake and MineSweeper repos!