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; 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(); init();
} }
@@ -66,21 +76,15 @@ GameDirector::~GameDirector()
delete menuTitle; delete menuTitle;
for (Uint8 i = 0; i < mMaxBalloons; i++) for (Uint8 i = 0; i < mMaxBalloons; i++)
{
if (balloon[i])
{ {
delete balloon[i]; delete balloon[i];
} }
}
for (int i = 0; i < mMaxBullets; i++) for (int i = 0; i < mMaxBullets; i++)
{
if (bullet[i])
{ {
delete bullet[i]; delete bullet[i];
} }
} }
}
// Iniciador // Iniciador
void GameDirector::init() void GameDirector::init()
@@ -349,8 +353,7 @@ Uint8 GameDirector::getBallonFreeIndex()
// Crea un globo nuevo en el vector de globos // Crea un globo nuevo en el vector de globos
Uint8 GameDirector::createNewBalloon(int x, int y, Uint8 kind, float velx, Uint16 creationtimer) Uint8 GameDirector::createNewBalloon(int x, int y, Uint8 kind, float velx, Uint16 creationtimer)
{ {
Uint8 index = getBallonFreeIndex(); const Uint8 index = getBallonFreeIndex();
balloon[index] = new Balloon(gRenderer);
balloon[index]->init(x, y, kind, velx, creationtimer); balloon[index]->init(x, y, kind, velx, creationtimer);
return index; return index;
} }
@@ -532,7 +535,6 @@ void GameDirector::resetBullets()
void GameDirector::createBullet(int x, int y, Uint8 kind) void GameDirector::createBullet(int x, int y, Uint8 kind)
{ {
const int index = getBulletFreeIndex(); const int index = getBulletFreeIndex();
bullet[index] = new Bullet(gRenderer);
bullet[index]->init(x, y, kind); bullet[index]->init(x, y, kind);
} }

Binary file not shown.