fixing bugs

This commit is contained in:
2021-08-28 18:26:45 +02:00
parent 946ab62c30
commit 914b9e4123
9 changed files with 68 additions and 56 deletions

View File

@@ -269,6 +269,7 @@ const int MULTIPLIER_NUMBER_Y = SCREEN_HEIGHT - (2 * BLOCK) + 2;
// PowerBall // PowerBall
#define POWERBALL_SCREENPOWER_MINIMUM 10 #define POWERBALL_SCREENPOWER_MINIMUM 10
#define POWERBALL_COUNTER 8
// Tipos de bala // Tipos de bala
#define BULLET_UP 1 #define BULLET_UP 1

View File

@@ -89,6 +89,7 @@ Game::~Game()
mRenderer = nullptr; mRenderer = nullptr;
mFileList = nullptr; mFileList = nullptr;
mLang = nullptr;
mInput[0] = nullptr; mInput[0] = nullptr;
mInput[1] = nullptr; mInput[1] = nullptr;
@@ -289,7 +290,6 @@ void Game::init()
mSection.subsection = GAME_SECTION_PLAY_1P; mSection.subsection = GAME_SECTION_PLAY_1P;
mMenaceCurrent = 0; mMenaceCurrent = 0;
mMenaceThreshold = 0; mMenaceThreshold = 0;
//mHiScore = 0;
mHiScoreAchieved = false; mHiScoreAchieved = false;
mCurrentStage = 0; mCurrentStage = 0;
mStageBitmapCounter = STAGE_COUNTER; mStageBitmapCounter = STAGE_COUNTER;
@@ -318,6 +318,7 @@ void Game::init()
mHelper.itemCoffeeOdds = ITEM_COFFEE_ODDS; mHelper.itemCoffeeOdds = ITEM_COFFEE_ODDS;
mHelper.itemCoffeeMachineOdds = ITEM_COFFEE_MACHINE_ODDS; mHelper.itemCoffeeMachineOdds = ITEM_COFFEE_MACHINE_ODDS;
mPowerBallEnabled = false; mPowerBallEnabled = false;
mPowerBallCounter = 0;
mCoffeeMachineEnabled = false; mCoffeeMachineEnabled = false;
mPostFade = 0; mPostFade = 0;
@@ -354,11 +355,6 @@ void Game::init()
// Iniciualiza el objeto para el fundido // Iniciualiza el objeto para el fundido
mFade->init(0x27, 0x27, 0x36); mFade->init(0x27, 0x27, 0x36);
// Inicializa los objetos de texto
//mText->init();
//mTextScoreBoard->init();
//mTextBig->init();
// Inicializa el objeto con el menu de pausa // Inicializa el objeto con el menu de pausa
mMenuPause->init("PAUSE", 0, 12 * BLOCK, MENU_BACKGROUND_SOLID); mMenuPause->init("PAUSE", 0, 12 * BLOCK, MENU_BACKGROUND_SOLID);
mMenuPause->addItem(mLang->getText(46)); mMenuPause->addItem(mLang->getText(46));
@@ -1444,16 +1440,16 @@ void Game::deployEnemyFormation()
} }
else else
{ {
// Decrementa el contador de despliegues enemigos de la PowerBall
mPowerBallCounter > 0 ? mPowerBallCounter-- : mPowerBallCounter = 0;
// Elige una formación enemiga la azar // Elige una formación enemiga la azar
Uint8 set = (rand() % 10); Uint8 set = (rand() % 10);
// Evita repetir la ultima formación enemiga desplegada // Evita repetir la ultima formación enemiga desplegada
if (set == mLastEnemyDeploy) if (set == mLastEnemyDeploy)
{ ++set %= 10;
set++;
set %= 10;
}
mLastEnemyDeploy = set; mLastEnemyDeploy = set;
if (mDebug.enabled) if (mDebug.enabled)
@@ -1850,6 +1846,7 @@ void Game::createPowerBall()
mBalloon[getBalloonFreeIndex()]->init(posX, posY, POWER_BALL, BALLOON_VELX_POSITIVE * (((rand() % 2) * 2) - 1), mEnemySpeed, 100, mTextureBalloon, mRenderer); mBalloon[getBalloonFreeIndex()]->init(posX, posY, POWER_BALL, BALLOON_VELX_POSITIVE * (((rand() % 2) * 2) - 1), mEnemySpeed, 100, mTextureBalloon, mRenderer);
mPowerBallEnabled = true; mPowerBallEnabled = true;
mPowerBallCounter = POWERBALL_COUNTER;
} }
// Establece a cero todos los valores del vector de objetos globo // Establece a cero todos los valores del vector de objetos globo
@@ -2245,12 +2242,15 @@ void Game::createBullet(int x, int y, Uint8 kind, bool poweredUp, int owner)
void Game::updateItems() void Game::updateItems()
{ {
for (int i = 0; i < MAX_ITEMS; i++) for (int i = 0; i < MAX_ITEMS; i++)
if (mItem[i]->update() == 1) {
mItem[i]->update();
if (mItem[i]->floorCollision())
{ {
JA_PlaySound(mSoundCollision); JA_PlaySound(mSoundCollision);
mEffect.shake = true; mEffect.shake = true;
} }
} }
}
// Pinta los items activos // Pinta los items activos
void Game::renderItems() void Game::renderItems()
@@ -3317,7 +3317,7 @@ void Game::renderDebugInfo()
// Indica si se puede crear una powerball // Indica si se puede crear una powerball
bool Game::canPowerBallBeCreated() bool Game::canPowerBallBeCreated()
{ {
if ((!mPowerBallEnabled) && (calculateScreenPower() > POWERBALL_SCREENPOWER_MINIMUM)) if ((!mPowerBallEnabled) && (calculateScreenPower() > POWERBALL_SCREENPOWER_MINIMUM) && (mPowerBallCounter == 0))
return true; return true;
else else
return false; return false;

View File

@@ -182,6 +182,7 @@ private:
effect_t mEffect; // Variable para gestionar los efectos visuales effect_t mEffect; // Variable para gestionar los efectos visuales
helper_t mHelper; // Variable para gestionar las ayudas helper_t mHelper; // Variable para gestionar las ayudas
bool mPowerBallEnabled; // Indica si hay una powerball ya activa bool mPowerBallEnabled; // Indica si hay una powerball ya activa
Uint8 mPowerBallCounter; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra
bool mCoffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego bool mCoffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego
Uint8 mPostFade; // Qué hacer al acabar el fade Uint8 mPostFade; // Qué hacer al acabar el fade
float mSin[360]; // Vector con los valores del seno para 360 grados float mSin[360]; // Vector con los valores del seno para 360 grados

View File

@@ -73,7 +73,6 @@ void Instructions::init()
mSprite->init(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, mItemTexture, mRenderer); mSprite->init(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, mItemTexture, mRenderer);
mTicks = 0; mTicks = 0;
mTicksSpeed = 15; mTicksSpeed = 15;
//mText->init();
mManualQuit = false; mManualQuit = false;
mCounter = 0; mCounter = 0;
} }

