How truongtuan1312/blockblast-group2 works
1. Project type and runtime
- This is a desktop Java game that clones Block Blast.
- The architecture is centered on a Swing-style UI with an in-process game loop and no external backend or services.
2. Application entry and shell
- Main.java is the startup point.
- BlockBlastFrame.java is the top-level window/container.
- GamePanel.java is the main rendering and update surface where gameplay is likely run.
3. User input boundary
- InputHandler.java isolates keyboard/mouse interaction from game logic.
- Input likely feeds the panel/game state rather than manipulating board data directly, which keeps UI and rules separated.
4. Core game model
- Board.java represents the playfield and placement rules.
- Piece.java represents the draggable/placable block shapes.
- InvalidPlacementException.java is used to signal illegal moves, so placement validation is explicit in the domain layer.
5. Piece creation and variation
- PieceFactory.java is responsible for generating pieces.
- This is a clear creation boundary: the rest of the game consumes pieces without needing to know how they are assembled or randomized.
6. State management and undo
- GameState.java appears to capture the full mutable game snapshot.
- GameStateMemento.java supports snapshotting/restoring that state.
- UndoManager.java manages the history stack or rollback flow, making undo a first-class subsystem rather than ad hoc logic.
7. Scoring system
- ScoreStrategy.java defines scoring behavior as a pluggable policy.
- ClassicScoreStrategy.java provides the concrete scoring rules used by the game.
- This indicates the score calculation is intentionally separated from board mechanics.
8. Rendering abstractions
- Drawable.java suggests a shared render contract for on-screen objects.
- ScoreText.java is likely a UI overlay element for score feedback.
- LevelTheme.java implies visual theming is data-driven or at least abstracted from gameplay logic.
9. Visual effects subsystem
- Particle.java is the base effect type.
- AtmosphereParticle.java and DebrisParticle.java are specialized particle effects for ambient motion and placement feedback.
- These are presentation-only objects that enhance the game feel without affecting rules.
10. Object reuse / performance
- GameObjectPool.java indicates pooling for transient objects, probably particles or other short-lived render entities.
- This is a performance-oriented boundary to reduce allocation churn during gameplay.
11. Audio feedback
- SoundManager.java is a separate subsystem for sound effects.
- It likely reacts to game events such as placement, clears, invalid actions, or undo, instead of being called from rendering code.
12. Overall data flow
- The typical flow is: input → game panel/controller logic → board/piece validation → scoring/state update → visual/audio feedback.
- Undo works by restoring a prior GameState snapshot.
- Rendering consumes current model state plus transient effects like particles, score text, and theme data.
13. Main architectural boundary
- The code cleanly separates:
- game rules (Board, Piece, scoring, exceptions),
- state/history (GameState, memento, undo),
- presentation/effects (GamePanel, drawable objects, particles, score text, theme),
- support services (SoundManager, object pool, factories).
- That separation is the key to drawing an accurate architecture diagram for this repository.
Main entry points: GamePanel.java Game Panel · InputHandler.java Input · Drawable.java Drawable · Particle.java Particle
Components 21
App Shell
Startup and top-level windowing
- Main · Application bootstrap
Main.java - Game Frame · Top-level desktop container
BlockBlastFrame.java - Game Panel · Main update and render surface
GamePanel.java - Input · Keyboard and mouse handling
InputHandler.java
Game Core
Rules, state, scoring, and undo
- Board · Playfield and placement rules
Board.java - Piece · Block shape model
Piece.java - Invalid Move · Illegal placement signal
InvalidPlacementException.java - Game State · Mutable game snapshot
GameState.java - Memento · State capture and restore
GameStateMemento.java - Undo · Undo stack and rollback flow
UndoManager.java - Score Strategy · Scoring rule contract
ScoreStrategy.java - Classic Score · Default scoring rules
ClassicScoreStrategy.java
Presentation
Rendering, effects, and feedback
- Drawable · Shared render interface
Drawable.java - Theme · Level look and feel
LevelTheme.java - Score Text · Score feedback text
ScoreText.java - Particle · Base visual effect
Particle.java - Atmosphere · Ambient motion effect
AtmosphereParticle.java - Debris · Placement feedback effect
DebrisParticle.java
Support
Factories, pooling, and services
- Piece Factory · Creates and randomizes pieces
PieceFactory.java - Object Pool · Reuses transient objects
GameObjectPool.java - Sound · Sound effect playback
SoundManager.java
Connections 21
- Main → Game Frame: creates · Bootstraps the application shell
- Game Frame → Game Panel: hosts · Window contains the main game surface
- Game Panel → Input: receives · Panel delegates user events to input handling
- Input → Board: moves · Input drives placement attempts against the board
- Input → Piece: selects · Input interacts with the active piece
- Board → Invalid Move: throws · Illegal placements are signaled as domain errors
- Game Panel → Game State: updates · Game loop advances the mutable state
- Game State → Memento: captures · State can be snapshotted for rollback
- Undo → Memento: stores · Undo manager retains snapshots
- Undo → Game State: restores · Undo restores a prior game state
- Piece Factory → Piece: creates · Factory produces playable pieces
- Score Strategy → Classic Score: implemented by · Classic scoring is the concrete policy
- Game Panel → Score Strategy: uses · Gameplay consults scoring rules
- Game Panel → Drawable: renders · Visual objects follow a shared draw contract
- Drawable → Score Text: includes · Score text is one drawable overlay
- Drawable → Particle: includes · Particles participate in rendering
- Particle → Atmosphere: specializes · Ambient particle subtype
- Particle → Debris: specializes · Debris particle subtype
- Game Panel → Theme: styles · Theme config informs presentation
- Game Panel → Object Pool: reuses · Transient effects may be pooled
- Game Panel → Sound: plays · Gameplay events trigger audio feedback