BLOG WEEK 5 – Vector subscript out of range

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.Main menu2

BLOG WEEK 5 – Vector subscript out of range

En reaktion på ”BLOG WEEK 5 – Vector subscript out of range

  1. gabrielstoffelprogramming skriver:

    Hi Christoffer Forsberg  ,

    I totally like how you are explaining the way how you are implementing the hurricane into the code.
    I really like the style of the game and the idea behind.
    You wrote your post really good and there are no grammatical problems or something.
    Your explaining is very well written and easy to read and easy to understand. I just have one question about your post. Why did you do it that way you describe it? How did it go with the hitboxes and other stuff? Myself I am a new bee so information like that could be very useful for me and the rest of the new bees which are reading your blog post’s. Maybe just link a tutorial web side or a video from youtube or where ever you learned it.

    I am really happy that you made it and found that problem. Did you use some program to detect where you problem was leaking? You could just talk about it little bit more and give the readers tips how they could do it like you. Or give them tips how to do things like that.

    Hope you have fixed more player feedback, i like your project very much so keep up the good work guys.:D

    Gilla

Lämna en kommentar