Hello there!
This week has been doing a lot for the final, when I say a lot, I mean a lot. I have been creating stuff for the program all over to make the final as good as possible. However creating objects in the game also means that you have to make the infamous std::vector. A vector is just ”lockers” where you can save information, (I will not go in any further in to it.) Vectors have an exceptional ability to crash the program if you are not doing it right and not telling you where too look for the error, so you need to go through all and every one of your vector’s and check if any of them where wrong. Just even something as simple as ++ instead of — will make it crash, and it is so simple to miss anything that could crash.
Have I told you about the part where everything we do in our program is based on vectors? Why? Well its the simplest way of doing ANYTHING with multiple objects, so far as I know atleast. Since you need them to check hitboxes, you need them for updates, drawing and erasing memory leaks.
So how about we talk about memory leaks, I had previously thought of a way to delete objects that would be superb, I had a counter that counted up whenever something spawned it had a counter add one. This made it so I could draw everything and interact so I could do it in reverse, what this did for the game is so when two units would spawn the one thats closest to the bottom screen draws itself first.
Now I was thinking about the memory leaks I was thinking that it would erase things that was the oldest so it would not mess up anything else that was on the screen. This however was where my superb plan would go in to fail. Everytime the program checked for something to delete it would start to check at things that did not exsist making the game crash. So this is when i started to go crazy about the vector crashes so I did it so it would go the correct way instead of backwards and would you look at that, no more crashes! This was an incredible feeling having the program to erase objects and not crash! This made the game playable without mayjor lags.