Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

The game must be written entirely in C. Overview This game is inspired by the retro bomberman game, but it is an oversimplified version. The

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

The game must be written entirely in C.

Overview This game is inspired by the retro bomberman game, but it is an oversimplified version. The game consists of a 2D board of hidden rewards and scores. The scores are represented as floating point numbers, positive and negative. The board tiles are randomly populated by these numbers. In addition, the board has an exit tile and reward tiles that double the range of a bomb. When the user uncovers the exit tile, the game is won. The player starts with three lives and a score of zero and a specific number of bombs. S/He chooses a cell to place a bomb. The bomb explodes uncovering the immediate bordering tiles to the bomb. The user's score is updated as the sum of all the values of the uncovered tiles. If the score becomes negative a life is lost and the number of lives is decremented. If a reward tile is uncovered, the bomb range is doubled: it will be able to uncover the immediately surrounding tiles and their immediately surrounding tiles. Unlike the original game, the bomb never kills the bomberman. The game ends in one of three cases: when the score becomes less than or equal to zero and the lives are zeroed, when the player uncovers the exit tile on the board, or the total number of bombs is exhausted before uncovering the exit tile. When the user starts a new life, the total number of bombs is maintained from the previous life and the score is zeroed. There is no need for a graphical interface. Details The user starts the game by specifying a player name and the dimensions of the game board. These will be NxM grids. The minimum value of N and M is 10 and there is no maximum, as long as the game board can be fit on the screen. For example, the following command line invocation starts the game with a 100x200 grid: ./mygame.o bomberman 100 200 The grid is then initialized with random floating numbers with two precision points, ensuring that no more than 20% of the cells are negative. These numbers should be non-zero with a maximum absolute value of 15. You must use bitwise arithmetic to calculate the modulus of the random numbers. To help with grading, display the uncovered game board, showing all the contents of the tiles and also stating the ratio of negative tiles. Therefore, if the board is 3x4 (Remember: the minimum value of N and Mis 10 and there is no maximum) your program should display something like the following before the actual game starts: 1.00 -2.10 $ 0.50 1.00 -2.10 $ 14.00 7.20 -1.10 0.70 * 5.00 0.50 12.00 4.01 Total negative numbers 2/12 = 16.66% less than 20% The normal (covered) game board is then displayed. We will give an example using 5x5 grid (such a board size is too small to result in a meaningful game). The initial screen will look like the following (note that the number of bombs needs to be appropriate for the game board size): XXXXX XXXXX XXXXX XXXXX XXXXX Lives: 3 Score: 0 Bombs: 3 Prompt the user to choose a tile to place the bomb by entering its coordinates, such as: Enter bomb position (x, y): 0 1 The move is applied, and the resulting game state is shown again (+ indicates a positive score and a negative score). For example: Total uncovered score of 5.23 points ++-XX -++XX XXXXX XXXXX XXXXX Lives: 3 Score: 5.34 Bombs: 2 A bomb-range-doubled reward is represented by a dollar ($) symbol. For example, if tile 1 1 contains such a reward, the response to placing the bomb in tile 0 1 above may look like: Bang!! Your bomb range is doubled Total uncovered score of 5.23 points ++-XX -$+XX XXXXX XXXXX XXXXX Lives: 3 Score: 5.34 Bombs: 2 Since a $ is uncovered, the next bomb will have a double-range effect. This effect lasts for one bomb only. The exit tile is represented using the * symbol. In addition the game may utilize other surnrise nacks. These will be given bonus points and it is left to In addition, the game may utilize other surprise packs. These will be given bonus points and it is left to your creativity to choose such packs. No bonus points will be given to surprise pack if the double-range- effect feature is not implemented. The user can choose at any time to exit the game. When the game ends with a win or a loss, the player's name, score, and duration of the play are recorded in a log file. A user can also ask to display the top n scores before or after any game, including player names and duration. Modularity Your code must be divided into functions as appropriate. At a minimum, you must define the following functions (we are not showing all necessary arguments): initializeGame (*board) randomNum (n, m, neg); n and m are the lower and upper bounds for the random number; the generated number is negative if neg is true. displayGame (*board) calculateScore (), returns overall score logScore () exitGame ) displayTopScores (n) Overview This game is inspired by the retro bomberman game, but it is an oversimplified version. The game consists of a 2D board of hidden rewards and scores. The scores are represented as floating point numbers, positive and negative. The board tiles are randomly populated by these numbers. In addition, the board has an exit tile and reward tiles that double the range of a bomb. When the user uncovers the exit tile, the game is won. The player starts with three lives and a score of zero and a specific number of bombs. S/He chooses a cell to place a bomb. The bomb explodes uncovering the immediate bordering tiles to the bomb. The user's score is updated as the sum of all the values of the uncovered tiles. If the score becomes negative a life is lost and the number of lives is decremented. If a reward tile is uncovered, the bomb range is doubled: it will be able to uncover the immediately surrounding tiles and their immediately surrounding tiles. Unlike the original game, the bomb never kills the bomberman. The game ends in one of three cases: when the score becomes less than or equal to zero and the lives are zeroed, when the player uncovers the exit tile on the board, or the total number of bombs is exhausted before uncovering the exit tile. When the user starts a new life, the total number of bombs is maintained from the previous life and the score is zeroed. There is no need for a graphical interface. Details The user starts the game by specifying a player name and the dimensions of the game board. These will be NxM grids. The minimum value of N and M is 10 and there is no maximum, as long as the game board can be fit on the screen. For example, the following command line invocation starts the game with a 100x200 grid: ./mygame.o bomberman 100 200 The grid is then initialized with random floating numbers with two precision points, ensuring that no more than 20% of the cells are negative. These numbers should be non-zero with a maximum absolute value of 15. You must use bitwise arithmetic to calculate the modulus of the random numbers. To help with grading, display the uncovered game board, showing all the contents of the tiles and also stating the ratio of negative tiles. Therefore, if the board is 3x4 (Remember: the minimum value of N and Mis 10 and there is no maximum) your program should display something like the following before the actual game starts: 1.00 -2.10 $ 0.50 1.00 -2.10 $ 14.00 7.20 -1.10 0.70 * 5.00 0.50 12.00 4.01 Total negative numbers 2/12 = 16.66% less than 20% The normal (covered) game board is then displayed. We will give an example using 5x5 grid (such a board size is too small to result in a meaningful game). The initial screen will look like the following (note that the number of bombs needs to be appropriate for the game board size): XXXXX XXXXX XXXXX XXXXX XXXXX Lives: 3 Score: 0 Bombs: 3 Prompt the user to choose a tile to place the bomb by entering its coordinates, such as: Enter bomb position (x, y): 0 1 The move is applied, and the resulting game state is shown again (+ indicates a positive score and a negative score). For example: Total uncovered score of 5.23 points ++-XX -++XX XXXXX XXXXX XXXXX Lives: 3 Score: 5.34 Bombs: 2 A bomb-range-doubled reward is represented by a dollar ($) symbol. For example, if tile 1 1 contains such a reward, the response to placing the bomb in tile 0 1 above may look like: Bang!! Your bomb range is doubled Total uncovered score of 5.23 points ++-XX -$+XX XXXXX XXXXX XXXXX Lives: 3 Score: 5.34 Bombs: 2 Since a $ is uncovered, the next bomb will have a double-range effect. This effect lasts for one bomb only. The exit tile is represented using the * symbol. In addition the game may utilize other surnrise nacks. These will be given bonus points and it is left to In addition, the game may utilize other surprise packs. These will be given bonus points and it is left to your creativity to choose such packs. No bonus points will be given to surprise pack if the double-range- effect feature is not implemented. The user can choose at any time to exit the game. When the game ends with a win or a loss, the player's name, score, and duration of the play are recorded in a log file. A user can also ask to display the top n scores before or after any game, including player names and duration. Modularity Your code must be divided into functions as appropriate. At a minimum, you must define the following functions (we are not showing all necessary arguments): initializeGame (*board) randomNum (n, m, neg); n and m are the lower and upper bounds for the random number; the generated number is negative if neg is true. displayGame (*board) calculateScore (), returns overall score logScore () exitGame ) displayTopScores (n)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Accounting

Authors: Karen W. Braun, Wendy M. Tietz

5th edition

978-0134128528

Students also viewed these Finance questions