Compile and Run the Application: Use the Gradle command to clean, build, and run your application.
gradle clean build runThis project utilizes several design patterns to structure the code and manage the game state effectively:
- Purpose: Manage different behaviours for each ghost in the game, allowing type-specific chase targeting.
- Classes Involved:
GhostStrategy: Defines the interface for ghost behaviours.BlinkyChaseStrategy,PinkyChaseStrategy,InkyChaseStrategy,ClydeChaseStrategy: Implement chase behaviours per ghost.
- Package:
pacman.model.entity.dynamic.ghost.strategy
- Purpose: Define the framework for ghost modes (CHASE, SCATTER, FRIGHTENED) while letting subclasses fill in mode-specific logic.
- Classes Involved:
GhostBehavior: Outlines the template for movement.ChaseBehavior,ScatterBehavior,FrightenedBehavior: Implement the hook methods for each mode.
- Package:
pacman.model.entity.dynamic.ghost.template
- Purpose: Simplify and centralise frightened-mode activation and timing.
- Classes Involved:
FrightenedModeManager: Coordinates mode switching, ghost speed updates, and score bonuses.LevelImpl: Calls high-level methodsstartFrightenedMode()andresetModeTransition()to trigger the facade.
- Package:
pacman.model.entity.dynamic.ghost
- Purpose: Propagate game-state changes to interested parties without tight coupling.
- Examples:
PacmanimplementsPlayerPositionSubjectand notifiesGhostobservers of position updates.GameEngineImplandLevelImplnotify registeredGameStateObserverandLevelStateObserverinstances about progression events.
- Packages:
pacman.model.entity.dynamic.player.observer,pacman.model.engine.observer,pacman.model.level.observer
- Purpose: Encapsulate user input actions so they can be queued, executed, and validated independently.
- Classes Involved:
MoveCommandinterface with concrete commands (MoveUpCommand,MoveDownCommand, etc.) that call the model.MovementInvoker: Stores current and queued commands and executes them when movement is possible.
- Packages:
pacman.view.keyboard.command,pacman.model.entity.dynamic.player
- Purpose: Ensure only one command invoker coordinates player movement.
- Class:
MovementInvokerexposesgetInstance()and maintains a single shared instance. - Package:
pacman.model.entity.dynamic.player
- Purpose: Create renderable entities based on map configuration while isolating construction logic.
- Classes Involved:
RenderableFactoryRegistryImpl: Delegates creation to registered factories.- Concrete factories such as
GhostFactory,PelletFactory,WallFactory, andPacmanFactory.
- Package:
pacman.model.factories
- Purpose: Provide a fluent API for constructing complex objects with optional parameters.
- Class:
KinematicStateImpl.KinematicStateBuilderbuildsKinematicStateImplinstances with configurable position, speed, and direction. - Package:
pacman.model.entity.dynamic.physics