{"id":16187086,"url":"https://github.com/robloach/chaiscript_extras_box2d","last_synced_at":"2025-04-02T03:31:19.039Z","repository":{"id":66036232,"uuid":"147892204","full_name":"RobLoach/ChaiScript_Extras_Box2D","owner":"RobLoach","description":"ChaiScript Box2D Bindings","archived":false,"fork":false,"pushed_at":"2019-01-08T19:09:50.000Z","size":124,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T18:02:01.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobLoach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-08T02:01:29.000Z","updated_at":"2020-04-14T10:10:44.000Z","dependencies_parsed_at":"2023-02-21T20:16:23.993Z","dependency_job_id":null,"html_url":"https://github.com/RobLoach/ChaiScript_Extras_Box2D","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2FChaiScript_Extras_Box2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2FChaiScript_Extras_Box2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2FChaiScript_Extras_Box2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2FChaiScript_Extras_Box2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobLoach","download_url":"https://codeload.github.com/RobLoach/ChaiScript_Extras_Box2D/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246746916,"owners_count":20827062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:20:14.612Z","updated_at":"2025-04-02T03:31:18.689Z","avatar_url":"https://github.com/RobLoach.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChaiScript Extras Box2D [![Build Status](https://travis-ci.org/RobLoach/ChaiScript_Extras_Box2D.svg?branch=master)](https://travis-ci.org/RobLoach/ChaiScript_Extras_Box2D)\n\nProvides [ChaiScript](https://github.com/ChaiScript/ChaiScript) bindings to [Box2D](https://github.com/erincatto/Box2D).\n\nThis is currently just a proof of concept. Any assistance in getting this up and running would be much appreciated.\n\n## Usage\n\n1. Include the module source...\n    ```cpp\n    #include \"ChaiScript_Extras_Box2D/include/chaiscript/extras/box2d.hpp\"\n    ```\n\n2. Add the module to the ChaiScript instance...\n    ```cpp\n    auto box2dlib = chaiscript::extras::box2d::bootstrap();\n    chai.add(box2dlib);\n    ```\n\n3. Use Box2D in ChaiScript...\n    ```c\n    // Define the gravity vector.\n    var gravity = b2Vec2(0.0f, -10.0f)\n\n    // Construct a world object, which will hold and simulate the rigid bodies.\n    var world = b2World(gravity)\n\n    // Define the ground body.\n    var groundBodyDef = b2BodyDef()\n    groundBodyDef.position.Set(0.0f, -10.0f)\n\n    // Call the body factory which allocates memory for the ground body\n    // from a pool and creates the ground box shape (also from a pool).\n    // The body is also added to the world.\n    var groundBody = world.CreateBody(groundBodyDef)\n\n    // Define the ground box shape.\n    var groundBox = b2PolygonShape()\n\n    // The extents are the half-widths of the box.\n    groundBox.SetAsBox(50.0f, 10.0f)\n\n    // Add the ground fixture to the ground body.\n    groundBody.CreateFixture(groundBox, 0.0f)\n\n    // Define the dynamic body. We set its position and call the body factory.\n    var bodyDef = b2BodyDef()\n    bodyDef.type = b2_dynamicBody\n    bodyDef.position.Set(0.0f, 4.0f)\n    var body = world.CreateBody(bodyDef)\n\n    // Define another box shape for our dynamic body.\n    var dynamicBox = b2PolygonShape()\n    dynamicBox.SetAsBox(1.0f, 1.0f)\n\n    // Define the dynamic body fixture.\n    var fixtureDef = b2FixtureDef()\n    //fixtureDef.shape = dynamicBox\n    SetShape(fixtureDef, dynamicBox)\n\n    // Set the box density to be non-zero, so it will be dynamic.\n    fixtureDef.density = 1.0f\n\n    // Override the default friction.\n    fixtureDef.friction = 0.3f\n\n    // Add the shape to the body.\n    body.CreateFixture(fixtureDef)\n\n    // Prepare for simulation. Typically we use a time step of 1/60 of a\n    // second (60Hz) and 10 iterations. This provides a high quality simulation\n    // in most game scenarios.\n    var timeStep = 1.0f / 60.0f\n    var velocityIterations = 6\n    var positionIterations = 2\n\n    // This is our little game loop.\n    for (var i = 0; i \u003c 60; ++i) {\n        // Instruct the world to perform a single step of simulation.\n        // It is generally best to keep the time step and iterations fixed.\n        world.Step(timeStep, velocityIterations, positionIterations)\n\n        // Now print the position and angle of the body.\n        var position = body.GetPosition()\n        var angle = body.GetAngle()\n\n        print(\"X: \" + to_string(position.x))\n        print(\"Y: \" + to_string(position.y))\n        print(\"A: \" + to_string(angle))\n    }\n    ```\n\n## Development\n\n```\ngit submodule update --init\nmkdir build\ncd build\ncmake ..\nmake\nmake test\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fchaiscript_extras_box2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobloach%2Fchaiscript_extras_box2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fchaiscript_extras_box2d/lists"}