Dear fellow programmers,
I am struggling quite a bit with this small snippet of code. The only
thing missing is the iteration through the lists, but this part is not
as simple as it seems.
They lists are std::vector<CObject*>, the iterators fit and eit are
std::vector<CObject*>::iterators, which should be irrelevant though.
...
fit = m_Friend.begin();
while (fit != m_Friend.end())
{
eit = m_Enemy.begin();
while (eit != m_Enemy.end())
{
if ((*fit)->TestCollisionWith(*eit))
{
(*fit)->CollideWith(*eit);
(*eit)->CollideWith(*fit);
if ((*eit)->IsDead())
{
m_Kill.push_back(*eit);
eit = m_Enemy.erase(eit);
}
if ((*fit)->IsDead())
{
m_Kill.push_back(*fit);
fit = m_Friend.erase(fit);
eit = m_Enemy.begin();
}
}
// conditional incrementation of eit
}
// conditional incrementation of fit
}
...
Anyone got a bright thought on this issue? I'm curious to hear your
ideas !
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]