Ya compila y no se cuelga

This commit is contained in:
2022-10-20 18:31:53 +02:00
parent e753f6fbdb
commit ca5adf9433
2 changed files with 14 additions and 12 deletions

View File

@@ -31,6 +31,16 @@ GameDirector::GameDirector(SDL_Renderer *gRenderer)
{
this->gRenderer = gRenderer;
for (Uint8 i = 0; i < mMaxBalloons; i++)
{
balloon[i] = new Balloon(gRenderer);
}
for (int i = 0; i < mMaxBullets; i++)
{
bullet[i] = new Bullet(gRenderer);
}
init();
}
@@ -67,18 +77,12 @@ GameDirector::~GameDirector()
for (Uint8 i = 0; i < mMaxBalloons; i++)
{
if (balloon[i])
{
delete balloon[i];
}
delete balloon[i];
}
for (int i = 0; i < mMaxBullets; i++)
{
if (bullet[i])
{
delete bullet[i];
}
delete bullet[i];
}
}
@@ -349,8 +353,7 @@ Uint8 GameDirector::getBallonFreeIndex()
// Crea un globo nuevo en el vector de globos
Uint8 GameDirector::createNewBalloon(int x, int y, Uint8 kind, float velx, Uint16 creationtimer)
{
Uint8 index = getBallonFreeIndex();
balloon[index] = new Balloon(gRenderer);
const Uint8 index = getBallonFreeIndex();
balloon[index]->init(x, y, kind, velx, creationtimer);
return index;
}
@@ -532,7 +535,6 @@ void GameDirector::resetBullets()
void GameDirector::createBullet(int x, int y, Uint8 kind)
{
const int index = getBulletFreeIndex();
bullet[index] = new Bullet(gRenderer);
bullet[index]->init(x, y, kind);
}