Skip to content

deepencoding/PacAttack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ PacAttack

Stack: C++ โ€ข SFML


๐Ÿš€ Project Overview

PacAttack is a modern take on the classic Pac-Man arcade experience, built in C++ using SFML. Featuring advanced Ghost AI behaviors, intelligent pathfinding, dynamic audio cues, precise collision detection, and an adaptive scoring & level progression system, PacAttack aims to deliver both nostalgia and fresh gameplay twists that increase replay value and player engagement.


๐ŸŽฏ Key Features

  • Unique Ghost AI Behaviors
    Each ghost has its own decision-making logic and dynamic state changes (chase, scatter, frightened, adaptive), making the maze challenge more engaging and less predictable.

  • Intelligent Pathfinding Algorithms
    Efficient pathfinding (e.g., A* or BFS with heuristics) ensures ghosts navigate the maze effectively, adapting routes based on player position, level, and game state.

  • Dynamic Audio Cues
    Contextual sound effects and music transitions (e.g., escalating tension as player collects more points, alert cues when ghosts switch behaviors) enhance immersion and feedback.

  • Precise Collision Detection
    Robust collision logic calibrates hitboxes for the player (Paccy), ghosts, pellets, power-ups, and walls, ensuring smooth interactions and minimizing glitches.

  • Progressive Scoring & Level Progression
    An adaptive difficulty system scales Ghost AI aggressiveness and speed based on player performance, unlocking new levels or tweaks (e.g., faster ghost speed, smarter chase patterns) to maintain challenge and retention.

  • Cross-Platform Build
    Tested on Windows and Linux. Uses C++17 threading and memory management to keep the rendering loop responsive and thread-safe.


๐Ÿ“ File Structure

The repository is organized into logical modules for readability and maintainability. Example structure:


PacAttack/
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ images/                # Maze layouts, sprites, UI elements
โ”‚   โ”œโ”€โ”€ audio/                 # Sound effects and music tracks
โ”‚   โ””โ”€โ”€ levels/                # Level definitions (map data, enemy configs)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.cpp               # Entry point
โ”‚   โ”œโ”€โ”€ Paccy.cpp/.hpp         # Player character implementation
โ”‚   โ”œโ”€โ”€ Ghosts.cpp/.hpp        # Ghost class definitions & behaviors
โ”‚   โ”œโ”€โ”€ GhostManager.cpp/.hpp  # Ghost AI manager, state transitions
โ”‚   โ”œโ”€โ”€ MapCollision.cpp/.hpp  # Maze collision logic
โ”‚   โ”œโ”€โ”€ DrawMap.cpp/.hpp       # Rendering maze layout
โ”‚   โ”œโ”€โ”€ DrawText.cpp/.hpp      # UI text rendering (score, lives, etc.)
โ”‚   โ”œโ”€โ”€ ConvertSketch.cpp/.hpp # (Optional) Tools to convert sketchmaps to tilemaps
โ”‚   โ”œโ”€โ”€ Chronometer.hpp        # Timing utilities (frame timing, AI timers)
โ”‚   โ”œโ”€โ”€ AudioManager.cpp/.hpp  # Loading & playing audio cues
โ”‚   โ”œโ”€โ”€ LevelManager.cpp/.hpp  # Handles level loading, progression logic
โ”‚   โ”œโ”€โ”€ ScoreManager.cpp/.hpp  # Tracks scoring, combos, power-up effects
โ”‚   โ””โ”€โ”€ global.hpp             # Global constants, enums, configuration
โ”œโ”€โ”€ images-github/             # Screenshots for README/GitHub display
โ”‚   โ”œโ”€โ”€ FileStructure.png
โ”‚   โ”œโ”€โ”€ start\_screen.png
โ”‚   โ”œโ”€โ”€ gameplay\_1.png
โ”‚   โ””โ”€โ”€ gameplay\_2.png
โ”œโ”€โ”€ Build/                     # (Generated) build outputs
โ”œโ”€โ”€ CMakeLists.txt             # Build configuration
โ””โ”€โ”€ README.md                  # This file

Note: Adjust paths or filenames if your repository layout differs.


๐ŸŽฌ Screenshots

Start Screen

Gameplay Examples



๐Ÿ› ๏ธ Getting Started

Prerequisites

  • A C++17 (or newer) compiler (e.g., g++, clang++, MSVC).
  • SFML (if building from source; note: the project may include static linking of SFML for easier distribution).
  • CMake (minimum version 3.10+ recommended).

Clone the Repository

git clone https://github.com/deepencoding/PacAttack.git
cd PacAttack

Build & Compile

  1. Create a build directory

    mkdir build
    cd build
  2. Run CMake configuration

    cmake ..
    • If SFML is installed system-wide, CMake will find it.

    • If using custom SFML location, set SFML_DIR or appropriate CMake variables:

      cmake -DSFML_DIR=/path/to/SFML/lib/cmake/SFML ..
  3. Build the project

    cmake --build .

    This produces the executable (e.g., PacAttack or PacAttack.exe).

Run the Game

From the build directory:

./PacAttack
  • The game window should open with the start screen.
  • Control Paccy through the maze, collect pellets, avoid or chase ghosts when powered up.

