Program Description
Assumptions:
- The program was downloaded to an SD card, and that SD card was inserted in to the Proteus.
- The user has a basic knowledge of the Proteus and the game, Minesweeper.
- The Proteus is fitted with two button boards, one in port 0 the other in port 2.
Variables:
1. Again(bool): used to keep track of whether the user wants to play again or not. If again=true, then the user would like to play again; if again=false, then the user would not like to play again.
2.Diff (int): used to determine the level of difficulty based on user input. If diff=1, then the level of difficulty is easy; if diff=2 then the level of difficulty is hard.
3. X(int): used to set the number of columns
4. Y (int): used to set the number of rows.
5. z (int) : is generated randomly from number 0, 1, 2, and 3 for each cell. If z=3 for a specific cell, then bombs[x][y] for that cell is set equal to 1, x being the column number, and y being the row number for that cell. If z doesn’t equal 3 for a specific cell then bombs[x][y] is set equal to 0 for that cell.
6. Game(int): used to determine if a player has hit a bomb and lost the game or not. If game=1, then the player has not yet chosen a mined box, or has not yet cleared the entire board; if game=0, then the player has either just chosen a mined box or just cleared the entire board without hitting a bomb, and the game ends.
7.x_pos(int): used to keep track of the chosen row by the user.
8. y_pos(int):used to keep track of the chosen column by the user.
9.wins(int):used to keep track of the wins.
10.loss(int):used to keep track of losses.
11.c(int): used to keep track of user input when asked to play again.
Functions:
1. void printboard(int , int ): A function used to print the initial board for the game. The parameter of the function is two int values representing the number of columns and rows respectively.
2. void choose (int* , int*): A function used to call RC() and set the value of the two passed int depending on the return from RC(). The parameter of the function is two integer pointers.
3. int RC(): A function used to translate the button input into a row/column number. The parameter of the function is null, and the return of the function is an integer representing which column/row was picked by the user.
4.void check (int *, int , int, int , int, int *): A function used to check if the player picked a mined box. If the player chose a mined box, the function displays a losing picture and sets the value of game to zero to end the game. Otherwise, the function set the value of game to one and the game continues. The parameter of the function is as follow:
a. An int array pointer for the board array
b. An int value representing the number of columns
c. An int value representing the number of rows
d. An int value representing the picked column
e.An int value representing the picked row
f.An int pointer to the game variable.
5.void display (int*, int *, int , int): A function used to print the active board with the chosen boxes revealed. The parameter of the function is as follow:
a.An int array pointer for the board array
b.An int array pointer for the bombs array
c.An int representing the number of columns
d.An int representing the number of rows
6. void win (int *, int, int , int *, int *): A function used to determine if the player has cleared the entire board without hitting a bomb. If so, the function prints a victory game and sets the value of game to zero to end the game and increments the number of wins by one. The parameter of the function is as follow:
a.An int array pointer for the board array
b.An int representing the number of columns
c.An int representing the number of rows
d.An int pointer to the game variable
e.An int pointer to the wins variable
7. void flagger (int *, int m): A functions used to flag a cell when called. The cell is determined by calling upon the RC() function inside. The parameter of the function is as follows:
a.An int array pointer for the board array
b.An int representing the number of columns
BETA TEST FEEDBACK:
- The team liked the idea of the game and how the board is totally randomized
- The team pointed out that some of the words ran on two different lines which looked unprofessional
- The issue was solved by splitting long printed sentences into two WriteLine() calls
- The team pointed out that the instructions on the homepage were unclear and the functions of the buttons are not clear
- The issue was solved by adding more clear and detailed instructions on the home screen describing the function of each button
- The team also thought there is a “lag” in the time between picking a column and a row, as well as in the beginning of the code
- The “lag” was due to a Sleep() call that was apparently too long. The issue was solved by cutting the time of each Sleep() into half which made the game run smoother than before.