From ff0102256c83e3a716a796963de51ad8a712af64 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 27 Aug 2021 13:54:57 +0200 Subject: [PATCH] enhancing title screen --- source/director.cpp | 2 +- source/game.cpp | 29 ++++++++++++++++++----------- source/item.cpp | 23 ----------------------- source/player.cpp | 2 +- source/title.cpp | 6 ++++++ 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index edd8fd8..3c42670 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -74,7 +74,7 @@ void Director::init() } // Sección - mSection.name = PROG_SECTION_GAME; + mSection.name = PROG_SECTION_LOGO; mSection.subsection = 0; // Textos diff --git a/source/game.cpp b/source/game.cpp index 95bab9e..5db84c3 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2133,6 +2133,12 @@ void Game::checkPlayerItemCollision(int index) case ITEM_COFFEE: mPlayer[index]->giveExtraHit(); JA_PlaySound(mSoundItemPickup); + if (mPlayer[index]->getCoffees() == 2) + { + mPlayer[index]->addScore(5000); + updateHiScore(); + createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m5000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m5000Bitmap); + } break; case ITEM_COFFEE_MACHINE: mPlayer[index]->setPowerUp(true); @@ -2277,10 +2283,10 @@ void Game::resetItems() // Devuelve un item en función del azar Uint8 Game::dropItem() { - if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled)) - return NO_KIND; - else - return ITEM_COFFEE_MACHINE; + //if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled)) + // return NO_KIND; + //else + // return ITEM_COFFEE_MACHINE; const Uint8 luckyNumber = rand() % 100; const Uint8 item = rand() % 6; @@ -2873,7 +2879,7 @@ void Game::checkGameInput() } // Comprueba el input de pausa - if (mInput[i]->checkInput(INPUT_BUTTON_PAUSE, REPEAT_FALSE)) + if (mInput[i]->checkInput(INPUT_CANCEL, REPEAT_FALSE)) { mSection.subsection = GAME_SECTION_PAUSE; @@ -3159,12 +3165,13 @@ void Game::runPausedGame() } // Dibuja los objetos - renderBackground(); - renderBalloons(); - renderBullets(); - for (int i = 0; i < mNumPlayers; i++) - mPlayer[i]->render(); - renderScoreBoard(); + //renderBackground(); + //renderBalloons(); + //renderBullets(); + //for (int i = 0; i < mNumPlayers; i++) + // mPlayer[i]->render(); + //renderScoreBoard(); + renderPlayField(); mMenuPause->render(); mFade->render(); diff --git a/source/item.cpp b/source/item.cpp index 85dc016..f7b7b00 100644 --- a/source/item.cpp +++ b/source/item.cpp @@ -87,7 +87,6 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer * case ITEM_COFFEE_MACHINE: mWidth = 32; mHeight = 32; - //mPosX = (rand() % (PLAY_AREA_WIDTH - mWidth - 3)) + 3; mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth - 5)) + 2; mPosY = PLAY_AREA_TOP - mHeight; mVelX = 0.0f; @@ -98,7 +97,6 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer * mSprite->setAnimationFrames(0, 1, 32 * 1, 16 * 2, mWidth, mHeight); mSprite->setAnimationFrames(0, 2, 32 * 2, 16 * 2, mWidth, mHeight); mSprite->setAnimationFrames(0, 3, 32 * 3, 16 * 2, mWidth, mHeight); - //mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0)); mSprite->setPosX(mPosX); mSprite->setPosY(mPosY); mCollider.r = 10; @@ -108,17 +106,6 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer * default: break; } - - if (mClass == ITEM_COFFEE_MACHINE) - { - printf("-creation-\n"); - printf("x\t%f\n", mPosX); - printf("y\t%f\n", mPosY); - printf("ax\t%f\n", mAccelX); - printf("ay\t%f\n", mAccelY); - printf("r\t%i\n", mCollider.r); - printf("---\n"); - } } // Centra el objeto en la posición X @@ -162,16 +149,6 @@ void Item::render() // Actualiza la posición y estados del objeto void Item::move() { - //if (mClass == ITEM_COFFEE_MACHINE) - //{ - // printf("-move-\n"); - // printf("x\t%f\n", mPosX); - // printf("y\t%f\n", mPosY); - // printf("ax\t%f\n", mAccelX); - // printf("ay\t%f\n", mAccelY); - // printf("---\n"); - //} - mStatus = 0; // Calcula la nueva posición diff --git a/source/player.cpp b/source/player.cpp index 1db63aa..3f03426 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -65,7 +65,7 @@ void Player::init(float x, int y, LTexture *textureLegs, LTexture *textureBody, mScore = 0; // Establece el multiplicador de puntos inicial - mScoreMultiplier = 2.0f; + mScoreMultiplier = 1.0f; // Inicia el contador para la cadencia de disparo mCooldown = 10; diff --git a/source/title.cpp b/source/title.cpp index 5622a7b..deb0f19 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -391,6 +391,9 @@ section_t Title::run(Uint8 subsection) SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255); SDL_RenderClear(mRenderer); + // Dibuja el tileado de fondo + SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL); + // Dibuja los objetos mCoffeeBitmap->render(); mCrisisBitmap->render(); @@ -437,6 +440,9 @@ section_t Title::run(Uint8 subsection) SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255); SDL_RenderClear(mRenderer); + // Dibuja el tileado de fondo + SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL); + // Dibuja los objetos mCoffeeBitmap->setPosX(a + v[n / 3]); mCrisisBitmap->setPosX(b + v[n / 3]);