The project

Before making this project, I’d used Unity game engine for making a couple of games like Tetris by following some Youtube tutorials. Also, I made Space Shooter during HackUPC2021, but I wasn’t on my own. Now I wanted to do a project on my own and decided to start with a simple game. Minesweeper was a good candidate as it didn’t seem too complex. I didn’t reinvent the wheel and made a clone of minesweeper.

How it works

Basically I defined a matrix with a fixed size and with the help of a random number generator, mines are placed randomly across the board. Each cell has some parameters like a boolean to check if it has a flag, if it’s opened, an integer that determines the number of mines next to it, etc. Each state of the cell has its own sprite. When the game detects a mouse click in a cell, the game updates the cell state and shows a new sprite corresponding to its new state. This was the most complex part of this project, it wasn’t too hard. To open the adjacent cells when there’s no mine in a cell, I made a dfs algorithm.

View Code on Github

for Windows 64bit