Skip to content

About

A modular 2D Game Engine built with Java Swing and AWT.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Java 2D Game Engine — Game-loop-0.1

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.

Features

Core Engine & Configuration

  • Engine lifecycle management — Dedicated core components for managing the engine thread and runtime lifecycle.
  • Runtime metrics — System metrics for monitoring engine performance.
  • Persistent configuration — EngineConfig for loading and managing engine settings and properties.

Entity & Scene Management

  • State-driven entities — EntityState-based behavior management and state transitions.
  • Scene management — Modular scene architecture with TestScene and support for tilemap integration.
  • Object lifecycle management — Structured handling of active scene objects and their lifecycles.

Physics & Collision Detection

  • 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 CollisionEvent containers and listeners for responsive physics callbacks.

Graphics & Visual Effects

  • 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 & Audio

  • Input handling — Keyboard and mouse bindings with event dispatching.
  • Audio subsystem — Configurable audio listeners and playback components.

Tilemap & Level Serialization

  • CSV map serialization — MapSerializer for 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.

Debugging & Developer Tools

  • 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.

Architecture

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

Architectural Principles

  • 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.

Requirements

  • 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.

Getting Started

1. Clone the Repository

git clone https://github.com/Nash6643/Game-loop-0.1.git
cd Game-loop-0.1

2. Compile the Source

If 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")

3. Run the Engine

If engine.core.Main is the configured entry point, run:

java -cp bin engine.core.Main

Note: Replace engine.core.Main with 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.

Tilemap Format

The tile subsystem supports CSV-based level data, allowing maps to be represented as grids of integer tile identifiers.

Example

1,1,1,1,1
1,0,0,0,1
1,0,2,0,1
1,1,1,1,1

Tile Identifiers

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.

Project Goals

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.

Future Improvements

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.

License

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

About

A modular 2D Game Engine built with Java Swing and AWT.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages