From 27ab03decdf2bd2e437a3f682e4a049493c220ac Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Sat, 29 Nov 2025 13:32:33 -0500 Subject: [PATCH] update readme --- README.md | 208 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 125 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 6d7fdca..f972d3d 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,156 @@ -# CMake SFML Project Template +# Pacmen SFML -This repository template should allow for a fast and hassle-free kick start of your next SFML project using CMake. -Thanks to [GitHub's nature of templates](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template), you can fork this repository without inheriting its Git history. +A classic Pac-Man game implementation built with C++ and SFML 3. -The template starts out very basic, but might receive additional features over time: +## Features -- Basic CMake script to build your project and link SFML on any operating system -- Basic [GitHub Actions](https://github.com/features/actions) script for all major platforms +- **Classic Pac-Man gameplay** with authentic arcade mechanics +- **Four unique ghosts** with AI behaviors: + - **Blinky** (Red) - Aggressive chaser + - **Pinky** (Pink) - Ambusher + - **Inky** (Cyan) - Strategic flanker + - **Clyde** (Orange) - Unpredictable patrol +- **Authentic game mechanics**: + - Ghost scatter/chase mode cycling + - Tunnel wrapping + - Staggered ghost release from ghost house + - Cornering tolerance for smooth controls +- **Comprehensive audio** - Original Pac-Man sound effects including: + - Start music + - Pellet eating sounds + - Siren progressions +- **JSON-based configuration** - Easily customizable game parameters +- **Resource management system** - Efficient loading and caching of assets -## Quick start +## Requirements -### Command line +- CMake 3.28 or higher +- C++17 compatible compiler +- Git (for fetching dependencies) -1. Install [Git](https://git-scm.com/downloads) and [CMake](https://cmake.org/download/). Use your system's package manager if available. -2. Follow [GitHub's instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for how to use their project template feature to create your own project. If you don't want to use GitHub, see the section below. -3. Clone your new GitHub repo and open the repo in your text editor of choice. -4. Open [CMakeLists.txt](CMakeLists.txt). Rename the project and the target name of the executable to whatever name you want. Make sure to change all occurrences. -5. If you want to add or remove any .cpp files, change the source files listed in the `add_executable` call in CMakeLists.txt to match the source files your project requires. If you plan on keeping the default main.cpp file then no changes are required. -6. If your code uses the Audio or Network modules then add `SFML::Audio` or `SFML::Network` to the `target_link_libraries` call alongside the existing `SFML::Graphics` library that is being linked. -7. If you use Linux, install SFML's dependencies using your system package manager. On Ubuntu and other Debian-based distributions you can use the following commands: - ``` - sudo apt update - sudo apt install \ - libxrandr-dev \ - libxcursor-dev \ - libxi-dev \ - libudev-dev \ - libfreetype-dev \ - libflac-dev \ - libvorbis-dev \ - libgl1-mesa-dev \ - libegl1-mesa-dev \ - libfreetype-dev - ``` -8. Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part. +### Platform-Specific Dependencies - - [VS Code](https://code.visualstudio.com) via the [CMake extension](https://code.visualstudio.com/docs/cpp/cmake-linux) - - [Visual Studio](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170) - - [CLion](https://www.jetbrains.com/clion/features/cmake-support.html) - - [Qt Creator](https://doc.qt.io/qtcreator/creator-project-cmake.html) +#### Linux (Ubuntu/Debian) +```bash +sudo apt update +sudo apt install \ + libxrandr-dev \ + libxcursor-dev \ + libxi-dev \ + libudev-dev \ + libfreetype-dev \ + libflac-dev \ + libvorbis-dev \ + libgl1-mesa-dev \ + libegl1-mesa-dev +``` - Using CMake from the command line is straightforward as well. - Be sure to run these commands in the root directory of the project you just created. +## Building - ``` - cmake -B build - cmake --build build - ``` +### Using CMake (Command Line) -9. Enjoy! +```bash +# Configure the project +cmake -B build -### Visual Studio +# Build the project +cmake --build build -Using a Visual Studio workspace is the simplest way to get started on windows. +# Run the game +./build/bin/main +``` -1. Ensure you have the [required components installed](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio#installation). -2. Follow [GitHub's instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for how to use their project template feature to create your own project. -3. If you have already cloned this repo, you can [open the folder](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio0#ide-integration). -4. If not, you can [clone it directly in Visual Studio](https://learn.microsoft.com/en-us/visualstudio/get-started/tutorial-open-project-from-repo). +### Using an IDE -Visual Studio should automatically configure the CMake project, then you can build and run as normal through Visual Studio. See the links above for more details. +This project supports CMake integration with popular IDEs: -## Upgrading SFML +- **VS Code** - Use the [CMake extension](https://code.visualstudio.com/docs/cpp/cmake-linux) +- **Visual Studio** - Open as a [CMake project](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio) +- **CLion** - Has built-in [CMake support](https://www.jetbrains.com/clion/features/cmake-support.html) +- **Qt Creator** - Supports [CMake projects](https://doc.qt.io/qtcreator/creator-project-cmake.html) -SFML is found via CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module. -FetchContent automatically downloads SFML from GitHub and builds it alongside your own code. -Beyond the convenience of not having to install SFML yourself, this ensures ABI compatibility and simplifies things like specifying static versus shared libraries. +## Controls -Modifying what version of SFML you want is as easy as changing the `GIT_TAG` argument. -Currently it uses SFML 3 via the `3.0.2` tag. +- **W / Up Arrow** - Move up +- **A / Left Arrow** - Move left +- **S / Down Arrow** - Move down +- **D / Right Arrow** - Move right -## But I want to... +## Project Structure -Modify CMake options by adding them as configuration parameters (with a `-D` flag) or by modifying the contents of CMakeCache.txt and rebuilding. +``` +pacmen-sfml/ +├── src/ +│ ├── main.cpp # Entry point +│ ├── Game.cpp/h # Main game loop and initialization +│ ├── Entity.cpp/h # Base entity class with animations +│ ├── Pacman.cpp/h # Pac-Man entity +│ ├── Ghost.cpp/h # Base ghost class with AI +│ ├── Blinky.cpp/h # Red ghost implementation +│ ├── Pinky.cpp/h # Pink ghost implementation +│ ├── Inky.cpp/h # Cyan ghost implementation +│ ├── Clyde.cpp/h # Orange ghost implementation +│ ├── MazeMap.cpp/h # Maze rendering and collision +│ └── ResourceManager.cpp/h # Asset loading +├── assets/ +│ ├── fonts/ # Game fonts +│ ├── sounds/ # Sound effects +│ ├── textures/ # Sprite sheets and graphics +│ └── game/ +│ ├── config.json # Game configuration and level data +│ ├── maze.txt # Maze walls data +│ └── pellets.txt # Pellet placement data +├── CMakeLists.txt # Build configuration +└── README.md +``` -### Not use GitHub +## Configuration -You can use this project without a GitHub account by [downloading the contents](https://github.com/SFML/cmake-sfml-project/archive/refs/heads/master.zip) of the repository as a ZIP archive and unpacking it locally. -This approach also avoids using Git entirely if you would prefer to not do that. +The game uses `assets/game/config.json` for configuration, which includes: -### Change Compilers +- **Game constants** - Frame rate, tile size, base speeds, point values +- **Bonus fruit** - Appearance timing and point values +- **Level specifications** - 21 levels (1-20 plus 21+) with: + - Pac-Man and ghost speeds + - Vulnerable mode duration + - Scatter/chase timing patterns + - Ghost house release logic + - Bonus fruit types and values -See the variety of [`CMAKE__COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html) options. -In particular you'll want to modify `CMAKE_CXX_COMPILER` to point to the C++ compiler you wish to use. +## Architecture -### Change Compiler Optimizations +### Entity System +The game uses an inheritance-based entity system: +- `Entity` - Base class with animation, movement, and rendering +- `Pacman` - Player-controlled entity +- `Ghost` - AI-controlled entities with behavior modes -CMake abstracts away specific optimizer flags through the [`CMAKE_BUILD_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) option. -By default this project recommends `Release` builds which enable optimizations. -Other build types include `Debug` builds which enable debug symbols but disable optimizations. -If you're using a multi-configuration generator (as is often the case on Windows), you can modify the [`CMAKE_CONFIGURATION_TYPES`](https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIGURATION_TYPES.html#variable:CMAKE_CONFIGURATION_TYPES) option. +### Ghost AI +Ghosts operate in multiple modes: +- **Scatter** - Move to designated corners +- **Chase** - Pursue Pac-Man using unique targeting strategies +- **Vulnerable** - Flee from Pac-Man when energizer is eaten +- **In Box** - Wait in ghost house before release -### Change Generators +### Resource Management +`ResourceManager` handles loading caching of: +- Textures with runtime scaling +- Sound buffers +- Fonts +- Map data files -While CMake will attempt to pick a suitable default generator, some systems offer a number of generators to choose from. -Ubuntu, for example, offers Makefiles and Ninja as two potential options. -For a list of generators, click [here](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html). -To modify the generator you're using you must reconfigure your project providing a `-G` flag with a value corresponding to the generator you want. -You can't simply modify an entry in the CMakeCache.txt file unlike the above options. -Then you may rebuild your project with this new generator. +## Dependencies -## More Reading +The project automatically fetches these dependencies via CMake FetchContent: -Here are some useful resources if you want to learn more about CMake: +- **SFML 3.0.2** - Graphics, audio, and window management +- **nlohmann/json 3.11.3** - JSON parsing for configuration -- [Official CMake Tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/) -- [How to Use CMake Without the Agonizing Pain - Part 1](https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-1.html) -- [How to Use CMake Without the Agonizing Pain - Part 2](https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-2.html) -- [Better CMake YouTube series by Jefferon Amstutz](https://www.youtube.com/playlist?list=PL8i3OhJb4FNV10aIZ8oF0AA46HgA2ed8g) +## Acknowledgments -## License - -The source code is dual licensed under Public Domain and MIT -- choose whichever you prefer. +- Original Pac-Man game design by Toru Iwatani (Namco) +- Built with [SFML](https://www.sfml-dev.org/) +- Font: [Press Start 2P](https://fonts.google.com/specimen/Press+Start+2P) +- Graphics and sounds: [The Spriters Resource](https://www.spriters-resource.com/arcade/pacman/) +- Game reference from [The Pac-Man Dossier](https://pacman.holenet.info/) +- Project structure based on the [SFML CMake Template](https://github.com/SFML/cmake-sfml-project)