{"id":20466758,"url":"https://github.com/tastyep/hitboxbuilder-2d","last_synced_at":"2025-04-13T09:10:42.922Z","repository":{"id":78788825,"uuid":"96015549","full_name":"Tastyep/HitboxBuilder-2D","owner":"Tastyep","description":"Building hitboxes has never been easier","archived":false,"fork":false,"pushed_at":"2018-06-10T19:38:45.000Z","size":1070,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T00:54:11.632Z","etag":null,"topics":["c-plus-plus","collision","douglas-peucker","ear-clipping","game-2d","game-development","hitboxes","marching-squares","triangulation"],"latest_commit_sha":null,"homepage":"","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/Tastyep.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":"2017-07-02T10:12:42.000Z","updated_at":"2024-11-19T14:30:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"46f332b5-6399-4f6f-ae42-a33062f4c366","html_url":"https://github.com/Tastyep/HitboxBuilder-2D","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tastyep%2FHitboxBuilder-2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tastyep%2FHitboxBuilder-2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tastyep%2FHitboxBuilder-2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tastyep%2FHitboxBuilder-2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tastyep","download_url":"https://codeload.github.com/Tastyep/HitboxBuilder-2D/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688565,"owners_count":21145766,"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":["c-plus-plus","collision","douglas-peucker","ear-clipping","game-2d","game-development","hitboxes","marching-squares","triangulation"],"created_at":"2024-11-15T13:25:23.027Z","updated_at":"2025-04-13T09:10:42.915Z","avatar_url":"https://github.com/Tastyep.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/title.png\"  alt=\"logo\"\u003e\n\u003c/div\u003e\n\n\n## Introduction\nHitbox Builder is a lightweight C++ library aiming to automatizing the process of generating hitboxes composed by only convex polygons.\n\nIt was originally designed for 2D games, but it could also serve different purposes.\n\n## License\nHitbox Builder is distributed under the [MIT License](https://raw.githubusercontent.com/Tastyep/SFML-HitboxBuilder-2D/develop/LICENSE)\n\n## Requirements\n- [SFML](https://www.sfml-dev.org/)\n- [CMake](https://github.com/Kitware/CMake)\n- [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/)\n\n## Features\n- Contour detection ([Marching squares](https://en.wikipedia.org/wiki/Marching_squares))\n- Contour simplification ([Douglas–Peucker](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm))\n- Polygon triangulation ([Ear clipping](https://en.wikipedia.org/wiki/Two_ears_theorem))\n- Polygon partitioning (Hertel-Mehlhorn)\n\nBelow is a representation of each stage of transformation of the data.\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/banner.png\"  alt=\"logo\"\u003e\n\u003c/div\u003e\n\n## Usage\n\n```C++\n// Initialize the builder.\nHitboxBuilder::init();\n\n// Create a hitbox for the given sprite with an accuracy of 70%.\nconst auto hitbox = HitboxBuilder::make(sprite, 70, false);\n\nconst auto\u0026 convexPolygons = hitbox.body();\nconst auto\u0026 boundingBox = hitbox.bound();\n\n// Use these data as you like.\n```\n\n## Demos\n\nTo run the demos, execute the configure script with the option '-t'.\n\nExecute the target HitboxBuilder-tester located in the build directory.\n\nSome test bed commands are:\n- \u003ckbd\u003e←\u003c/kbd\u003e \u003ckbd\u003e→\u003c/kbd\u003e keys to slide between the images.\n- \u003ckbd\u003e↑\u003c/kbd\u003e \u003ckbd\u003e↓\u003c/kbd\u003e keys to increase/decrease the accuracy of the\nalgorithm.\n- \u003ckbd\u003eSpace\u003c/kbd\u003e key to toggle the display of the sprite.\n\nYou can load your own images by adding them to the TestBed/assets/ directory. You will just need to restart the program as they are loaded at the beginning.\n\n##### Output:\n\n Input                   | Output\n:-----------------------:|:-------------------------:\n![silhouette](https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/input.png) | ![Accuracy gif](https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/accuracy.gif)\n **Accuracy = 100**           |  **Accuracy = 66**\n![Italy 100](https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/italy-100.png) | ![Italy 66](https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/italy-66.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftastyep%2Fhitboxbuilder-2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftastyep%2Fhitboxbuilder-2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftastyep%2Fhitboxbuilder-2d/lists"}