/minesweeper

Java implementation of the classic Minesweeper game.

Primary LanguageJavaMIT LicenseMIT

Minesweeper

Java implementation of the classic Minesweeper game, using JavaFX for the graphics. Created as part of a course on object-oriented programming at NTNU Trondheim, spring 2019. Updated for readability and distributability spring 2022.

Table of Contents

Screenshots

Menu screenshot Gameplay screenshot

Running the App

Through the JAR

  1. Download the latest minesweeper.jar from Releases (https://github.com/hermannm/minesweeper/releases)

  2. Double click the downloaded .jar to run it!

    • Mac users may have to allow it through System Preferences -> Security & Privacy

You can also run the JAR from the terminal:

java -jar minesweeper.jar

Through Gradle

  1. Clone the repo
git clone https://github.com/hermannm/minesweeper.git
  1. Navigate to the new folder
cd minesweeper
  1. Build the project
./gradlew build
  1. Run the app
./gradlew run

Project Structure

  • src contains the Java packages for the project.
    • Package dev.hermannm.minesweeper contains the entry point of the application, as well as its controller and game mode configuration.
      • Subpackage game contains the game logic for Minesweeper.
      • Subpackage gui contains the JavaFX graphical user interface for the game.
      • Subpackage io contains a class for saving and loading games to and from text files.
  • resources contains the static assets for the app.
    • styles.css is the JavaFX CSS stylesheet for the UI.
    • fonts contains the font files used in the stylesheet.
    • img contains the Minesweeper icons used in the stylesheet and the game.
  • build.gradle.kts contains the Gradle build config for the project.

Credits