Defold-box2d Box2D extension

Thanks. I will use your code. It better😁
I am not good at c++ :))

I will later look on lual_error. Replacing assert with lual_error will be the best solution:)

1 Like

Hey, I think your contribution is great! :clap:

4 Likes

Ohh. luaL_error very strange :slight_smile:
It stop execution as excepted.
But on windows it does not contains error on stack. pcall return table from function args, not error string
On html that error is not catched by pcall, and game is crashed:)

#define b2Assert(expr) \
{ \
    if (!(expr)) { \
        dmLogError("[ERROR]b2Assert. Expr:%s",#expr); \
        luaL_error(box2dDefoldNE::GLOBAL_L,"[ERROR]b2Assert. Expr:%s",#expr); \
        dmLogError("After luaL_error"); \
    } \
}
test("b2Assert", function()
            local shape = box2d.NewPolygonShape()
            local status, value = pcall(shape.Set,shape,{ vmath.vector3(0, 0, 0), vmath.vector3(1, 0, 0) })
            assert_false(status)
            UTILS.test_error(value,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
        end)

I’ve released a new version 1.0.0
Hooray :partying_face: :partying_face: :partying_face:

I am believe this extension is ready for using in games.

It 99% binding of box2d. Some functions and classes are not binded, but it have all you need to make a game with physic.

Now it have 241 tests. First version have 195.

Fixed some bugs, and add new functions.

[CHANGELOG]

1.Replace b2assert with dmLogError
2.Refactor wrapper for b2Contact
3.Fixed wrappers for box2dObjects was not delete.
4.Add old_manifold and impulse to contact listener
5.Add Box2dContact:GetNext()
6.Add Box2dWorld:GetContactList()
7.Add Box2dBody:GetJointList()
8.Add Box2dBody:GetContactList()

11 Likes

Make a simple game with box2d extension.

18 Likes

Thank you @d954mas for this extension! :heart:

As a kind reminder Dmitry beside of this created for us i.a. emmylua integrations for intellij and vscode, many open sourced game examples or 2.5D shooter example. So, I guess it’s reasonable I can shameleslly plug he also has Patreon/Coffee pages :wink:

3 Likes

Update to 1.0.1. Thanks to @AGulev
1)Add M1 architecture
2) Make installation easier. (not need to use app.manifest)

7 Likes

hii i’m using defold 1.6.3 i downloaded the box 2d project from Github (Demo Project) which runs fine in on build but when i build HTML5 it loads in browser but after showing Defold logo it shows black screen …do it support this version of Defold? or something else is wrong?

1 Like

Look at console, and fix some errors in lua.
It not worked in 1.6.3

You need to replace some ; with ,

I will fixed it in weekends.

1 Like

i hope soon it will be ready to use :upside_down_face: , btw i’m interested in creating "Real time Slice the Object " ( like fruit ninja but not predecided slices) … is it possible using this extension?

1 Like

Yes. You can create a polygon shape in runtime to make sliced parts.

In fruit ninja I think you can slice object only once?

2 Likes

not sure if it allows only one cut but i think they just spawn two prefabs of piece objects ( rather than cutting real collision shape of fruit into two) when the cut goes through fruit …

Yes, Fruit Ninja cuts fruits to two pre-defined parts most probably (instantiating two parts in place of the one that was “sliced”).

Metal Gear Rising has cuts that comes to my mind immediately, when you described them :smiley: I think we need also runtime resources creation features like dynamic mesh creation, dynamic texturing etc and afaik all the blocks are in Defold already, right?

2 Likes