/Minesweeper

code of a minesweeper game in C++ language and using SBDL graphic environment

Primary LanguageC++

Check out the full gameplay demonstration and features of our Minesweeper game on YouTube at: https://youtu.be/TOnGt4zp0IE?si=U4a5_RhkpS3QMTRm

Key Structures and Variables

  • player_info struct stores player name and score.
  • Various arrays to manage the game state like the mine locations and game board status.
  • Texture and Music variables for loading and displaying graphics and sounds.

Main Functions

  • asset_loader() - Loads all the required textures and fonts.
  • Game_preparations() - Sets up the initial game state by placing mines and calculating adjacent mine counts.
  • board_shower() - Renders the game board based on the current state of cells.
  • game_start() - Main game loop handling user inputs and game updates.
  • win_function() and lose_function() - Handle game conclusion events.
  • game_saver() and game_loader() - Functions for saving and loading game states, useful for managing game progress across sessions.
  • custom_game_option() - Allows users to customize game settings.
  • leaderboard() - Manages and displays a leaderboard of player scores.

Graphical and User Interaction

  • Various SDL and SBDL functions are used for handling graphics and user interactions like mouse clicks and keyboard inputs.

Observations

  • The game appears well-structured with clear separations for functionality such as game setup, gameplay handling, and utility functions like saving/loading.
  • The use of global variables and arrays extensively makes it easier to manage the state across different parts of the game, though it could also increase complexity and potential bugs with larger code bases.
  • The use of hardcoded values (e.g., array sizes, texture paths) suggests that the game configuration is static but includes functions for some level of customization through the game menus.

Possible Enhancements

  • Consider encapsulating game logic into classes to reduce dependencies and improve modularity.
  • Introduce error handling, especially for file operations and external library functions.
  • Optimize memory usage and management, particularly with dynamic allocation and deallocation.

This overview touches on the primary components and functionalities in your project. If you need a deeper dive into any specific function or part of the code, feel free to ask!