Most of the bugs I found are unexpected and I don’t know how to prevent them in the first place other than doing the trial and errors method. For example with the new map, I have discovered a problem with collisions, when collisions are superimposed they do not trigger in the correct order, a collision under another is sometimes over. There is a problem with the order of insertions, and everything is put in a
For example with the new map, I have discovered a problem with collisions, when collisions are superimposed they do not trigger in the correct order, a collision under another is sometimes over. There is a problem with the order of insertions, and everything is put in a unordered_map, at first when I choose to have a map I was thinking in term of performance and if the container needs to be ordered lexicographically. Now it seems obvious a vector is a right container because the number of elements is small. For a large number of elements, I will need to have a map for lookup and a vector to keep track of insertions or if boost is used in the project have a boost::multi_index.
Another thing was the collisions of the items was only performed at the center of the item, in most cases this is fine but for something like this :

This is really annoying to visualize the center and it became difficult to trigger the collisions. The algorithm used to perform collision between one point and a polygon is : Point Inclusion in Polygon Test W. Randolph Franklin (WRF)
To have something more precise I detect collision between a convex polygon and convex polygon. For that, I need a collision library or at least another algorithm, the most used for doing polygon detection is the algorithm implementing the separating axis theorem.
It was time-consuming to found a working implementation of this theorem because most of the articles explain how the algorithm works but the implementation is mostly pseudocode. And libraries are most of the time too heavy, are not free for a commercial project or not adapted for collision detection but for simulating physics (box2d).
Here is a working version of SAT in C99 : Polygonal collision detection.
I have made a small demo to adapt the C99 version to C++ and avoid all the memory leaks with malloc.
CollisionDetection