How ameshalexk/minesweeper works
This project is a simple, browser-based Minesweeper game built entirely as a front-end application. It uses HTML (index.html) for the layout and structure, main.css for styling (including positioning for game squares and modals), and app.js for all the game logic. The game leverages jQuery for DOM manipulation and event handling and uses the browser’s local storage to manage player information and high scores. It is hosted on GitHub Pages.
Main Components
• User Interface (UI):
– index.html is the single HTML file providing the game’s structure, including the board where 100 DIVs are generated, and the modals (for user input, instructions, and high scores).
• Presentation Layer:
– main.css provides the visual styling for the grid, modals, and overall layout.
• Game Engine / Logic:
– app.js contains the game’s essential logic – it generates the grid, assigns mines randomly, handles the “on click” event listeners for squares, computes neighboring mines, and triggers the end-of-game conditions (win/lose scenarios).
• Persistence Layer:
– Local storage is used to store the player name and win time and manage the leaderboard (sorted in descending order).
• Third-Party Libraries:
– jQuery (used for DOM manipulation and event handling).
Relationships and Interactions
• User Interaction Flow:
– A user interacts with the UI (index.html) by clicking on squares, marking bombs, and navigating between modals.
– Events are captured (e.g., On Click events) and processed by the code in app.js.
• Game Processing Logic:
– app.js uses the given CSS properties (using "top" and "left") to place DIVs on the screen, dynamically creating the grid.
– The game engine randomly assigns up to 10 mines and calculates adjacent mine counts.
• Data Persistence:
– When a game ends, or at relevant checkpoints, the player’s score and name get stored into local storage.
– The leaderboard modal reads and displays this data.
• Hosting Environment:
– The entire application is deployed on GitHub Pages, so it runs completely in the client’s browser without server-side components.