GithubHelp home page GithubHelp logo

openfl / box2d Goto Github PK

View Code? Open in Web Editor NEW
95.0 9.0 27.0 313 KB

Haxe port of Box2D, a popular rigid-body 2D physics engine

License: Other

Haxe 91.75% ActionScript 8.25%
box2d haxe openfl physics physics-engine

box2d's Introduction

MIT License Haxelib Version Build Status Community Discord Server


Introduction

The OpenFL project is an open-source answer to the needs of game and application developers everywhere, looking for a fast, simple approach to delivering creative masterpieces without relying on a specific implementation, such as a browser plugin.

Using the innovative Haxe programming language, OpenFL supports wildly different platforms using one codebase. Transitioning from one target type to another is simple, and keeps the strengths of the target environment. OpenFL builds to native C++, Neko or Flash bytecode, or JavaScript, enabling maximum compatibility and runtime performance.

OpenFL depends on Lime, which has easy-to-use command-line tools, and provides backend support.

Platforms

Currently, OpenFL supports the following platforms:

  • iOS
  • Android
  • HTML5
  • Windows
  • macOS
  • Linux
  • Flash
  • AIR

There is also a community effort to bring OpenFL to consoles, OpenFL is running on:

  • Switch
  • Wii U
  • PlayStation 4
  • PlayStation 3
  • PlayStation Vita
  • Xbox One

Additional details on console support will be available in the future.

OpenFL is also being used in additional environments:

  • TiVo boxes
  • Raspberry Pi
  • Node.js

Libraries

OpenFL is compatible with many libraries, ported from ActionScript or written originally in Haxe, including:

OpenFL also powers other platforms, such as Stencyl.

Code Editors

Plugins have been written for many code editors, but the most popular editors used for Haxe and OpenFL development are:

Easy Deployment

OpenFL includes the tools you need to build, package, install and run on each target platform.

For example, openfl test html5 will generate an HTML5 project, create a local web server and open your default browser.

Some platforms will require a standard SDK to build (such as Visual Studio C++ or Xcode). OpenFL includes "setup" commands to even help the install of these standard tools.

3D Support

OpenFL is designed primarily for 2D development, but you can use the OpenGLRenderer API to write your own WebGL-style code, and mix it with the OpenFL display architecture.

OpenFL also has support for the Stage3D API. If you like you can use this directly, or you can also use libraries such as Away3D or Starling.

Native Extensions

When you target a native platform, the output is true native C++, enabling deep integration with platform features and third-party SDKs. There is a standard Haxe "CFFI" API for connecting Haxe classes directly to C++ libraries.

We have also developed a straight-forward Android library project API for adding Java-based extensions, too. Native extensions can also use the standard Lime project format, for flexible control over dependencies, adding additional assets or tuning the output of your project.

The result are native extensions that can be made to interchangeably drop into projects, without breaking one another. We have made no attempt to emulate the system for AIR native extensions, which are much more difficult to create and less flexible.

Core Components

OpenFL relies upon Lime, a foundation for cross-platform project development.

hxcpp is used automatically by the Lime tools to manage the C++ compilation process for each platform, and to provide the Haxe standard library for C++ support.

License

OpenFL is free, open-source software under the MIT license.

Installing OpenFL

Follow the directions at openfl.org.

Development Builds

When there are changes, OpenFL is built nightly. Builds are available for download here.

To install a development build, use the "haxelib local" command:

haxelib local openfl-haxelib.zip

Building from Source

Clone the OpenFL repository:

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

Tell haxelib where your development copy of OpenFL is installed:

haxelib dev openfl openfl

To return to release builds:

haxelib dev openfl

You may also need a development build of Lime installed.

box2d's People

Contributors

amiani avatar beeblerox avatar gama11 avatar hypersurge avatar jarnik avatar jgranick avatar justnajm avatar lerg avatar marc-jones avatar randomnine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

box2d's Issues

Remove dependency on Flash

I'm trying to use box2d in my Heaps.io project, compiled for HashLink. The compilation fails because of the usage of flash.display.Sprite in B2DebugDraw.

