I think I am getting to grips with it, but at the moment, I am trying to practice writing the code from notes. I've got the code to run, with a few errors which I've managed to fix.
The part which is bugging me at the moment is when I debug the code and the program runs, the particles spray into which ever direction and when I close the window, a dialog box appears which says:
Debug Assertion Failed!
Program: ... [insert directory path]
File:c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector
Line 932
Expression: vector subscript out of range
[/quote]
Now when I had a look at the code that came on the CD, there was a part of the code which was trying to erase an object pointer of the Emitter class, but using the standard vector library. Now, I am guessing you can't call std::vector functions and erase the elements if it isn't of type std::vector.
Here is the code that is trying to remove the emitters:
void ParticleManager::removeEmitter(int emitterNum)
{
iterateEmitter(emitter[emitterNum]);
}
void ParticleManager::iterateEmitter(Emitter* which)
{
// emitter.erase(&which);
std::vector <Emitter*>::iterator Iter;
for(Iter = emitter.begin(); Iter != emitter.end(); Iter++)
{
if(*Iter != which)
{
emitter.erase(Iter);
break;
}
}
}
The emitter object is of type std::vector. It's the part of the code that's commented. If I use that which was in the provided code, will have a red mark underneath the dot and the last bracket. I am just stuck at what to do, I don't think I have found a good book that really explains how the std::vector works, so this is most likely why I have run into problems like this because I've not learnt it in detail...