Code Monkey home page Code Monkey logo

obb-for-phaser's Introduction

OBB-for-Phaser

⚠️ WARNING ⚠️

🚧 This project is not actively maintained and therefore in archive state. 🚧

Description

This project is about replacing Phaser.io's Arcade Physics AABB collision detection (which doesn't offer bounding box rotation) with "Oriented bounding box" collision detection or short OBB.

The great benefit: OBB supports rotating bounding boxes!

Important

This project is in a testing state. Please feel free to add pull requests and issues!

Usage

  • Download the obb.js file from the sources
  • Add it to your html right behind phaser, like this:
<script type="text/javascript" src="lib/phaser.js"></script>
<script type="text/javascript" src="lib/obb.js"></script>
  • Then in your game.js add this line in the preload function (I assume you already have started the Arcade physics)
OBB.setOBB(this.game);

Debugging

For debugging purposes you can use the OBB.debug object. Currently it only supports drwaing the vertices of bodies. You can use it like this:

render: function () {
    // Standard for the drawn vertices is red
    OBB.debug.drawVertices(this.player.body);

    // Or you can set a custom color; blue for example
    // OBB.debug.drawVertices(this.player.body, "0x0000ff");
}

Bower

As soon as this project is stable and safe to use, I will add it to bower.

Known issues

  • Currently the collision detection works fine, but collided objects do not correctly bounce off each other yet.
  • There is no touching state

License

MIT. See the LICENSE.md file in this repository for more information.

Use it on your own risk!

Be aware that you use this code on your own risk. The authors of this code won't take any responsibilites for anything.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

obb-for-phaser's People

Contributors

tobiasmuecksch avatar

Stargazers

David Hayes avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.