Skip to content

Dyumes/Minesweeper-Keenan-Gaetan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Table of content]


[Description]

Title ISC

Minesweeper - ISC Edition is a new take on the classic game : Minesweeper. Minesweeper - ISC Edition is a single-player logic-based computer game played on a rectangular board. The goal is to locate a predetermined number of randomly-placed mines by clicking on safe squares while avoiding the squares with mines. The player must use their wits and deduction to find the squares with mines and signal them using flags. Minesweeper - ISC Edition takes it's visual inspiration from the ISC branch of the HEI of Sion (which is by far the best branch).


[Hellsweeper]

"Attention Helldivers! The enemies of Managed Democracy have planted mines inside of our territory. It is your duty to bring Freedom and Peace once more inside of our soil. For Super Earth!"

helldiver salute

Hellsweeper is an alternative mode available for Minesweeper - ISC Edition. Bringing a brand new visual style, Hellsweeper puts you in the boots of an elite Helldiver tasked with the perilous mission of clearing minefields to secure humanity's survival in a hostile galaxy. Hellsweeper will take you on a democratic and perilous adventure as you locate and secure the mines hidden by Super Earth's enemies. But fear not! Your brave commander is here to bring you valuable moral support during your fight! Good luck, and may the light of Liberty guide you.

helldiver salute


[Screenshots]


[Guide]

Once you have selected one of the three difficulty available, the game will generate a board with hidden squares. Your goal is to find and flag all the hidden mines without clicking on one. Left-click on a square reveals either a number or a blank space. Numbers tell you how many mines are in the eight squares surrounding the one you just clicked. To mark a mine, Right-click to place a flag. Use the numbers to figure out where the mines are and clear all the safe squares. If you clear every safe square and flag all the mines correctly, you win! Avoid guessing and use logic to solve the puzzle.

If you find yourself stuck or wishing to change the current setting, you can press R on your keyboard to generate a new game! Pressing M will return you to the menu, while pressing Escape will close the game.


[Code]

main.scala

1. Initialization

  • Graphics Setup:
    • Initializes the game window using FunGraphics, setting dimensions, titles, and display options
  • Audio Initialization:
    • Prepares sound effects like background music and action sounds using the Audio class
  • Grid Setup:
    • Constructs a grid of Cell objects representing each tile in the game

2. Game mechanics

  • spawnMines():
    • Places mines randomly in the grid, ensuring unique positions
  • countMines():
    • Calculates and stores the number of adjacent mines for each cell
  • clearFirstClickArea(row, col):
    • Ensures the first clicked area is free of mines for a fair start
  • revealAdjacent(row, col):
    • Recursively reveals adjacent cells if no adjacent mines are present

3. Rendering

  • drawGrid():
    • Renders the game grid, dynamically adjusting cell colors, images, and fonts based on the game state
  • win() / lost():
    • Displays a "WIN" or "LOST" screen with animations and updates

4. Event handling

  • Mouse Input:
    • Handles left-click (reveal) and right-click (toggle flag) actions, triggering appropriate updates to the game state.
  • Keyboard Input:
    • Supports actions like restarting (R), opening the menu (M), or exiting (ESC).

5. Utility functions

  • startNewGame():
    • Resets the grid and initializes a new game with specified parameters
  • drawMenu() (via menu object):
    • Manages rendering of the main menu and navigation logic

menu.scala

1. Core Menu Rendering

  • drawMenu()
    • Displays the main menu with options for "Play," "Settings," and "Exit"
    • Clears the graphics buffer
    • Renders menu elements (background, buttons)
    • Handles mouse clicks for:
      • Play: Transitions to drawLevelMenu()
      • Settings: Transitions to drawSettingsMenu()
      • Exit: Exits the application

2. Level selection menu

  • drawLevelMenu()
    • Provides buttons for selecting difficulty levels: Easy, Medium, and Hard
    • Clears the graphics buffer and draws the level selection UI
    • Handles mouse clicks to:
      • Adjust grid dimensions (rows, cols), cell size, and mine count for each level
      • Start a new game by calling startNewGame()

3. Level selection menu

  • drawSettingsMenu()
    • Displays the settings menu, including an option to activate "Helldiver Mode"
    • Clears the graphics buffer and draws the settings UI
    • Handles mouse clicks for:
      • Returning to the main menu (drawMenu())
      • Activating "Helldiver Mode," which modifies game behavior and visuals

4. Level selection menu

  • Mouse Input Handling
    • Each menu listens for mouse clicks and determines button interactions based on click coordinates
  • Graphics Rendering
    • Uses graphics.drawTransformedPicture() and graphics.drawString() to render UI elements and text dynamically
  • Sound effects
    • Plays buttonSound on button interactions and gameHellmode for "Helldiver Mode"

images.scala

1. Mode configuration

  • hellsweeperMode (Boolean)
    • Tracks whether "Helldiver Mode" is active
    • false: Default mode
    • true: Helldiver mode

2. Paths for image

  • defaultPath (Array[String])
    • Contains file paths for default game assets such as grid tiles, menu buttons, and backgrounds
  • hellsweeperPath (Array[String])
    • Contains file paths for Helldiver Mode assets, including grid tiles and menu visuals tailored for the mode
  • activePath (Array[String])
    • Dynamically references either defaultPath or hellsweeperPath based on the current game mode

3. Path management

* getImagesPath()

  • Updates the activePath array based on the current mode:
  • Switches to hellsweeperPath if hellsweeperMode is true
  • Reverts to defaultPath if hellsweeperMode is false

4. Specialized assets

  • lostImage
    • File path for the image displayed when the player loses the game in Helldiver Mode
  • winImage
    • File path for the image displayed when the player wins the game in Helldiver Mode
  • General-Related Images:
    • generalImage: Path for General Mudry's image
    • generalHelmetImage: Path for General Mudry with a helmet
    • generalTextImage: Path for text assets related to General Mudry

general.scala

1. Quotes stockage

  • voiceline (Array[String])
    • An array of inspirational and thematic quotes delivered by the General himself

2. Quotes integration

  • Purpose:
    • Displays a randomized voiceline from the voiceline array along with the General's visual and thematic elements.
  • Clear Graphics:
    • Clears the screen using graphics.clear()
  • Background Setup:
    • Draws the General's background and image
  • Randomized Voiceline Selection:
    • A random quote is selected from the voiceline array
  • Text Presentation:
    • Draws the General's associated text image and displays the selected voiceline
  • Delays for Effect:
    • Pauses for 500ms before displaying the text.
    • Keeps the voiceline and visuals on screen for 5 seconds

Absolute Democracy

About

Minesweeper project Prog imp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages