Git Product home page Git Product logo

box2d's Introduction

MIT License Haxelib Version

Box2D

The Box2D rigid-body 2D physics engine, ported to Haxe from the Box2DFlash port by Boris the Brave.

The syntax has been updated to follow the standard Haxe convention, for example:

ActionScript

var world:b2World = new b2World (new b2Vec2 (0, 10.0), true);
var worldScale:int = 30;
    
var body:b2BodyDef = new b2BodyDef ();
body.position.Set (250 / worldScale, 200 / worldScale);
body.type = b2Body.b2_dynamicBody;
  	
var circle:b2CircleShape = new b2CircleShape (10 / worldScale);
var fixture:b2FixtureDef = new b2FixtureDef ();
fixture.shape = circle;
  	
player = world.CreateBody (body);
player.CreateFixture (fixture);

The above ActionScript code would be written like this in Haxe:

Haxe

var world = new B2World (new B2Vec2 (0, 10.0), true);
var worldScale = 30;
    
var body = new B2BodyDef ();
body.position.set (250 / worldScale, 200 / worldScale);
body.type = DYNAMIC_BODY;
    
var circle = new B2CircleShape (10 / worldScale);
var fixture = new B2FixtureDef ();
fixture.shape = circle;
    
player = world.createBody (body);
player.createFixture (fixture);

Installation

You can easily install Box2D using haxelib:

haxelib install box2d

To add it to a Lime or OpenFL project, add this to your project file:

<haxelib name="box2d" />

Development Builds

Clone the Box2D repository:

git clone https://github.com/openfl/box2d

Tell haxelib where your development copy of Box2D is installed:

haxelib dev box2d box2d

To return to release builds:

haxelib dev box2d

box2d's People

Contributors

jgranick avatar hypersurge avatar randomnine avatar lerg avatar gama11 avatar jarnik avatar justnajm avatar beeblerox avatar amiani avatar marc-jones 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.