For those who have an allergy to global variables don't worry it is just for testing :P.

So, now before starting the engine, it is possible to change some engine states by using functions like bkp_set*(); here they are commented.

When the engine starts it will set up my memory pools. Those are a number of memory stacks of a different size. Every time I require some memory it will give me a "ticket" (pointer of size N) popped from stack #n. All allocations are made at the first time an object of size N is required. For example, if I want 64bytes and the pool is empty it will malloc(64 * default_number_of_object) then later I will just need to pop the ticket or push it back. There is no garbage collector but memory leaks are detected and logged.

PRO: the number of calls to malloc is very low or at least computable before a game starts.

CON: the default values may waste memory. However, using bkp_set_memory*() allows changing the parameter for pools of the same memory. Anyway, I will need to make statistics for each game to calculate how to set up the memory manager.

This line shows how to ask a ticket (pop a block). I can show the details of the memory manager if asked.

Next is the text-engine (if I can call it like this), it is still temporary as I am still a beginner with freetype and I am not sure I will continue with it at the moment, I used it because I want a result and don't want to reinvent the wheel. The function to draw is the following, it needs a font loaded by bkp_graphics_newFont (not sure if I want to separate Text module and Graphics module yet)

In the previous code you don't see any calls of that function because I use an OnscreenTextBuffer, it is a buffer of linked lists where each node contains everything to draw a text on screen such as Text, Position, Scale, Color. Any text can be added to buffer with the following:

Here a pointer to the buffer entry is returned to "fps", so you guess for which purpose. 64 is the size in bytes of the text length. Once set, the size cannot change but the content can be changed, for example, like this:

The last thing I did was scrolling. I didn't do anything fancy or special here, just adding a VIEW matrix in the shader. Every time I move the view portbkp_graphics_2dscroll(G[0]->dyn.gbox); in the GPU otherwise it keeps its values. It is a single function that takes as a parameter a rectangle to focus on. In the following example, the center of the player's bounding box is used as the point of focus:

bkp_graphics_2dscroll(G[0]->dyn.gbox);

Something I didn't show here is that is possible so set an autoscroll by just giving a default x/y speed to the scroller once again with a function like bkp_set*().

If I comment one of the bkp_memory_releaseTichet() lines at the end we get this in the log file or/and screen:

The memory leak is detected in the Pool number 4 (320 bytes/ticket) unfortunately I do not provide a way to find exactly where it is. However, it is already a good hint to find it.

Now a small video to show everything. I made the character bounce to show clearly all platforms' properties.

What will come next?

So far in my learning process I start to go away from my main goal, indeed if this demo shows a Mario like a game, it is not at all what I am making but some features I needed are now present. As an example, the double jump will not be in my game but I implemented it. It is time to pause the game engine development and go to game dev. Next step should be creating the main character and his/her basic movements.

I spend a lot of time separating tasks, making the project ready to receive other contributors. That's why I am creating and documenting all the functions.

I also have an artist now, not official yet but... Anyway, my experience made me suspicious.

Something I have to recognize I am bad at is levelling. I needed such a long time to pass all basic levels of Soul of Mask, this game is difficult and the difficulty doesn't come crescendo, it is too sudden. I didn't even finish the last level, it looks impossible for me.

And as always thanks for reading.

Until next time

ps: I am thinking about making the game engine open-source, for those who read it please tell me in the comment what you think about that Idea.