Better HN
topnewbestaskshowjobs
Log inSign up

shakiba

111 karma · joined Mar 21, 2013 (13y ago) · 83 submissions

[ my public key: https://keybase.io/shakiba; my proof: https://keybase.io/shakiba/sigs/FQHp2InsGkNbADXbCwZU73JSjfwhWhkr7SlWpdsexXw ]
Submissions

1.

Ask HN: Can we stop Coronavirus if enough people volunteer to catch it?

2 points · by shakiba · 6y ago · 7 comments

comment 6y ago · link · parent

That's right, it's only rendering and layout library.

3.

Ask HN: How to Implement `toString` in JavaScript with Functional Programming?

1 points · by shakiba · 8y ago · 1 comment

comment 9y ago · link · parent

I guess I fixed the issue that you pointed out, it was a new bug in testbed. Thanks for reporting!

You may need to force-reload the example to see the update. Please let me know if the issue still exists for you.

comment 9y ago · link · parent

Thanks! It is easy to integrate Planck.js with other liraries and dev tools.

comment 9y ago · link · parent

Thank you!

I have not seen any problem with car example on my own laptop, but I will try it on some more different devices to find the issue.

Regarding performance, because Planck.js code is hand-made and readable it is not difficult to improve it if it is not fast enough with some cases.

asm.js looks promising, I'm going to have a closer look at it.

comment 9y ago · link · parent

The game is very cool! :)

comment 9y ago · link · parent

P2.js was a great effort and is a nice project. It is also inspired by Box2D and its API is very similar, however Box2D algorithm and architecture are more sophisticated and stable, and is already used in many popular games (such as AngryBirds) and game dev libraries (such as Apple's SpriteKit) so I decided to rewrite Box2D to make it available to JS/HTML5 game developers as well.

comment 9y ago · link · parent

Box2DJS is based on an old Flash port and as far as I remember it didn't work well when I tested it (for example second example on the website doesn't work currently, right click to switch to next example). I decided to directly port from C++ so that I can keep it updated.

comment 9y ago · link · parent

Awesome, thank you!

comment 9y ago · link · parent

Probably it would be easy, I would be happy to help with that, please feel free to open an issue on github.

comment 9y ago · link · parent

Those are changes to internals, there are only few API differences which are explained on readme page. Anyway, I agree with you, a new API doc would be very helpful.

comment 9y ago · link · parent

The main difference is that it is a hand-made rewrite, so the code is readable and improvable, so performance can be improved and optimized even if it is not fast enough in some cases. Also see my other comment about comparison with emscripten port.

comment 9y ago · link · parent

In JS, if you pass same input it will give you same results. With box2d/planck frequency needs to be constant anyway, and I have not seen any nondeterministic component in the code. (I think in box2d docs it refers differences in execution platforms not the library itself.)

comment 9y ago · link · parent

Great work! I decided to directly rewrite Planck.js from Box2D C++ code, so that I can keep it updated (as far as I remember that flash port was few years old).

comment 9y ago · link · parent

Thanks! Repost from reddit:

The main reasons that I decided not to use Emscripten port was usability:

- First, it is generated and unreadable code, therefore it is impossible to understand how it actually works in JS to use it optimally, debug it or improve it for JS. While it possible to improve Planck.js if it is not as fast in some cases, it is not possible to do anything with Emscripten port.

- Second, API of Emscripten port does not follow JavaScript conventions and is inconvenient to use in JavaScript. For example it returns an empty object, instead of no object (null or undefined) as last element of a linked list (which is very confusing in JS). Here are some more usage comparisons:

    // emscripten
    var bd_ground = new Box2D.b2BodyDef();
    var ground = world.CreateBody(bd_ground);
    var shape0 = new Box2D.b2EdgeShape();
    shape0.Set(new Box2D.b2Vec2(-40.0, -6.0), new Box2D.b2Vec2(40.0, -6.0));
    ground.CreateFixture(shape0, 0.0);    

    // planck.js
    var ground = world.createBody({});
    ground.createFixture(planck.Edge(Vec2(-40.0, -6.0), Vec2(40.0, -6.0)), 0.0);

    // emscripten
    var bd = new Box2D.b2BodyDef();
    bd.set_type(Box2D.b2_dynamicBody);
    bd.set_position(ZERO);
    var body = world.CreateBody(bd);

    // planck.js
    var body = world.createBody({
      type: "dynamic",
      position: Vec2(0, 0),
    });
    // or just world.createDynamicBody();

    // emscripten    
    myQueryCallback = new Box2D.JSQueryCallback();
    myQueryCallback.ReportFixture = function(fixturePtr) { };

    // planck.js
    myQueryCallback = function(fixture) { };

comment 9y ago · link · parent

Planck.js developer here! I have posted this to reddit before, so I'm just going to include it here too:

I have ported/rewritten Box2D physics engine to JavaScript, for cross-platform HTML5 game development. Planck.js includes entire Box2D algorithms, a simple HTML5 Testbed, more than 50 examples and some new game prototypes. The project is pre-released and there may still be minor issues, which I'm working to fix. So far I have spent more than 400 hours for developing this project and it consists of around 20k lines of code.

https://github.com/shakiba/planck.js

My main motivations for working on this project are:

- Taking advantage of Box2D's efforts, achievements and community knowledge

- Developing readable and maintainable JavaScript code

- Optimizing the library for web and mobile platforms

- Providing a JavaScrip-friendly API

Your feedback is highly appreciated, and I hope you use Planck.js to make some awesome games soon!

comment 9y ago · link · parent

Thank you! Just fixed it! I actually LOLed very hard!

comment 10y ago · link · parent

Author here! Thanks for troll comment!

comment 10y ago · link · parent

> when I look at an open-source codebase built on React + Redux, it's so easy to understand the application architecture.

That's my point, I believe a library should not imply architecture.

21.

Redux is Overhyped(medium.com ↗)

7 points · by shakiba · 10y ago · 4 comments

22.

Redux is Overhyped(medium.com ↗)

2 points · by shakiba · 10y ago · 3 comments

comment 10y ago · link · parent

:)
123