๐ŸŽฎ Controls

  • Arrow Keys / WASD: Move Paccy (up/down/left/right).
  • P: Pause / Resume game.
  • M: Toggle mute audio.
  • ESC / Q: Quit to desktop.

(Adjust controls in code or config if different.)


โš™๏ธ Configuration & Tuning

  • Maze Layouts & Levels:

    • Level definitions can be stored as text/map files under assets/levels/. Modify tile representations or add new level files to expand gameplay.
    • Ghost speed, scatter/chase durations, power-up timings can be tweaked in global.hpp or a dedicated config struct.
  • Ghost AI Parameters:

    • Tweak pathfinding heuristics (e.g., weight factors) in GhostManager.
    • Adjust state transition thresholds (e.g., when ghosts switch from chase to scatter) based on level or score.
  • Audio Settings:

    • Audio files are in assets/audio/. Replace or add cues for new events (e.g., level-up jingle, extra life sound).
    • Volume levels and transition logic live in AudioManager.
  • Rendering & Performance:

    • Frame rate cap and timing logic in Chronometer.hpp.
    • Sprite sheets or textures can be updated in assets/images/; ensure collision boxes align with new visuals.

๐Ÿ” AI & Gameplay Details

Ghost AI Behaviors

  • State Machine: Each ghost cycles through states (Scatter, Chase, Frightened, Eaten). Transitions depend on timers, player actions (e.g., eating power pellet), and adaptive difficulty.

  • Adaptive Difficulty: Monitor player performance (e.g., pellet collection rate, lives remaining). If player excels, increase ghost speed or reduce scatter time to raise challenge; if struggling, ease parameters.

  • Pathfinding:

    • Implement A* (or BFS with heuristics) on the maze graph: nodes represent tile centers, edges represent valid moves.
    • Heuristics may include Manhattan distance or more advanced cost functions factoring in dynamic obstacles.
  • Dynamic Audio Integration:

    • When ghosts enter certain AI states (e.g., near-catch, frightened ending), trigger distinct audio cues for player feedback.
    • Background music tempo may shift subtly as player nears completion of level or power-up expiration.

Collision Detection

  • Tile-Based vs. Pixel-Based:

    • Use tile grid for coarse collision detection (walls vs. entities).
    • Use bounding boxes/circles for finer collisions (e.g., Paccy vs. ghost when closeness threshold met).
  • Smooth Movement:

    • When turning corners, allow buffered inputs so player doesnโ€™t feel โ€œstuckโ€ on grid intersections.
    • Ghosts use similar buffering for path recalculation.

Scoring & Progression

  • Pellet & Power-Up Scoring: Each pellet adds to score; power pellets trigger frightened mode and bonus scoring when eating ghosts.
  • Combo Tracking: Track consecutive ghost-eatings within a single power-up for exponential score multipliers.
  • Level Advancement: After clearing all pellets, transition to next maze layout. Increase difficulty by adjusting ghost speed, AI aggressiveness, or introducing new map elements.
  • High Scores: Optionally store high scores locally or via simple file I/O. (Extendable to online leaderboards.)

๐Ÿ“ฆ Distribution & Releases

  • Prebuilt Binaries: Check the Releases page to download precompiled binaries (e.g., PacAttack-binaries-v1.0.0.zip). Unzip and run the executable directlyโ€”no SFML install needed if statically linked.
  • Building from Source: Follow the Getting Started section above. Ensure SFML dependency is satisfied.

๐Ÿงฉ Extending PacAttack

  • New Ghost Types: Add classes with custom behaviors (e.g., ambusher, ambivalent ghost).
  • Power-Ups & Items: Introduce new power-ups (speed boost, temporary shield) and handle their integration in AI and scoring.
  • Multiplayer Mode: Experiment with local co-op or networked play (requires networking layer and sync logic).
  • Theming & Graphics: Swap sprite sets or add animations (e.g., animated mouth, ghost sprites), adjust UI overlays.
  • Analytics & Metrics: Log gameplay stats to fine-tune difficulty curves or for player feedback dashboards.

๐Ÿค Contributing

  1. Fork the repository.
  2. Create a branch: git checkout -b feature/awesome-ghost-ai.
  3. Commit changes with clear messages.
  4. Open a Pull Request against main.
  5. Ensure code compiles on supported platforms; add/update tests or demo scenes if applicable.
  6. Follow the existing style and architecture patterns.

We welcome improvements in AI, new levels, art assets, audio design, performance optimizations, and more!


๐Ÿงพ License

This project is released under the MIT License. See LICENSE for details.


๐Ÿ™‹โ€โ™‚๏ธ Author

@deepencoding โ€“ Passionate about game development, AI behaviors, and delivering smooth, engaging gameplay experiences. Feel free to open issues or discuss feature ideas!

About

PacAttack is an exciting clone game inspired by the classic arcade game Pacman. Players embark on a thrilling maze adventure, guiding their character through a challenging labyrinth while avoiding ghosts and collecting points. With captivating gameplay reminiscent of the original Pacman, offering a nostalgic experience for players of all ages.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors