Unexpected help

Today was a…productive day, more that i would have thought when rolling out of bet at 10AM.

Me and Martin met up in the Game room where we both worked on the last things we wanted to put in the game. I worked on getting the sprites in the game and as it turned out the sprites were drawing but at the top left corner due to me making the collider of the Particle’s Gameobject a nullpointer when declaring it.  Once that issue was resolved i went on to adding a second “splatter”  (I sort of wish i hadn’t named the particle object SplatterObject) that would appear when clicking on the screen and we went on to work in the classroom during the afternoon. Before making the firework i started on getting the particles to disappear after a set amount of time. When i got stuck i went on to implement the mouse and the firework while waiting for help and after some fiddling i managed to get it in. Now the only issue i was having was the particles not disappearing causing massive memory leaks. I didn’t have time to finish it as i had to catch the buss home so we decided to continue our work at home. At home i went on to try to get the particles to disappear. It took me all night since i didn’t really know how to remove objects properly, i ended up making the particles in a separate list in the Gameobject manager class. This caused me to have to change several parts of the gamestate code which used a method referring to the original list. I also made a timer for measuring the time since the last batch of particles were created and then the toughest challenge of all, removing them properly. After several hours of reading the platformer code and experimenting i was still unable to get the list emptied and the values removed properly. That’s when i got help from an unexpected place. 

Earlier during the afternoon i was contacted by one of my friends on steam, i told him i was working and set my status to busy, nothing more about it. Later when i was stuck on the removal he sent me another message asking why i was still so busy. I jokingly asked him: “Tell me how to empty a std::vector<> without causing unhandled exceptions the next time you call it.” assuming he would have no idea what i was talking about. A few minutes later he starts posting pieces of code in the steal chat. At first i assumed he was making things up but then i looked closer at the code and saw it was remarkably similar to my own. I also noticed that that code was using a v.clear() function i didn’t know about and after finding the right spot to put it in the code worked perfectly! 

void GameObjectMan::CleanupParticles(){
  std::vector<GameObject*>::iterator it = m_cvPobjs.begin();
  while (it != m_cvPobjs.end()){
    delete *it;
    *it = nullptr;
  it++;
  }
  m_cvPobjs.clear();

}

The funny thing was, he had just googled something and started posting pieces of code he found. He didn’t actually know anything about programming. I’m not sure what i should take from this experience… maybe to not refuse advice just because it’s coming from someone who knows less that you. 

In any case, the last features of the game are added and tomorrow we will sync our versions and go through them a final time to remove data leaks and unnecessary code. Then it’s on to write the reports. I think we’ll have this done in time after all. Wonderful.

 

 

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a comment