Skip to content

Commit

Permalink
master #comment Rework the README in preparation for the release.
Browse files Browse the repository at this point in the history
 - Add usage section.
 - Rework the assets, add images for the testbed section.
 - Complete references to algorithms.
  • Loading branch information
Luc Sinet committed Jun 10, 2018
1 parent e546ccb commit ab86816
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div align="center">
<img src="https://raw.githubusercontent.com/Tastyep/SFML-HitboxBuilder-2D/develop/assets/images/title.png" alt="logo">
<img src="https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/title.png" alt="logo">
</div>


## Introduction
Hitbox Builder is a lightweight C++ library aiming to automatizing the process of generating hitboxes.
Hitbox Builder is a lightweight C++ library aiming to automatizing the process of generating hitboxes composed by only convex polygons.

It was originally designed for 2D games, but it could also serve different purposes.

Expand All @@ -17,15 +17,32 @@ Hitbox Builder is distributed under the [MIT License](https://raw.githubusercont
- [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/)

## Features
- Contour detection
- Polygon builder
- Contour detection ([Marching squares](https://en.wikipedia.org/wiki/Marching_squares))
- Contour simplification ([Douglas–Peucker](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm))
- Polygon triangulation ([Ear clipping](https://en.wikipedia.org/wiki/Two_ears_theorem))
- Polygon partitioning (Hertel-Mehlhorn)

Below is a representation of each stage of transformation of the data.

<div align="center">
<img src="https://raw.githubusercontent.com/Tastyep/SFML-HitboxBuilder-2D/develop/assets/images/banner.png" alt="logo">
<img src="https://raw.githubusercontent.com/Tastyep/HitboxBuilder-2D/master/assets/images/banner.png" alt="logo">
</div>

## Usage

```C++
// Initialize the builder.
HitboxBuilder::init();

// Create a hitbox for the given sprite with an accuracy of 70%.
const auto hitbox = HitboxBuilder::make(sprite, 70, false);

const auto& convexPolygons = hitbox.body();
const auto& boundingBox = hitbox.bound();

// Use these data as you like.
```

## Demos

To run the demos, execute the configure script with the option '-t'.
Expand All @@ -34,6 +51,16 @@ Execute the target HitboxBuilder-tester located in the build directory.

Some test bed commands are:
- <kbd>←</kbd> <kbd>→</kbd> keys to slide between the images.
- <kbd>↑</kbd> <kbd>↓</kbd> keys to increase/decrease the accuracy of the algorithm.
- <kbd>↑</kbd> <kbd>↓</kbd> keys to increase/decrease the accuracy of the
algorithm.
- <kbd>Space</kbd> key to toggle the display of the sprite.

You 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.

##### Output:

Input | Output
:-----------------------:|:-------------------------:
![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)
**Accuracy = 100** | **Accuracy = 66**
![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)

0 comments on commit ab86816

Please sign in to comment.