How sang-gre/encanfrogger works
1. What this repo is
- A Java 2D game launcher/application with a clear split between UI screens, gameplay core, domain objects, data persistence, and asset loading.
- The entrypoint is launched via run.cmd, so this is a desktop runtime rather than a web or server app.
2. Startup / application shell
- The launch path centers on GameLauncher and a container/panel-based shell (MainContainer, MainPanel).
- The app appears to boot into a title/menu flow first, then transition into the active game panel.
3. UI layer
- src/ui/screens contains the primary screens: TitlePanel and MainPanel.
- src/ui/overlays contains CursorGlassPane, which suggests the UI uses an overlay layer for cursor/visual effects above normal content.
- src/ui/components/Cursor indicates some custom pointer rendering or cursor behavior.
4. Game core
- src/core/GamePanel and src/core/GameState define the gameplay runtime and the current mode/state of the game.
- src/core/CollisionSystem is the main spatial interaction boundary: it likely mediates player/object collisions and gameplay contact logic.
- This core layer is separated from the screen/UI layer, which helps keep menu/navigation code distinct from active gameplay behavior.
5. Game loop / execution model
- src/threads/GameLogicThread and src/threads/RenderThread show a threaded architecture.
- Logic updates and rendering are decoupled, which is important for the architecture diagram: one thread advances game state, another paints frames.
- This implies the active game panel is fed by concurrent update/render activity rather than a single synchronous loop.
6. Domain objects
- src/gameobjects contains the entity model: GameObject as the base type, plus concrete objects like Player and Coin.
- Direction and PlayerType encode game-specific enums/variants, likely used by movement and character selection logic.
- These are the objects manipulated by the core systems and collision code.
7. Data / persistence subsystem
- src/data is the persistence and progression boundary: PlayerAccount, SaveState, Score, LeaderboardManager, CharacterShop, and DataManager.
- This layer likely handles user profile data, saved progress, scoring, leaderboard state, and unlock/purchase-style character progression.
- DataManager is the orchestration point for reading/writing these structures.
8. Assets / content loading
- src/assets/AssetManager is the content-loading boundary for sprites and other resources.
- The assets/ folders (adamusSprite, deiaSprite, flammaraSprite, terraSprite, lireoObstacles) hold character and obstacle art, so visuals are file-backed rather than generated.
- Asset loading is a separate concern from gameplay logic, which is useful for diagramming content flow into the game runtime.
9. Primary runtime flow
- User starts in TitlePanel/menu UI.
- UI transitions into the main game shell, where GamePanel becomes active.
- GameLogicThread updates entities and collisions; RenderThread draws the current frame.
- During play, DataManager and related classes support persistence, scoring, account state, and leaderboard/shop features.
10. Important architectural boundary
- The most important separation is: UI screens and overlays on one side, gameplay/core simulation in the middle, and data/assets as supporting subsystems.
- That separation should be reflected in any diagram: screens drive state transitions, core systems own gameplay rules, and data/assets are services consumed by both.
11. Repository layout note
- There are also root-level Java files that mirror names under src/, which suggests either legacy copies or packaging duplicates.
- For architecture purposes, the src/ tree is the clearest modular view of the system.
Main entry points: DataManager.java DataManager · GamePanel.java GamePanel · GameLogicThread.java GameLogicThread · MainPanel.java MainPanel
Components 21
App Shell
Desktop launcher and top-level container
- GameLauncher · Application entrypoint launched by the desktop script
src/main/GameLauncher.java - MainContainer · Top-level window/container that hosts the active screen
MainContainer.java
UI
Screens and overlays for menus and presentation
- TitlePanel · Initial menu/title screen
src/ui/screens/TitlePanel.java - MainPanel · Primary gameplay screen and transition target
src/ui/screens/MainPanel.java - CursorGlassPane · Overlay layer used for cursor or visual effects
src/ui/overlays/CursorGlassPane.java - Cursor · Custom cursor rendering or behavior
src/ui/components/Cursor.java
Runtime
Active gameplay panel, state, and worker threads
- GamePanel · Active gameplay surface and coordination point
src/core/GamePanel.java - GameState · Current game mode or runtime state
src/core/GameState.java - CollisionSystem · Spatial interaction and contact logic
src/core/CollisionSystem.java - GameLogicThread · Advances simulation and game rules
src/threads/GameLogicThread.java - RenderThread · Renders the active frame stream
src/threads/RenderThread.java
Domain
Game entities and enums
- GameObject · Base type for in-game objects
src/gameobjects/GameObject.java - Player · Controllable character entity
src/gameobjects/Player.java - Coin · Collectible gameplay object
src/gameobjects/Coin.java
Data
Persistence, scoring, and progression
- DataManager · Coordinates save, profile, leaderboard, and shop data
src/data/DataManager.java - PlayerAccount · Player identity and account data
src/data/PlayerAccount.java - SaveState · Serialized progression or session snapshot
src/data/SaveState.java - Score · Score and ranking-related data
src/data/Score.java - LeaderboardManager · Leaderboard storage and updates
src/data/LeaderboardManager.java - CharacterShop · Unlock and selection logic for characters
src/data/CharacterShop.java
Content
Asset loading and file-backed art
- AssetManager · Loads sprites and other visual resources
src/assets/AssetManager.java
Connections 25
- GameLauncher → MainContainer: starts · Bootstraps the desktop application shell
- GameLauncher → TitlePanel: opens · Initial flow enters the title/menu screen
- MainContainer → TitlePanel: hosts · Container shows the active top-level screen
- TitlePanel → MainPanel: transitions · Menu flow moves into gameplay
- MainPanel → GamePanel: contains · Gameplay screen delegates to the core runtime panel
- MainPanel → CursorGlassPane: overlays · Applies cursor/visual overlay above content
- CursorGlassPane → Cursor: renders · Overlay drives custom cursor presentation
- GamePanel → GameState: tracks · Panel reads and updates the current game mode
- GamePanel → GameLogicThread: updates via · Logic is advanced on a dedicated worker
- GamePanel → RenderThread: draws via · Rendering is handled by a separate worker
- GameLogicThread → CollisionSystem: uses · Simulation checks interactions and contacts
- GameLogicThread → GameObject: steps · Updates shared entity model
- GameLogicThread → Player: updates · Advances player state and movement
- GameLogicThread → Coin: updates · Advances collectible behavior when needed
- CollisionSystem → GameObject: checks · Evaluates collisions across entities
- Player → GameObject: extends · Concrete player entity built on the base object
- Coin → GameObject: extends · Concrete collectible entity built on the base object
- GamePanel → AssetManager: loads · Gameplay surface consumes art and content assets
- DataManager → PlayerAccount: manages · Coordinates profile/account persistence
- DataManager → SaveState: manages · Coordinates save data persistence
- DataManager → Score: manages · Coordinates score storage and retrieval
- DataManager → LeaderboardManager: orchestrates · Coordinates leaderboard updates and reads
- DataManager → CharacterShop: orchestrates · Coordinates unlock and shop progression
- MainPanel → DataManager: consumes · UI can access progression and account state
- GamePanel → DataManager: consumes · Gameplay reads/writes persistent state