1.1.1 • Published 3 years ago

impact2d v1.1.1

Weekly downloads
22
License
ISC
Repository
github
Last release
3 years ago

About The Project

This is a light wight 2d physics engine for web development. Gives reasonable physics simulation for 2d convex geometries.

Demo

Usage

Very simple to use and configure.

Copy library code main.js from ./dist folder

 const {Engine, Shapes} = Impact2d
 const {Circle, RegPoly} = Shapes;
 
 // Create a world 2000 pixels * 2000 pixels
 let world = new Engine({scale: 2000, delta: 0.02});
 world.setGravity = 1;
 
 // Circle
 let body1 = new Circle({
  id: 'body1',
  x: 100,
  y: 100,
  r: 30,
  m: 100
 });
 
 // Regular polygon with 6 faces
 let body2 = new RegPoly({
  id: 'body2',
  x: 400,
  y: 100,
  r: 30,
  sides: 6,
  m: 50
 });
 world.addEntity(body1);
 world.addEntity(body2);
 
 // Run the simulation
 const tick = () => {
   world.tick();
   requestAnimationFrame(tick)
 }
 requestAnimationFrame(tick)

Highlighes

  • Maintained a Quadtree for storing spacial data for efficient search and thus good performance.
  • Built-in renders for fast drawing on the canvas.

Acknowledgements

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago