A lightweight 2D rigid-body physics simulation sandbox built with HTML5 Canvas and vanilla JavaScript.
🤖 AI Disclosure: This project was created primarily using AI assistance (Gemini). The physics integration, vector maths, collision resolution scripts, and UI code were generated through AI prompts, while I handled project direction, debugging, testing, and deployment.
- Sub-stepping Integrator: High-precision motion integration for stable high-speed simulations.
- Impulse-Based Collision Resolution: Handles circle-circle, circle-box, and box-box dynamic collisions.
- Rotational Dynamics: Realistic moment of inertia, angular velocity (\omega), torque, and friction-driven rolling calculations.
- Interactive Sandbox UI: Create particles, boxes, fixed anchors, springs, and pulleys dynamically.
- Visual Force Vectors: Live rendering of gravitational forces (F_g), normal forces, and spring constraints.
No installation or downloading is required to use this project! You can instantly run and play with the physics engine directly in your web browser by visiting the live GitHub Pages link:
👉 https://coolbeingdude.github.io/2d-physics-engine/
(Note: Downloading the repository is only necessary if you want to run or modify the source code offline.)
If you wish to run or edit the source code locally, no dependencies or build steps are required:
- Clone this repository: git clone https://github.com/Coolbeingdude/physics-engine.git
- Open
index.htmlin any modern web browser.
- Spawn Objects: Use the control panel or toolbar to add particles, rigid boxes, or springs.
- Drag & Drop: Click and drag objects in real-time to test physics interaction.
- Anchors: Toggle the anchor pin on any object to lock it in place.
- Tweak Environment: Adjust gravity and friction settings live.
This project is licensed under the MIT License - see the LICENSE file for details.