View File

@@ -30,7 +30,7 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
mVelY = -4.0f; mVelY = -4.0f;
mAccelX = 0.0f; mAccelX = 0.0f;
mAccelY = 0.2f; mAccelY = 0.2f;
mStatus = 0; mFloorCollision = false;
mCollider.r = mWidth / 2; mCollider.r = mWidth / 2;
shiftColliders(); shiftColliders();
@@ -149,7 +149,7 @@ void Item::render()
// Actualiza la posición y estados del objeto // Actualiza la posición y estados del objeto
void Item::move() void Item::move()
{ {
mStatus = 0; mFloorCollision = false;
// Calcula la nueva posición // Calcula la nueva posición
mPosX += mVelX; mPosX += mVelX;
@@ -169,15 +169,15 @@ void Item::move()
mVelX = -mVelX; mVelX = -mVelX;
} }
// Si se sale por arriba // Si se sale por arriba rebota (excepto la maquina de café)
//if (mPosY < PLAY_AREA_TOP) if ((mPosY < PLAY_AREA_TOP) && !(mClass == ITEM_COFFEE_MACHINE))
//{ {
// // Corrige // Corrige
// mPosY = PLAY_AREA_TOP; mPosY = PLAY_AREA_TOP;
//
// // Invierte el sentido // Invierte el sentido
// mVelY = -mVelY; mVelY = -mVelY;
//} }
// Si el objeto se sale por la parte inferior // Si el objeto se sale por la parte inferior
if (mPosY + mHeight > PLAY_AREA_BOTTOM) if (mPosY + mHeight > PLAY_AREA_BOTTOM)
@@ -192,7 +192,7 @@ void Item::move()
mAccelY = 0; mAccelY = 0;
mPosY = PLAY_AREA_BOTTOM - mHeight; mPosY = PLAY_AREA_BOTTOM - mHeight;
if (mClass == ITEM_COFFEE_MACHINE) if (mClass == ITEM_COFFEE_MACHINE)
mStatus = 1; mFloorCollision = true;
} }
// Actualiza la posición del sprite // Actualiza la posición del sprite
@@ -207,7 +207,7 @@ void Item::erase()
} }
// Actualiza el objeto a su posicion, animación y controla los contadores // Actualiza el objeto a su posicion, animación y controla los contadores
int Item::update() void Item::update()
{ {
if (mEnabled) if (mEnabled)
{ {
@@ -217,8 +217,6 @@ int Item::update()
updateTimeToLive(); updateTimeToLive();
checkTimeToLive(); checkTimeToLive();
} }
return mStatus;
} }
// Actualiza el contador // Actualiza el contador
@@ -291,3 +289,9 @@ void Item::shiftColliders()
mCollider.x = int(mPosX + mCollider.r); mCollider.x = int(mPosX + mCollider.r);
mCollider.y = int(mPosY + mCollider.r); mCollider.y = int(mPosY + mCollider.r);
} }
// Informa si el objeto ha colisionado con el suelo
bool Item::floorCollision()
{
return mFloorCollision;
}

