Ich habe explosionen implementieren wollen:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// Überschneiden sich die Rects?
if (RectShot.y < RectAsteroid.y + RectAsteroid.h &&
RectShot.y + RectShot.h > RectAsteroid.y &&
RectShot.x < RectAsteroid.x + RectAsteroid.w &&
RectShot.x + RectShot.w > RectAsteroid.x)
{
// Ja, also gab es eine Kollision. Somit Schuss und
// Asteroid deaktivieren
g_pHighscore->Add(100);
ItAsteroid->SetAlive (false);
ItShot->SetAlive (false);
CExplosion Explosion(static_cast<float>(RectShot.x), static_cast<float>(RectShot.y + RectShot.w/2), m_pSpriteExplosion);
m_ExplosionList.push_back(Explosion);
}
|
falls es also ne kollision gibt spööte theoretisch ne explosion erzeugt werden und im update rufe ich immer noch
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
|
void CGame::ProcessExplosions()
{
list<CExplosion>::iterator ItExplosion;
for (ItExplosion = m_ExplosionList.begin(); ItExplosion != m_ExplosionList.end(); ItExplosion++)
{
ItExplosion->Process();
}
}
|
auf um die explosionen zu rendern und zwar so:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
|
void CExplosion::Process()
{
if(AnimPhase > 20)
this->~CExplosion();
m_pSpriteExplosion->Render(static_cast<float>(AnimPhase));
AnimPhase++;
}
|
Das alles kompiliert auch und läuft schön durch usw. allerdings hängt es sich auf, wenn eine explosion erzeugt wird