This is a Pac-Man game implementation. The project is an extension of the given scaffold code, adding new features and enhancements to the game.
- Prerequisites: Ensure that you have Java installed on your system.
- Build Tool: This project uses Gradle for build management. Ensure you have Gradle installed, or use the Gradle wrapper included (
gradle clean build runfor Linux/MacOS,gradlew.batfor Windows). - Running the Project:
- Clone the repository or download the files.
- Navigate to the project root directory.
- Use the following command to run the project:
./gradle clean build run
- Alternatively, if using an IDE, import the project as a Gradle project and run
App.javain thepacman.viewpackage.
- Files:
GhostFactory.java,PacmanFactory.java,WallFactory.java,PelletFactory.java,RenderableFactoryRegistryImpl.java - Purpose: The Factory Pattern is used to create instances of various game entities (Pac-Man, Ghosts, Walls, Pellets) dynamically without modifying the core code structure.
- Files:
ChaseStrategy.java,ScatterStrategy.java,BlinkyChaseStrategy.java,PinkyChaseStrategy.java, etc. - Purpose: The Strategy Pattern allows for flexible behavior of ghosts by switching between different chase and scatter strategies.
- Files:
GhostState.java,ScatterState.java,ChaseState.java,FrightenedState.java - Purpose: Manages the behavior of ghosts depending on their current state (chase, scatter, frightened) to dynamically change behavior without altering the core logic.
- Files:
GameStateObserver.java,LevelStateObserver.java,GameEngineImpl.java,DisplayManager.java,LevelImpl.java - Purpose: Allows different parts of the game (like score display and game state) to stay in sync by observing changes in game state and level state.
- Files:
MoveCommand.java,MoveUpCommand.java,MoveDownCommand.java,KeyboardInputHandler.java - Purpose: Decouples input handling from action execution by encapsulating movement commands, allowing for flexible input handling.
- Files:
GhostDecorator.java,FrightenedGhostDecorator.java - Purpose: Adds new behavior to ghosts dynamically, like frightened behavior, without changing the underlying ghost structure.
App.java: The main entry point for running the game.pacman.model: Contains core models and game logic, including the engine, entities, and level management.engine: Manages game state and engine operations.entity: Holds all entity-related classes, including Pac-Man, ghosts, and pellets.factories: Contains factory classes for creating game entities.level: Manages level-related logic and state.observer: Implements observer interfaces for game and level states.
pacman.view: Contains view-related classes for rendering the game and handling user input.KeyboardInputHandler.java: Manages player input via keyboard.DisplayManager.java: Handles rendering of game elements on the screen.
- Quirks: If you encounter issues with file paths or resources not loading, make sure to run the project from the root directory where
resources/mazeis accessible. - Known Issues: The game currently assumes fixed screen dimensions, so resizing may affect display. Further extensions could involve adapting to dynamic screen sizes.
- Future Improvements: Additional states for ghosts and enhancements in rendering are possible with minimal code changes, thanks to the use of design patterns.