Try to make a game in c++

Project 18

Caracteristics

Description

For this project, I wanted to review the c++ language and deepen it, with all the knowledge that I have accumulated so far. My goal was just to test a game concept using the SDL library, a library I had already experimented in the RPG club in semester 1 at the IUT. For this project, I tested some techniques that I never implemented in my previous projects. I didn't directly link collisions to tiles, I got better performance and I could have collisions that are not necessarily rectangular. My first step in the project was to create the whole base for coding more efficiently and more quickly. As with every project : create a window manager, abstract window, overload the objects provided by SDL, to create textures, animations, animation groups. For the animations field, I added something interesting, the notion of hot spot. A notion that allows to make coherent animations while having frames of different sizes.

After putting these aspects in place, I coded the basis of a character. Then a camera, which is always centered on the player but which also adapts to the position of the mouse. Indeed, the goal is to make the player attack towards the direction of the mouse when he clicks. For the map collision system, I segmented it into an array of squares of size N, which indicates which collision boxes (not necessarily rectangular) to test with the player when he is in this square. This is just a way to optimize the speed of the game, not the memory used, to make polygonal collisions without having to test all the collisions on the map. Then I created collision boxes more complex than simple rectangles like rotated rectangles, since the collision box of the player's sword rotates around him when he attacks. It depends on the position of the mouse It took me a little time, but in the end the result was very pleasant and worked very well.

In addition to this project, I created a few enemies, and a whole inventory system, with three armor slots and two weapon slots. I've run into some problems. which I guess anyone who codes in C++ has to deal with. A circular dependency problem but where a part of the cycle is through inheritance between classes. I solved with difficulty this bug by adopting a way of designing the architecture that I didn't like. Then I had a memory problem, probably a crazy pointer, that I didn't know how to fix. Every time the program was launched, a random part of the code which behaved unpredictably. Most of the time, the behavior was the crash of the program, but I got more exotic behaviors like the character's life bar taking the speed value of the player. In short, a more than annoying bug.

To sum up, with this project, I saw that it is quite pleasant to code in C++. It's a language that allows a lot of things, it's a very optimized one but a language that is hard and challenging to debug.

Visuals (Click on one pick to enlarge it)

Game home. Player on the grass field. Cursor over an enemy.

Hey test test