{"id":21252671,"url":"https://github.com/atomicptr/bunraku","last_synced_at":"2025-06-21T04:07:33.841Z","repository":{"id":255638006,"uuid":"851721100","full_name":"atomicptr/bunraku","owner":"atomicptr","description":"A header only 2D animation library for making games with C++23","archived":false,"fork":false,"pushed_at":"2025-02-16T13:32:45.000Z","size":291,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T15:03:25.537Z","etag":null,"topics":["animation","animation-library","cpp","cpp23","fsm","game-development","header-only","header-only-library","raylib"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomicptr.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":"2024-09-03T15:45:38.000Z","updated_at":"2025-02-16T13:32:48.000Z","dependencies_parsed_at":"2024-09-06T12:48:13.480Z","dependency_job_id":"b2e21dea-5ed0-4d96-8545-f8a6bc828845","html_url":"https://github.com/atomicptr/bunraku","commit_stats":null,"previous_names":["atomicptr/bunraku"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atomicptr/bunraku","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fbunraku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fbunraku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fbunraku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fbunraku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicptr","download_url":"https://codeload.github.com/atomicptr/bunraku/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fbunraku/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261060134,"owners_count":23103985,"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":["animation","animation-library","cpp","cpp23","fsm","game-development","header-only","header-only-library","raylib"],"created_at":"2024-11-21T03:48:24.436Z","updated_at":"2025-06-21T04:07:28.825Z","avatar_url":"https://github.com/atomicptr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bunraku (文楽)\n\nA header only 2D animation library for making games with C++23\n\nInspired by the LÖVE library [anim8](https://github.com/kikito/anim8) and the Odin library [anima](https://github.com/atomicptr/anima).\n\n## Compatibility\n\nThis library is implemented to be renderer agnostic, however there is a raylib implementation available in src/bunraku\\_raylib.hpp/cpp.\n\n## Installation\n\nCopy the files into your project :)\n\n## Usage\n\nCheck out one of the examples:\n\n- [anim8 1945 example](./examples/anim8_1945/src/main.cpp) (port of the anim8 demo)\n- [cat fighter fsm](./examples/cat_fighter_fsm/src/main.cpp) - Animations with a finite state machine\n\n### Simple example\n\n```cpp\n#include \u003craylib.h\u003e\n#include \u003cbunraku/bunraku.hpp\u003e\n#include \u003cbunraku/bunraku_raylib.hpp\u003e\n\nint main() {\n    InitWindow(800, 600, \"Simple Example\");\n    SetTargetFPS(60);\n\n    auto image = LoadImage(\"path/to/image.png\");\n    auto texture = LoadTextureFromImage(image);\n    UnloadImage(image);\n\n    // first we need to define our grid\n    auto grid = bunraku::Grid{32, 32};\n\n    auto animation = bunraku::Animation{\n        // here we specify we want column: 0-7 in row: 0\n        grid.frames(\"0-7\", 0),\n        // and the animation speed is 0.1s\n        0.1f\n    };\n\n    while (!WhileWindowShouldClose()) {\n        auto dt = GetFrameTime();\n\n        // update the animation before drawing\n        animation.update(dt);\n\n        BeginDrawing();\n        ClearBackground(RAYWHITE);\n\n        // and finally draw the animation\n        bunraku::raylib::draw(animation, texture, 100, 100);\n\n        EndDrawing();\n    }\n\n    UnloadTexture(texture);\n    WindowClose();\n\n    return 0;\n}\n```\n\n## Documentation\n\n### Grids\n\nGrids exist to make it as easy as possible to quickly define animations using rectangles of teh same size.\n\nGrids are defined like this:\n\n```cpp\n\nbunraku::Grid(\n    int frame_width,  // the width of the frame\n    int frame_height, // the height of the frame\n    int left = 0,     // (optional) starting x position of our grid, this is used to define multiple grids within a single file\n    int top = 0,      // (optional) starting y position of our grid, this is used to define multiple grids within a single file \n    int border = 0    // (optional) this allows you to define gaps between images\n);\n\n```\n\n![](./.github/images/grid_example.png)\n(Took this explanation from the anim8 repo)\n\nTo get frames from a grid you need to call the ``Grid::frames`` function\n\n```cpp\n\nauto grid = bunraku::Grid{32, 32};\n\ngrid.frames(\n    column_interval_range_0, // the defined column range of our animation\n    row_interval_range_0,    // the defined row range of our animation\n    column_interval_range_1, // the defined column range of our animation\n    row_interval_range_1,    // the defined row range of our animation\n    column_interval_range_2, // the defined column range of our animation\n    row_interval_range_2,    // the defined row range of our animation\n    // ...\n);\n\n```\n\n### Animations\n\nAnimations are a group of frames that change after a set duration\n\n```cpp\n\nbunraku::Animation(\n    std::vector\u003cFrameRect\u003e frames,               // the frames to play, this should be supplied using grids\n    float duration,                              // the duration each frame will take until the next one will play\n    bool playing = true,                         // (optional) is the animation playing? Default is true\n    bool oneshot = false,                        // (optional) should the animation only play once? Default is false\n    bool flip_h = false,                         // (optional) flip horizontally\n    bool flip_v = false,                         // (optional) flip vertically\n    std::optional\u003cOnFinishedFn\u003e on_finished = {} // (optional) a callback that will be called every time the current animation has finished\n);\n\n```\n\n## Assets\n\n- examples/anim8_1945/assets/1945.png - [Widgetworx Spritelib](http://www.widgetworx.com/widgetworx/portfolio/spritelib.html)\n- examples/cat_fighter_fsm/assets/cat_fighter.png - [dogchicken from opengameart.org](https://opengameart.org/content/cat-fighter-sprite-sheet)\n\n\n## License\n\nBSD 0-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fbunraku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicptr%2Fbunraku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fbunraku/lists"}