How marct1me/gravitysimulation2-javaedition works
1. Project shape
- This is a multi-module LibGDX game written in Java.
- The main runtime is split into core (game logic) and lwjgl3 (desktop launcher). There are also server and shared modules, but the visible architecture is primarily a single-player desktop simulation.
2. Startup and platform boundary
- lwjgl3/Lwjgl3Launcher is the platform entry point.
- It boots the LibGDX application and applies window-related startup behavior before handing control to the core game class.
- core/GravitySimulation2 is the central game bootstrapper: it loads configuration, initializes UI, and selects the first screen.
3. Screen-based application flow
- The app is organized around LibGDX screens:
- MainMenuScreen
- SceneLoadingScreen
- SceneScreen
- These represent the major runtime states: menu, load transition, and active simulation.
- screen/DefaultBackground and screen/scene/SceneScreenBackground provide visual backdrops under the screens.
4. UI and menu subsystem
- gameinterface contains the in-game interface layer and menu objects.
- It is split into concrete menus for:
- main menu
- load menu
- pause menu
- settings menu
- Settings are organized as fields/categories:
- game settings
- graphic settings
- window settings
- This layer controls visibility/state of menu objects and is the main bridge between user input and game-state transitions.
5. Configuration system
- config defines the runtime configuration model and its loading/management.
- The repository ships with three config categories stored under assets/config:
- game.json
- graphic.json
- window.json
- ConfigManager is the central loader/manager, while GameConfig, GraphicConfig, and WindowConfig represent category-specific settings.
- These configs affect both UI behavior and runtime rendering/window behavior.
6. Simulation domain
- The core simulation model lives under objects.
- GameScene is the container for the active world.
- objects/object defines scene entities through GameObject plus type-specific implementations such as:
- StarObject
- PlanetObject
- SatelliteObject
- EmptyObject
- ObjectType / ObjectTypes separate object behavior/metadata from the base object structure.
7. Physics engine and threading boundary
- The physics subsystem is under objects/physic.
- Key parts are:
- Simulation
- SimulationSpace
- Physic
- PhysicBody
- Vector2D
- The README indicates simulation calculations run in a separate thread, so the physics engine is a distinct runtime boundary from the render/UI thread.
- This is a major architectural separation: UI/screens drive state, while the simulation thread advances object motion.
8. Camera subsystem
- objects/camera contains Camera and CameraController.
- The camera is part of the scene state and is persisted in save files.
- Camera settings are tied into both gameplay and loading/saving, so camera state is not just a render concern; it is part of the serialized scene snapshot.
9. Save/load pipeline
- Save handling is under save.
- The save format is split into multiple files per scenario:
- save.json as the header/metadata
- scene.json for scene objects
- simulation.json for simulation parameters
- camera.json for camera state
- SceneParser reconstructs a full scene from the save folder.
- The load flow is staged: header first, then scene/simulation/camera data, then the scene is activated and the simulation starts.
10. Content/data assets
- assets/ui contains bitmap font and skin assets used by the UI.
- assets/saves/* contains predefined scenarios such as centauri, duet, magic, simple, sol, and test.
- These are not just data files; they are runtime content that defines the initial simulation worlds the user can load.
11. Main data flow
- User starts in the menu.
- Configs are loaded and applied.
- Selecting a save triggers parsing of the save folder into scene, simulation, objects, and camera.
- The app switches to the scene screen.
- The simulation thread advances physics while the screen layer renders objects and overlays.
- Returning to the main menu clears the active scene and stops/tears down the simulation state.
12. Additional modules and boundaries
- server contains a ServerMain entrypoint, but no clear integration with the core game flow is visible in this tree.
- shared exists as a separate module, likely intended for code reuse or tests, but it is not shown as part of the main runtime path.
- This makes the repository primarily a desktop game/simulation app, with extra module boundaries prepared for future expansion.
Main entry points: gameinterface UI layer · GravitySimulation2.java Game bootstrap · GameScene.java Game scene · SceneScreen.java Scene screen
Components 24
lwjgl3
Desktop launcher and platform startup
- Launcher · Starts the LibGDX app and applies desktop startup behavior.
lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/Lwjgl3Launcher.java - Startup helper · Handles platform-specific startup details before the game opens.
lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/StartupHelper.java
core
Game runtime, screens, simulation, and UI
- Game bootstrap · Central game class that loads config, initializes UI, and selects the first screen.
core/src/main/java/com/gravitysimulation2/GravitySimulation2.java - Main menu · Initial screen for menu-driven startup and navigation.
core/src/main/java/com/gravitysimulation2/screen/mainmenu/MainMenuScreen.java - Load screen · Transition screen used while loading a save or scene.
core/src/main/java/com/gravitysimulation2/screen/loading/SceneLoadingScreen.java - Scene screen · Active simulation screen that renders and drives the world.
core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java - Scene backdrop · Visual background used behind the active scene screen.
core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreenBackground.java - Default backdrop · Shared background used by screen-level UI states.
core/src/main/java/com/gravitysimulation2/screen/DefaultBackground.java - UI layer · In-game interface layer that coordinates menus and interaction state.
core/src/main/java/com/gravitysimulation2/gameinterface - Settings menu · Menu for adjusting game, graphics, and window settings.
core/src/main/java/com/gravitysimulation2/gameinterface/menu/settings/SettingsMenu.java - Main menu UI · Concrete main menu object and navigation entry.
core/src/main/java/com/gravitysimulation2/gameinterface/menu/main/MainMenu.java - Load menu · Menu for choosing and opening bundled save scenarios.
core/src/main/java/com/gravitysimulation2/gameinterface/menu/load/LoadMenu.java - Pause menu · Pause-state overlay for controlling the running simulation.
core/src/main/java/com/gravitysimulation2/gameinterface/menu/pause/PauseMenu.java - Config manager · Loads and manages runtime configuration categories.
core/src/main/java/com/gravitysimulation2/config/ConfigManager.java - Game scene · Container for the active world, simulation, and camera state.
core/src/main/java/com/gravitysimulation2/objects/GameScene.java - Camera · Camera state and controller persisted with the scene.
core/src/main/java/com/gravitysimulation2/objects/camera/Camera.java - Objects · Base scene objects and object-type implementations.
core/src/main/java/com/gravitysimulation2/objects/object - Physics · Separate physics runtime that advances bodies and motion.
core/src/main/java/com/gravitysimulation2/objects/physic - Save parser · Rebuilds a full scene from save metadata, scene, simulation, and camera files.
core/src/main/java/com/gravitysimulation2/save/SceneParser.java
server
Standalone server entrypoint
- Server main · Standalone server entrypoint not wired into the desktop game flow.
server/src/main/java/com/gravitysimulation2/server/ServerMain.java
shared
Shared module placeholder
- Shared · Placeholder module for code reuse or future expansion.
shared/src/main/java/com/gravitysimulation2/SharedTest.java
assets
Runtime configs, UI skins, and bundled saves
- Config assets · Bundled configuration files for game, graphics, and window settings.
assets/config - Save assets · Bundled scenario saves that define loadable worlds.
assets/saves - UI assets · Fonts and skin resources used by the interface layer.
assets/ui
Connections 27
- Launcher → Startup helper: boots · Desktop launcher uses startup helper for platform-specific boot behavior.
- Startup helper → Game bootstrap: launches · Startup hands control to the core LibGDX game.
- Game bootstrap → Config manager: loads · Core bootstrap loads runtime configuration at startup.
- Game bootstrap → Main menu: opens · Initial state is the main menu screen.
- Game bootstrap → UI layer: initializes · Bootstraps the in-game interface layer.
- UI layer → Main menu UI: contains · UI layer hosts the main menu.
- UI layer → Load menu: contains · UI layer hosts the load menu.
- UI layer → Pause menu: contains · UI layer hosts the pause menu.
- UI layer → Settings menu: contains · UI layer hosts the settings menu.
- Settings menu → Config manager: edits · Settings menu reads and updates runtime config categories.
- Main menu → Load screen: navigates · Menu flow transitions into loading when a save is selected.
- Load screen → Save parser: parses · Load screen reconstructs scene data through the save pipeline.
- Save parser → Game scene: builds · Parsed save data becomes the active scene model.
- Game bootstrap → Scene screen: switches to · Core game activates the scene screen after loading.
- Scene screen → Game scene: renders · Scene screen displays the active world state.
- Scene screen → Scene backdrop: uses · Active scene has its own background layer.
- Main menu → Default backdrop: uses · Menu screens use shared background rendering.
- Scene screen → Camera: drives · Scene screen consumes camera state for view control.
- Game scene → Camera: includes · Camera is part of the serialized scene state.
- Game scene → Objects: contains · Scene owns the world objects.
- Objects → Physics: updates through · Objects are advanced by the physics subsystem.
- Game scene → Physics: runs with · Active scene is paired with the simulation thread.
- Physics → Save parser: serializes to · Simulation state is persisted as part of the save format.
- Save parser → Save assets: reads · Load pipeline reads bundled save scenarios.
- Config manager → Config assets: reads · Configuration manager loads shipped config files.
- UI layer → UI assets: skins with · Interface uses bundled fonts and skin assets.
- Server main → Shared: depends on · Server module likely shares common code boundary.