I am working on a 2D HTML Canvas JavaScript engine that now has a very simple physical component that just goes through each object and:
- Adds an acceleration vector to the velocity vector
- Adds a velocity vector to a position vector
- Checks for conflicts between objects, but does nothing but call onCollide methods of objects (physical answer - objects just pass through each other)
This works fine so far and regardless of the frame rate, but I need to give up support for something that supports:
- Interaction with a solid (I think the correct word), where the objects in contact exert a resistive normal force on each other
- Collider windows that can be rotated - at the moment I use only colliders and Pythagorus to find where the two contacts are.
- Forces
The engine runs on dynamic FPS, which means that physics must be independent of frame rate. I seem to be reluctant to use any libraries, but if what I try is just silly without it, I am ready to use something like Box2DJS, etc.
Also, if I use JavaScript, performance will be more important than accuracy, I would say.
Sorry if this is a duplicate, but I couldn’t find anything along the way of creating a simple physical engine using only libraries.
Hooray!:)
source
share