View File

@@ -18,7 +18,7 @@ private:
float mVelY; // Velocidad en el eje Y float mVelY; // Velocidad en el eje Y
float mAccelX; // Aceleración en el eje X float mAccelX; // Aceleración en el eje X
float mAccelY; // Aceleración en el eje Y float mAccelY; // Aceleración en el eje Y
int mStatus; // Contiene mensajes de estado bool mFloorCollision; // Indica si el objeto colisiona con el suelo
AnimatedSprite *mSprite; // Sprite con los graficos del objeto AnimatedSprite *mSprite; // Sprite con los graficos del objeto
@@ -52,7 +52,7 @@ public:
void erase(); void erase();
// Actualiza al objeto a su posicion, animación y controla los contadores // Actualiza al objeto a su posicion, animación y controla los contadores
int update(); void update();
// Actualiza el contador // Actualiza el contador
void updateTimeToLive(); void updateTimeToLive();
@@ -86,6 +86,9 @@ public:
// Temporizador con el tiempo que el objeto está presente // Temporizador con el tiempo que el objeto está presente
Uint16 mTimeToLive; Uint16 mTimeToLive;
// Informa si el objeto ha colisionado con el suelo
bool floorCollision();
}; };
#endif #endif

View File

@@ -41,6 +41,13 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::stri
// Destructor // Destructor
Title::~Title() Title::~Title()
{ {
mWindow = nullptr;
mRenderer = nullptr;
mInput = nullptr;
mFileList = nullptr;
mOptions = nullptr;
mLang = nullptr;
delete mEventHandler; delete mEventHandler;
mEventHandler = nullptr; mEventHandler = nullptr;
@@ -50,9 +57,6 @@ Title::~Title()
delete mText2; delete mText2;
mText2 = nullptr; mText2 = nullptr;
delete mLang;
mLang = nullptr;
delete mFade; delete mFade;
mFade = nullptr; mFade = nullptr;
@@ -129,8 +133,6 @@ void Title::init(bool demo, Uint8 subsection)
mPostFade = 0; mPostFade = 0;
mTicks = 0; mTicks = 0;
mTicksSpeed = 15; mTicksSpeed = 15;
//mText->init();
//mText2->init();
mFade->init(0x00, 0x00, 0x00); mFade->init(0x00, 0x00, 0x00);
mDemo = demo; mDemo = demo;

View File

@@ -5,11 +5,13 @@
Writer::Writer(Text *text) Writer::Writer(Text *text)
{ {
mText = text; mText = text;
init();
} }
// Destructor // Destructor
Writer::~Writer() Writer::~Writer()
{ {
mText = nullptr;
} }
// Inicializador // Inicializador