Skip to content

This repository contains the source code of a 2D physics engine written in javascript from scratch without using any physics librairies.

Notifications You must be signed in to change notification settings

TheRedShip/2D-Physics-engine

Repository files navigation

2D-Physics-engine

This repository includes the source code for a 2D physics engine implemented in JavaScript, entirely from scratch without reliance on any external physics libraries. The engine is capable of simulating ball collisions, gravitation and other things, adhering to real-world physical laws such as the law of conservation of energy.


⚠️Please be advised that this project is still in it's beta phase and may still experience bugs and glitches.⚠️

Summary

Features

  • More than a hundred ball collisions in real time.

  • Ability to simulate multiple objects with varying mass and velocity

  • The engine provides control over the friction and gravity of each individual object.

  • Creating walls and curves.

  • Can copy objects, ball and walls.
  • Realistic simulation of gravitation and object's attraction.

  • Perfectly circular orbit around any object.

  • Integration of springs in order to constraints movements.

  • Allow to zoom out and zoom in, and move the camera with right click.

Installation

  1. Clone this repository
  2. Serve the index.html file through a server service, such as express,flask or by utilizing the built-in server feature in Visual Studio Code.

Examples

To showcase the capabilities of the physics engine, here is some examples:

Multiple collisions in a bottle scenario

Double pendulum experiment

Newton's gravity implementation

Gravity prediction

All features working simultaneously

Credits

About

This repository contains the source code of a 2D physics engine written in javascript from scratch without using any physics librairies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published