Update 53

Still working on the level 3, adding mechanism, objects. I have also been practising drawing with a tablet a lot this week. I mostly draw on paper because making lines on a tablet is slow and not comfortable (on a small tablet bamboo) and painful after a while because you need to use wrist sometimes to be precise with small strokes. I need to make a lot of pauses to not overwork my hands. I have found that paint tool sai is better at making clean lines than photoshop. And there is a pencil brush that really look like drawing with a pencil compared to photoshop brush.


I need to do a lot of picture studies to have a “good” rendering with soft edges and proper colours. For the moment I am simply trying to get comfortable with a tablet with simple and fast drawing and rendering. The result is not refined and quite dirty with lots of errors but that okay I need to make a lot more small pieces to be fast. Making art with the tablet is quite time-consuming, so I try to limit myself because I have other things to do in the game.

Update 52

I am adding/removing things in the level 3, I feel there is not enough content but I already have a lot of objects, so I am trying to find new ways to use these objects. I have a lot of constraints such as not adding more maps and each puzzle must be logic, it can be complex (using different objects in a precise order on something). In the level, there is a goal and everything the player is doing is reaching this goal to progress into the game. The goal allows the player to know more about the plot. Since I have a lot of things in the inventory I am adding obstacle (things on maps you can’t pick but need to remove). In the level 3, there is no character so I don’t have to change dialogs. Adding more content without diluting the story is important, every objects and dialog are useful in the game I am not adding random content without impact just to have a context or things that are purely a waste of time.


There is little hints in the game and dialogs give plot element or object but no hints, that’s why I am making the combination of objects very logic so that the player know he can think before trying every object in the inventory. When there are multiple good solutions I can add dialogs to discard the possibility, but when the player do stupid associations I don’t add random dialogs to mock the player like many other point and clicks does. Because the first thing that it does is wasting time and create a delay between interactions. That’s why I think this game will be fast to finish because there is no delay between interaction and loading, even the speed of the text can have no delay. There is a lot of experimentations, combinations but it doesn’t feel painful to do since it takes very little time.

Update 51

I am trying now to clean and optimise the engine since most of the things are implemented. For example, a long time before when I was using SFML and a lot of bugs were not fixed I was not able to use stack allocations for the dialogues and the actions. But now I can to the many bugs and memory leaks I have fixed. But having thing stack allocated complexify things because each time they are created and destroyed so I have moved the destructor into a free method to only free the object when needed. Before I was able to check is the object was allocated simply with if(object != NULL)  {…} because with dynamic allocation you have a pointer to the object. Now I have a variable bool allocated which I set to true if the object is allocated (most of the time allocated == resources loaded).

When do you use stack allocation ? In games, most of the times the things to optimise are the loading times between levels, so for a point and click there is not much memory needed so I can have every allocation in the game loop stack allocated. The only time when I utilise dynamic allocation is when the game start, and I need to create big objects such as Game and FileManager. For texture, I use SDL_gpu wich rely on stb_image and SDL to load the images so every allocation is masked, and for sound Almixer it uses OpenAL. Each of these libraries uses dynamic allocation (malloc) for the loading/decoding of files. Now the loading times are faster than before and the navigation between maps is more fluid.

I have also found other small bugs with the audio, where I was using a thread inside another thread of Almixer because the library was compiled with the thread option…

After fixing so many things I think I am at a point when the engine is stable, but each time I find something else to change and after that, I have a lot of small bugs in the game to fix because things are not performed in the same order.

I have also finished most of the level 2 so now it’s time to fix and polish the big levels 3 and 4.

Update 50


On this animation taken from the game, you can see the frame rate in red and the green squares are the collisions (quite useful for debugging).

Here is the door animation for the second level, the movement is not very smooth because there are only 5 images for the animation. Can’t you use more than five images? Will it be smoother with 10 images? Yes with 10 images it will be good, but there is a price : VRAM space and loading time.  For 5 images I need to use two 2048*2048 textures so with 10 Image I need to use four 2048*2048 textures, the first texture can only contain 2 images because the static part of the map is also stored. 4*2048*2048 = 4096*4096 texture just for one map which is quite big for an animation. You can also see I have put the door on the left side of the map and not in the center for a reason.



This explains why in 2 games most of the animations are small because if the character or the object is 100*100 pixels you can put 20*20 = 400 images in 2048*2048 textures so you can have an animation for every attack something like that:


For  big animations, you can use a video but again the price just for 2 or 3 seconds of animation is expensive in term of loading time. Even with all the progress made in computer science, there is still limits because the memory is still finite. And if you use a resolution large enough you can fill up the memory pretty quickly, even with one animation!

Update 49

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.