I can't reveal my source code - I have to protect my ultra secret game design! Just kidding ;)
I'm using 2 arrays - "game_board(y,x)" for the values in the puzzle (0 = blank, 9 = mine,1-6 = number of corners touching mines) and "visible(y,x)" for checking visibility (1 = revealed, 0 = obscured). y and x are obviously the current puzzle board square locations.
For example, this is the code I use to draw the board. I'm about to change all the if-thens to case-selects but you get the idea:
;Draw the puzzle out
For y = 1 To 28
For x = 1 To 27
new_x = x_start + (20 * (x - 1))
new_y = y_start + (20 * (y - 1))
If visible(y,x) = 0
DrawImage blank,new_x,new_y
Else
If game_board(y,x) = 0
DrawImage empty,new_x,new_y
ElseIf game_board(y,x) = 9
DrawImage mine,new_x,new_y
ElseIf game_board(y,x) = 1
DrawImage one,new_x,new_y
ElseIf game_board(y,x) = 2
DrawImage two,new_x,new_y
ElseIf game_board(y,x) = 3
DrawImage three,new_x,new_y
ElseIf game_board(y,x) = 4
DrawImage four,new_x,new_y
ElseIf game_board(y,x) = 5
DrawImage five,new_x,new_y
ElseIf game_board(y,x) = 6
DrawImage six,new_x,new_y
EndIf
EndIf
Next
Next
and here is the code I used to determine numerical values for each piece (based on if corners are touching mines. I suspect this is close the method I will need to cascade but I'm not certain:
;evaluate the puzzle and look for numerical values
For y = 1 To 28
For x = 1 To 27
;look at all 5 corners around the location
corners = 0
If Not game_board(y,x) = 9
;check upper left
If game_board(y-1,x-1) = 9 Then corners = corners + 1
;check upper
If game_board(y-1,x) = 9 Then corners = corners + 1
;check upper right
If game_board(y-1,x+1) = 9 Then corners = corners + 1
;check left
If game_board(y,x-1) = 9 Then corners = corners + 1
;check right
If game_board(y,x+1) = 9 Then corners = corners + 1
;check bottom left
If game_board(y+1,x-1) = 9 Then corners = corners + 1
;check bottom
If game_board(y+1,x) = 9 Then corners = corners + 1
;check bottom right
If game_board(y+1,x+1) = 9 Then corners = corners + 1
;write the board value
game_board(y,x) = corners
EndIf
Next
Next
I hope this answers any questions. I might compile all this into a beginners tutorial once I'm done so any help is much appreciated :)