Sleepy-Fish / BogieJS

Simple collision extensions for PIXI.js
MIT License
2 stars 0 forks source link

Spacial Bounce Option #3

Open JRileyH opened 4 years ago

JRileyH commented 4 years ago

As a variable option parameter to Spacial class there should be a boolean “bounce” (default to false probably) that automatically adds on-collision behavior to dynamic Spacials.

The behavior should be to make appropriate changes to velocity to give the appearance of bouncing off another spacial after colliding.

This will require some subclassing and smart planning on where the behavior logic should be stored (most likely either physics/collisions.js function library or on the Spacial subclass). We also may want to make a Spacial bouncable on one physics world layer but only fire collision events on another layer so bounce options may need to be more complex than a boolean (string, boolean key value pair maybe)

This should also be extendable to utilize physical material properties stored on the spacial that dictate bounce behavior such as how much velocity is lost on bounce if we ever decide to add that. Perfect elastic collision is reasonable to assume for now though.