Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The game of Minesweeper is a single-player puzzle game where the user is presented a grid of cells. Underneath the cells are a number of

image text in transcribed

The game of Minesweeper is a single-player puzzle game where the user is presented a grid of cells. Underneath the cells are a number of randomly placed mines. Consider the following screenshot of a game in process: @New Pause Settings 370 116 2 2 75 11 3 5 61 11 1 11221 525 5 11 55 134511 3663 315 22 15 111 53 1 442 11 3 44 1 4689 3 curvc Wikipedia In the above example, the user will click on each cell in the grid. If a mine is clicked, the game is immediately over and the player has lost. If the user didn't click on a mine, the a number is revealed to the user. This number is the number of mines in adjacent cells to the revealed number. Keep in mind that there are at-most eight cells adjacent to a cell. Corner cells only have three adjacent cells. Cells on the boundary of the game vary in count for adjacent neighboring cells. The game is won when the player has revealed all cells and not clicked on any (exploding) mines Requirements: For this assignment you are to implement a Vanilla JavaScript (ES5) version of Minesweeper. Feel free to use any HTML5 controls in your solution. Consider the following algorithm: 1. Generate a random n x m grid of cells for the user to click on, with n and m being the respective width and height of the grid After the user clicks on a cell, randomly place x mines on the grid (with x being the number of mines for your game.) Don't place a mine on the cell the user clicked on. (This is so the user gets one free click and the game isn't lost on first try.) 2. If no mines are adjacent to the cell, simply place 0 in the cell or shade the background a different color to show contrast to the user a. 3. 4. 5. Keep collecting clicks from the user, revealing the number of adjacent mines under each tile The game is won when all cells not containing mines are exposed and a mine was not clicked The game is lost immediately when a mine is clicked Points will be awarded based on correctness and creativity. Some features that aren't required but are nice to have include: Changing the color of the number of adjacent mines of a cell Giving the user the ability to flag a cell (via mouse right click) Ability for the user to play modes of difficulty, for instance Easy Mode might be a 10 x 10 grid with 10 mines while Hard Mode might be a 100 x 100 grid with 60 mines (these numbers are up to the developer.) With the above implementation, if no mines are adjacent to a particular cell the number 0 is shown in the cell. As an alternative, if the user clicks on a cell with no adjacent mines, you can reveal all "empty" cells (this will be demonstrated in class.) . The game of Minesweeper is a single-player puzzle game where the user is presented a grid of cells. Underneath the cells are a number of randomly placed mines. Consider the following screenshot of a game in process: @New Pause Settings 370 116 2 2 75 11 3 5 61 11 1 11221 525 5 11 55 134511 3663 315 22 15 111 53 1 442 11 3 44 1 4689 3 curvc Wikipedia In the above example, the user will click on each cell in the grid. If a mine is clicked, the game is immediately over and the player has lost. If the user didn't click on a mine, the a number is revealed to the user. This number is the number of mines in adjacent cells to the revealed number. Keep in mind that there are at-most eight cells adjacent to a cell. Corner cells only have three adjacent cells. Cells on the boundary of the game vary in count for adjacent neighboring cells. The game is won when the player has revealed all cells and not clicked on any (exploding) mines Requirements: For this assignment you are to implement a Vanilla JavaScript (ES5) version of Minesweeper. Feel free to use any HTML5 controls in your solution. Consider the following algorithm: 1. Generate a random n x m grid of cells for the user to click on, with n and m being the respective width and height of the grid After the user clicks on a cell, randomly place x mines on the grid (with x being the number of mines for your game.) Don't place a mine on the cell the user clicked on. (This is so the user gets one free click and the game isn't lost on first try.) 2. If no mines are adjacent to the cell, simply place 0 in the cell or shade the background a different color to show contrast to the user a. 3. 4. 5. Keep collecting clicks from the user, revealing the number of adjacent mines under each tile The game is won when all cells not containing mines are exposed and a mine was not clicked The game is lost immediately when a mine is clicked Points will be awarded based on correctness and creativity. Some features that aren't required but are nice to have include: Changing the color of the number of adjacent mines of a cell Giving the user the ability to flag a cell (via mouse right click) Ability for the user to play modes of difficulty, for instance Easy Mode might be a 10 x 10 grid with 10 mines while Hard Mode might be a 100 x 100 grid with 60 mines (these numbers are up to the developer.) With the above implementation, if no mines are adjacent to a particular cell the number 0 is shown in the cell. As an alternative, if the user clicks on a cell with no adjacent mines, you can reveal all "empty" cells (this will be demonstrated in class.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago