Skip to content

Click/Touch input generates circular rigid bodies that bounce within the canvas element until they come to a stop.

Notifications You must be signed in to change notification settings

PaulPineda/simple-physics-bounce

Repository files navigation

Simple physics engine

This is a simple demo of rigidbody physics.

Clicking within the dotted bordered canvas area creates a ball object that bounces within the dotted border until it comes to rest.


Testing:

This is just a regular npm package so once cloned, run:

npm install && npm run dev

Minification:

Once cloned and the dependencies have been installed you can create a minified version by running: npm run build


The following values can be adjusted to create different environments:

defaultVx/defaultVy (Default for both is 1000) These represent the x and y speed range used as the initial values (the defaults for both are 1000)

maxFps (Default: 1/60) The maximum elapsed time used to calculate the updated Ball position

gravity Default: 9.8 The value for gravity

friction Default: 0.7 The value used to reduce the speed of the rigid body when it bounces off the canvas borders

About

Click/Touch input generates circular rigid bodies that bounce within the canvas element until they come to a stop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published