Project Overview
MineSweeper
An 11×8 VB.NET Windows Forms game featuring randomized mine placement, multiple difficulty levels, recursive tile-reveal logic, player avatars, completion tracking, and SQLite high-score storage.
VB.NET
Windows Forms
SQLite


Language
VB.NET

Application
Desktop

Tools
Visual Studio 22

Status
Complete
From Code to Interface
Public Sub RevealEmptyTile(board As Gameboard, minefieldForm As Minefield, x As Integer, y As Integer)
If board.IsInsideBoard(x, y) = False Then
Exit Sub
End If
If board.placedMines(x, y) Then
Exit Sub
End If
If board.revealedCells(x, y) Then
Exit Sub
End If
If board.flaggedGrid(x, y) Then
Exit Sub
End If
If board.maybeGrid(x, y) Then
Exit Sub
End If
board.revealedCells(x, y) = True
If board.placedProximityNums(x, y) = 0 Then
FormatEmptyCells(board, x, y)
End If
If board.placedProximityNums(x, y) > 0 Then
RevealProximityFlag(board, minefieldForm, x, y)
Exit Sub
End If
For subset As Integer = 0 To xOffsets.Length - 1
Dim checkX As Integer = x + xOffsets(subset)
Dim checkY As Integer = y + yOffsets(subset)
RevealEmptyTile(board, minefieldForm, checkX, checkY)
Next
End Sub
Public Sub PlaceMines(board As Gameboard)
'Dim RNG As New Random(12345)
Dim RNG As New Random()
Dim placedMineGrid(board.horizontalSize - 1, board.verticalSize - 1) As Boolean
Dim minesPlaced As Integer = 0
While minesPlaced < board.mineCount
Dim randomX As Integer = RNG.Next(0, board.horizontalSize)
Dim randomY As Integer = RNG.Next(0, board.verticalSize)
If placedMineGrid(randomX, randomY) = False Then
placedMineGrid(randomX, randomY) = True
minesPlaced += 1
End If
End While
board.placedMines = placedMineGrid
End Sub
Public Sub CheckWinCondition(board As Gameboard, minefieldForm As Minefield)
If CheckAllCells(board) Then
minefieldForm.ScoreTimerStop()
board.player.completionTime = minefieldForm.currentTime
board.player.completionMilli = board.player.TimeSpanToMilliseconds(minefieldForm.currentTime)
For col As Integer = 0 To board.horizontalSize - 1
For row As Integer = 0 To board.verticalSize - 1
If board.revealedCells(col, row) = False AndAlso board.placedMines(col, row) = False Then
If board.placedProximityNums(col, row) > 0 Then
RevealProximityFlag(board, minefieldForm, col, row)
Else
RevealEmptyTile(board, minefieldForm, col, row)
End If
End If
Next
Next
minefieldForm.quitBtn.Text = "Main Menu"
minefieldForm.quitBtn.TextAlign = ContentAlignment.MiddleCenter
minefieldForm.quitBtn.Image = Nothing
MessageBox.Show("Congratulations! You cleared the minefield in " &
minefieldForm.currentTime.ToString("hh\:mm\:ss\.ff") & "!", "Mine Sweeper")
AddScore(board) 'Add score to db
For col As Integer = 0 To board.horizontalSize - 1
For row As Integer = 0 To board.verticalSize - 1
If board.flaggedGrid(col, row) Then
board.cellGrid(col, row).Enabled = False
End If
Next
Next
End If
End Sub

Project Capabilities
Key Features

Dynamic Minefield
Generates an interactive 11×8 button grid and randomly places mines according to the selected difficulty.

Recursive Tile Reveals
Automatically opens connected empty cells while displaying color-coded numbers for nearby mines.

Flags & Markers
Allows players to cycle covered cells between flagged, uncertain, and unmarked states while tracking remaining mines.

Difficulty & High Scores
Provides Easy, Medium, Hard, and Insane difficulty levels and stores the fastest completion times in SQLite.
Technical Deep Dive
Technical Implementation & Challenges
Technical Implementation

Dynamic Windows Forms grid • Multidimensional state arrays • Event-driven mouse controls • Recursive empty-cell reveal • Boundary validation • Stopwatch-based timing • SQLite score persistence
Challenges & Solutions

Managing Game State
Separate two-dimensional arrays track mines, revealed cells, flags, uncertain markers, proximity values, and button controls. Keeping these arrays synchronized ensures that the interface accurately represents the underlying game state.
Screenshots
Project Screens & Forms




Project Reflection
Growth, Lessons & Next Steps

What I Learned
Building Minesweeper strengthened my understanding of multidimensional arrays, recursive algorithms, event-driven interface design, and separating game state from visual controls. It also reinforced the importance of boundary validation and focused helper methods when debugging interconnected game logic.

Future Improvements
Future versions could include first-click protection, configurable board dimensions, additional visual and sound feedback, persistent player profiles, and high-score filtering by difficulty.