Its a C programming box game that allow the player to push the box into the goal. I also implement a pull function for user to pull the box
Below is a brief what it will happen inside the box program if it is execute.
-
I have implement a check function to check the input count of the argument and argument array from the user.
-
The program will continue if the check is true or else the program will be exit with error print to the user.
-
Map row and column will be increment by 2 which include the border space.
-
At the same time the player and goal row and column also increment by 1 to secure them within the map.
-
Next, the function boxLocation() will be call to generate the random row and column of the box inside the map.
-
The mapArray will be malloc() as 2D char array.
-
While loop is implement to iterate if the box location and goal location is not the same.
-
Inside the while loop, function map() will be call to store map, player, goal and box location within 2D mapArray.
-
Function mapPrint() will be call to print the map to the user.
-
Row and column difference of player and box will be calculate.
-
After the user input the character, another if-else will undergo to check whether the differenece of player and box row or column is equal to 1 (which next to each other).
-
If true, then the player will move with the character input by the user and calculate again the row and column difference of the player and box.
-
Another if-else will check the location of player and box is the same or not.
-
If true, the function push() will be call to move the box in the direction of the player move.
-
I have implement another if-else with #ifdef for the user to call the function pull() to pull the box if user enter "make PULL=1".
-
If the PULL function is define, then function pull() will be call to pull the box forward to direction of the player move.
-
If the box and goal location are the same, end of the while loop.
-
Function map() and function mapPrint() will be call again to show the user has win the game.
-
The 2D map array malloc() will be free and end the program.