How abbiereid/hand-controlled-pong works
Main Components
• FXGL Game Engine: This external library provides the underlying game loop, rendering, physics, asset management, input handling, etc.
• PongApp: This is the main entry point of the game (located in Pong/src/main/java/com/almasb/fxglgames/pong/PongApp.java). It initializes the application and starts the game loop.
• Game Entities and Components:
• BallComponent manages the ball’s behavior.
• BatComponent and EnemyBatComponent manage the batting mechanics.
• EntityType provides definitions for different types of entities.
• PongFactory is responsible for creating and assembling various game entities.
• UI and Configuration:
• MainUIController and the FXML file (assets/ui/main.fxml) handle the user interface elements.
• Assets (sounds and UI resources) in the resources directory provide multimedia feedback.
• Build & Deployment:
• The pom.xml file governs the build process using Maven, along with several CI/CD configuration files (.travis.yml, GitHub workflows) that aid in ensuring code quality and building for different environments like mobile with GraalVM.
File Structure for Architectural Choices
• The package structure (com.almasb.fxglgames.pong) shows component-based modularity, a common design in game development where entities and associated behaviors are separated.
• Resources are partitioned distinctly from source code ensuring asset management is clearly isolated.
• The inclusion of JavaFX FXML files hints at a clear separation of view (UI) from the core game logic.
• The directory also includes project configuration (pom.xml, .travis.yml) that reflects the automated build/test pipeline.
Determining Relationships and Interactions
• PongApp (the main application) initializes the FXGL game engine, registers the factories, and sets up the game scene.
• The PongFactory is invoked by the game engine to create game entities (ball, bats, etc.). Each game entity comprises various components (BallComponent, BatComponent, EnemyBatComponent) which define their behavior.
• The UI Controller (MainUIController) manages input and overlays tied to the game’s state.
• Assets (audio and UI elements) are loaded at runtime and connected to corresponding game events (ball hitting bat/wall triggers sounds).
Architectural Patterns and Design Principles
• Component-Based Design: Each game entity is modular, using small components for specific behaviors (e.g., dragging, collision) which can be reused.
• Separation of Concerns: The game engine logic (FXGL), the UI (FXML and its controller), and the game logic (in individual component classes) are well separated.
• Factory Pattern: The PongFactory encapsulates game entity creation, promoting loose coupling and scalability.
• Maven Build Lifecycle: The pom.xml encapsulates dependency resolution, build, and deployment configurations.