Minesweeper game developed with Rust, WebAssembly (Wasm), and Canvas

Overview

πŸ‘‰ click here to play the game πŸ‘ˆ

Minesweeper game

Revealing all the cells without hitting the mines is the task. Each number in the cell denotes how many bombs are in the adjacent cells (8 sides). You can mark any arbitrary cell with a flag.

This game is developed with Rust, WebAssembly (Wasm), and Canvas. Live demo available here

Screenshots

Screenshot 1 Screenshot 2

Functionality

  • βœ… The first click should always be an empty cell.
  • βœ… Right click on PC or long-press on touch devices should place the flag.
  • βœ… Clicking on SpongeBob should reset the game.
  • ⬜️ Option to select difficulty level.
  • ⬜️ Option to customize board size and mines count.

Contributing

Suggestions are always welcome

You might also like...
A space shooter game made with Amethyst and Rust.
A space shooter game made with Amethyst and Rust.

Theta Wave Project Introduction This game was made with the Amethyst engine. It is inspired by games like Raiden and The Binding of Isaac. Game Introd

Extensible open world rogue like game with pixel art. Players can explore the wilderness and ruins.
Extensible open world rogue like game with pixel art. Players can explore the wilderness and ruins.

Rusted Ruins Extensible open world rogue like game with pixel art. Players can explore the wilderness and ruins. This game is written in Rust. Screens

Planetoid is a toy project to demonstrate and learn several technologies. The goal is to create a little multiplayer asteriod game clone.
Planetoid is a toy project to demonstrate and learn several technologies. The goal is to create a little multiplayer asteriod game clone.

Planetoid is a toy project to demonstrate and learn several technologies. The goal is to create a little multiplayer asteriod game clone.

Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory
Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory

Mk48.io Game Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory. Watch out for torpe

A roguelike game in Rust
A roguelike game in Rust

A fantasy deathcrawl in Rust Work in progress. To run, with Rust compiler and Cargo package manager installed: cargo run --release When building on W

πŸ˜ βš”οΈπŸ˜ˆ A minimalistic 2D turn-based tactical game in Rust
πŸ˜ βš”οΈπŸ˜ˆ A minimalistic 2D turn-based tactical game in Rust

Zemeroth is a turn-based hexagonal tactical game written in Rust. Support: patreon.com/ozkriff News: @ozkriff on twitter | ozkriff.games | facebook |

⬑ Zone of Control is a hexagonal turn-based strategy game written in Rust. [DISCONTINUED]
⬑ Zone of Control is a hexagonal turn-based strategy game written in Rust. [DISCONTINUED]

Zone of Control The project is discontinued Sorry, friends. ZoC is discontinued. See https://ozkriff.github.io/2017-08-17--devlog.html Downloads Preco

This is a simple implementation of the classic snake game in rust
This is a simple implementation of the classic snake game in rust

My snake game Looks like this. This is with Roboto Mono Nerd Font. If you use a different font it may look different or distorted. Install rust In ord

The classic tetris game written in Rust using ncurses
The classic tetris game written in Rust using ncurses

tetris.rs This is the classic tetris game I wrote to have a bit of fun with Rust. Installation and playing cargo install --

Comments
  • Code rework suggestion

    Code rework suggestion

    I suggest reworking the Vec that holds cells in the board from cells: Vec<Vec<Cell>> to cells: Vec<Cell> and implementing an index calculating method, something like:

    fn get_index(&self, i: u32, j: u32) -> usize {
        (i * self.row + j) as usize
    }
    

    And from looking at the rest of the code, most of it would have to be modified to use this get_index method, when ever accessing or modifying cells. And creating the cells in the board should be just one long loop of for i in 0..(row * column)

    I also recommend reworking the bomb_near_cell method, to remove unnecessary recursive function, to something like:

    fn bomb_near_cell(&self, i: u32, j: u32) -> u8 {
        let mut count = 0;
        for delta_i in [self.heigh - 1, 0, 1].iter().cloned() {
            for delta_j in [self.width - 1, 0, 1].iter().cloned() {
                if (delta_i == 0 && delta_j == 0) || (delta_i < 0 || delta_j < 0 || delta_i > self.row || delta_j > self.column) {
                    continue;
                }
    
                let neighbor_i = (i + delta_i) % self.row;
                let neighbor_j = (j + delta_j) % self.column;
                let idx = self.get_index(neighbor_i, neighbor_j);
                count += self.cells[idx].is_bomb as u8 // This will work because bool casting to int is false = 0, true = 1
            }
        }
        count
    }
    

    This way we have no need of recursive calling of the bomb_near_cell method when checking the cells around the current one. No need for the search_end parameter.

    While JS is not my strong point, at quick glance, if correctly implemented these changes will not have any effect on the front end.

    opened by Finalgamer14 0
Owner
Karthik Nedunchezhiyan
Full stack developer || Rustacean πŸ¦€ || Distributed system || Cloud computing || Loves to work with Virtualization & Containerization || Open source contributor
Karthik Nedunchezhiyan
Minesweeper game where you only lose if the move is certainly wrong.

Non-deterministic Minesweeper Tired of having to guess in a game of minesweeper? Worry no more! This is a variation of Minesweeper game where you only

Lucas Clemente Vella 8 Aug 18, 2022
It's minesweeper

Minesweeper rs DOWNLOAD Features Adjustable width and height Adjustable mine count (using percentage) Adjustable colours Timer Area highlighting when

Wait What 11 Nov 16, 2022
Fish Game for Macroquad is an online multiplayer game, created as a demonstration of Nakama, an open-source scalable game server, using Rust-lang and the Macroquad game engine.

Fish Game for Macroquad is an online multiplayer game, created as a demonstration of Nakama, an open-source scalable game server, using Rust-lang and the Macroquad game engine.

Heroic Labs 130 Dec 29, 2022
2D real-time mutliplayer game in a browser. Showcase of the usability of wasm-peer crate.

Footballers Description 2D real-time multiplayer game in a browser. Players divided in two teams play a football match on field with two goal posts. G

null 10 Dec 22, 2022
The video game for Fonts of Power. A tabletop roleplaying game made in Rust with Bevy!

The code and rules for Fonts of Power, a tactical TTRPG / video game about exploring magical places. You can follow its development in our Discord ser

null 25 Dec 23, 2022
Red Light, Green Light is a traditional Korean children's game, popularised by the Squid Game TV series.

Red Light, Green Light Red Light, Green Light is a traditional Korean children's game, popularised by the Squid Game TV series. This project is the di

Cedric Chee 1 Jan 10, 2022
A game inspired by the classic atari game: demon attack

rusty_demon_attack A game inspired by the classic atari game: demon attack You can play the game in the web!

null 58 Jan 4, 2023
A collection of small games for the Fantasy Console WASM-4

WASM-4 Tutorial Games This repo contains the source code for different tutorial games for the Fantasy Console WASM-4. The goal is to provide a one-sto

Chris 15 Aug 10, 2022
Data-oriented and data-driven game engine written in Rust

What is Amethyst? Amethyst is a data-driven and data-oriented game engine aiming to be fast and as configurable as possible. Principles These principl

Amethyst Engine 7.9k Dec 31, 2022
A block game made in Rust and SFML

septadrop A block game made in Rust and SFML. For packaging instructions, see the build folder. Game Controls ??/?? arrow keys: horizontal movement ??

Elnu 1 Dec 19, 2022