Skip to content

Repository files navigation

2D Canvas Physics Engine & Sandbox

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.


🚀 Features

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

🕹️ Try It Online!

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

🛠️ Getting Started (For Offline Development)

If you wish to run or edit the source code locally, no dependencies or build steps are required:

  1. Clone this repository: git clone https://github.com/Coolbeingdude/physics-engine.git
  2. Open index.html in any modern web browser.

🎮 How to Use

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

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An interactive 2D rigid-body physics engine built with HTML5 Canvas and vanilla JavaScript. Features custom numerical integration, rotational dynamics, springs, and collision resolution.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages