This project is a simple 2D physics engine built in Java. It uses a component-based architecture and integrates with the Dominion ECS (Entity Component System) library for managing entities and components.
- Entity-Component System (ECS): Powered by Dominion ECS for efficient entity management.
- Rendering System: Supports rendering of basic shapes like squares and circles.
- UI System: Comprehensive UI framework with buttons, labels, panels, sliders, and debug overlays.
- Physics Simulation: Basic physics capabilities including collision detection and response.
- Transformations: Handles position, rotation, and scaling of objects.
- Customizable Game Engine: Includes a
GameEngineclass to manage the game loop and rendering. - Scene Management: Support for multiple scenes and entity management.
- Java 17 or higher
- Maven for dependency management and building the project
For detailed documentation, please visit our Wiki which includes:
- Getting Started Guide
- UI System Documentation
- Component System Documentation
- Physics System Documentation
- Example Use Cases
import com.engine.core.GameWindow;
import com.engine.ui.UISystem;
import dev.dominion.ecs.api.Dominion;
public class QuickStart {
public static void main(String[] args) {
// Create main game window
GameWindow window = new GameWindow("My First Game", 800, 600);
// Initialize ECS
Dominion ecs = Dominion.create();
// Create UI system
UISystem uiSystem = new UISystem(window, ecs);
// Create a button
uiSystem.createButton("Click Me!", 300, 250, 200, 50);
// Simple game loop
while (true) {
uiSystem.update(0.016); // ~60fps
window.clear();
window.render();
try { Thread.sleep(16); } catch (InterruptedException e) { }
}
}
}-
Clone the repository:
git clone https://github.com/Mustfa-IT/java2dphysics.git cd java2dphysics -
Build the project using Maven:
mvn clean install
-
Run the application:
mvn exec:java -Dexec.mainClass="com.Main"
-
src/main/java/comMain.java: Entry point of the application.core/: Contains the core game engine and window management classes.components/: Defines components likeTransform,RenderableComponent, andUIComponent.graph/: Includes rendering-related classes likeShape,Square, andCircle.ui/: Contains UI system and elements likeButton,Label,Panel, andSlider.physics/: Physics simulation system and related components.entity/: Entity management and scene system.
-
pom.xml: Maven configuration file for dependencies and build settings.
Contributions are welcome! Please see our Contributing Guide for details on how to participate in this project.
This project is licensed under the MIT License. See the LICENSE file for details.