Since I probably don't need debug draw I was wondering if we can wrap this code around a compile flag (using #if swf or maybe a custom debug_draw flag).

I'm pretty new to Haxe, but since this seems like an easy PR I could look into it if you like the idea.

Std.is is deprecated

There are warnings inside this library that say Std.is is deprecated. I see no reason not to switch all references to Std.is to Std.isOfType.

B2internal::m_p.set() what alternate ?

Hi,

I was trying box2d buoyancy example as3 in openfl but unable to find any alternate method for this "circDef.b2internal::m_p.Set(30 / m_physScale, 0 / m_physScale);".

bodyDef.position.set(300/ m_physScale, 300 / m_physScale);
body = m_world.createBody(bodyDef);
circDef = new B2CircleShape(7 / m_physScale);
fd = new B2FixtureDef();
fd.shape = circDef;
fd.density =2;
// circDef.computeMass(30 / m_physScale, 0 / m_physScale);
// circDef.B2internal:m_p.set(30 / m_physScale, 0 / m_physScale);
body.createFixture(fd);
// circDef.B2internal::m_p.set(-30 / m_physScale, 0 / m_physScale);
body.createFixture(fd);
// circDef.B2internal::m_p.set(0 / m_physScale, 30 / m_physScale);
body.createFixture(fd);
// circDef.B2internal::m_p.set(0 / m_physScale, -30 / m_physScale);
body.createFixture(fd);

By commenting the b2internal call I am able to run example but water is not interacting with bodies at all.

body.setFixedRotation cause error.

When I use the method with a dynamic body the game crash on all platforms.
Flash player said this:

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at box2D.dynamics::B2Body/resetMassData()[C:\HaxeToolkit\haxe\lib\box2d/1,2,0/box2D/dynamics/B2Body.hx:721]
at box2D.dynamics::B2Body/setFixedRotation()[C:\HaxeToolkit\haxe\lib\box2d/1,2,0/box2D/dynamics/B2Body.hx:1004]

LiquidFun integration

Integrating the changes provided by Google's LiquidFun library would provide particle-based fluid and soft body simulation to the library.

Code to reference:

Default value of B2Mat22 is probably wrong

class B2Mat22
{
    public function new ()
    {
        col1 = new B2Vec2(0, 1.0);
        col2 = new B2Vec2(0, 1.0);
    }
}

This would initialize the matrix in a way that when used as a transform results in a width of 0, which is hardly ever useful. I'd except it to be initialized as such:

class B2Mat22
{
    public function new ()
    {
        col1 = new B2Vec2(1.0, 0);
        col2 = new B2Vec2(0, 1.0);
    }
}

Can't edit contacts! (box2dflash 2.1a was outdated, broken, incomplete)

I wanted to raise this issue mainly to raise awareness as there is no simple fix.

The version of Box2D which this is a port of (2.1a) is not only very out of date, but was broken/incomplete at the time and lost some critical features compared to the even older 2.0.2. C++ box2d has since developed far beyond this version (2.3.1 in 2014) and never lost those critical features.

The main missing feature I came across was that in 2.1a you cannot modify a contact, which is a really big deal. For example, suppose you want to use a listener to change the friction of a contact based on the normal, in cpp this is easy (https://github.com/erincatto/Box2D/blob/master/Box2D/Dynamics/Contacts/b2Contact.h#L120). These variables and methods are not new; they pre-date version 2.1.

But for some reason they were removed from flash 2.1a so now contacts don't even have these properties in flash/haxe 2.1a.

I would recommend the cpp version as a better source as it is not only more up to date with better features, but also isn't critically broken when it comes to editing contacts.

Compilation fails on neko

Using the openfl-sample SimpleBox2D openfl/openfl-samples#8.
This is the result from test with Haxe 3.0.1 and Neko 2.0.0 on a Mac 64.

$ openfl test neko
Called from box2D/common/B2Settings.hx line 72
Uncaught exception - Invalid operation (*)

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.