A modular, lightweight 2D game engine built with Java and Swing/AWT, featuring a dedicated game loop, state-driven entities, AABB collision detection, event-driven physics, camera tracking, particle effects, and CSV-based tilemap serialization.
Designed with a modular architecture, the engine separates core systems into dedicated packages, promoting maintainability, extensibility, and clear separation of responsibilities.
- Engine lifecycle management — Dedicated core components for managing the engine thread and runtime lifecycle.
- Runtime metrics — System metrics for monitoring engine performance.
- Persistent configuration —
EngineConfigfor loading and managing engine settings and properties.
- State-driven entities —
EntityState-based behavior management and state transitions. - Scene management — Modular scene architecture with
TestSceneand support for tilemap integration. - Object lifecycle management — Structured handling of active scene objects and their lifecycles.
- AABB collision detection — Axis-Aligned Bounding Box collision checks for objects and static obstacles.
- Trigger boundaries — Collision boundaries for detecting interactions and trigger events.
- Event-driven collision handling — Decoupled
CollisionEventcontainers and listeners for responsive physics callbacks.
- 2D camera system — Viewport management with linear interpolation (lerp) for smooth target tracking.
- Particle emitter system — Particle generation, batching, lifetime management, and resource cleanup.
- Layered tile rendering — Multi-layer tilemap rendering integrated with scene management.
- Input handling — Keyboard and mouse bindings with event dispatching.
- Audio subsystem — Configurable audio listeners and playback components.
- CSV map serialization —
MapSerializerfor importing and exporting tile-based levels. - Custom level layouts — Simple, human-readable CSV data for defining map grids.
- Scene integration — Tilemap support within the scene management layer.
- Interactive debug overlay — Runtime debugging interface with performance metrics and audio controls.
- Collision visualization — Bounding-box overlays for inspecting collision boundaries.
- Runtime controls — Interactive tools for inspecting and controlling selected engine features.
The engine is organized into dedicated packages, each responsible for a distinct subsystem.
engine/
├── audio/ # Audio playback and event listeners
├── config/ # Runtime configuration and persistence
├── core/ # Engine lifecycle, game loop, and metrics
├── entity/ # Entity behavior and state management
├── fx/ # Particle emitters and visual effects
├── graphics/ # Camera viewport and target tracking
├── input/ # Keyboard/mouse bindings and event dispatch
├── physics/ # AABB collision detection and collision events
├── scene/ # Scene management and world integration
├── tile/ # CSV tilemap serialization
└── ui/ # Debug overlays and runtime controls
- Separation of concerns: Each subsystem has a clearly defined responsibility.
- Modularity: Components are organized to support independent development and maintenance.
- Event-driven interactions: Collision and audio-related events help decouple system behavior.
- Extensibility: The package structure provides a foundation for adding new gameplay and engine features.
- Java Development Kit (JDK): 11 or later recommended.
- Build tools: A Java compiler (
javac) and runtime (java). - IDE (optional): IntelliJ IDEA, Eclipse, or Visual Studio Code.
git clone https://github.com/Nash6643/Game-loop-0.1.git
cd Game-loop-0.1If the Java source files are located under the engine/ directory, compile them into a bin/ directory:
mkdir -p bin
javac -d bin $(find engine -name "*.java")If engine.core.Main is the configured entry point, run:
java -cp bin engine.core.MainNote: Replace
engine.core.Mainwith the fully qualified name of your actual entry-point class if it differs. The commands above assume a Unix-like shell; Windows users can run equivalent commands in Git Bash or adapt them for PowerShell.
The tile subsystem supports CSV-based level data, allowing maps to be represented as grids of integer tile identifiers.
1,1,1,1,1
1,0,0,0,1
1,0,2,0,1
1,1,1,1,1| ID | Meaning |
|---|---|
0 |
Empty or walkable space |
1 |
Solid wall or collidable tile |
2 |
Trigger or event tile |
These identifiers are illustrative; their actual behavior depends on the tile definitions and collision logic configured in the engine.
Game-loop-0.1 explores the fundamental systems behind a modular 2D game engine, including:
- Game-loop and engine lifecycle management.
- Entity state and scene management.
- Collision detection and event-driven interactions.
- Camera movement and particle effects.
- Tilemap rendering and level serialization.
- Runtime debugging and subsystem integration.
The project provides a foundation for experimenting with game-engine architecture and expanding toward more advanced 2D gameplay systems.
Potential areas for further development include:
- Build automation with Maven or Gradle.
- Automated unit and integration tests.
- Improved physics resolution and collision response.
- Expanded animation and sprite-rendering systems.
- Additional tilemap editing and layer-management tools.
- Performance profiling and frame-time analysis.
- Example scenes demonstrating individual engine subsystems.
Add a license file to the repository if you intend to distribute the project under an open-source license.
Repository: Nash6643/Game-loop-0.1