fixing some bugs
This commit is contained in:
@@ -603,7 +603,8 @@ void Balloon::disable()
|
||||
void Balloon::pop()
|
||||
{
|
||||
setPopping(true);
|
||||
mSprite->setAnimationCounter(0);
|
||||
mSprite->setAnimationCounter(0);
|
||||
mSprite->disableRotate();
|
||||
setTimeToLive(120);
|
||||
setStop(true);
|
||||
setStoppedTimer(2000);
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
float zoomW; // Zoom aplicado a la anchura
|
||||
float zoomH; // Zoom aplicado a la altura
|
||||
float despX; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom
|
||||
float despY; // idem
|
||||
float despY; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom
|
||||
|
||||
// Vector con los valores de zoom para el ancho y alto del globo
|
||||
float w[MAX_BOUNCE] = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f};
|
||||
|
||||
@@ -171,7 +171,7 @@ Game::~Game()
|
||||
delete mTextureText;
|
||||
mTextureText = nullptr;
|
||||
|
||||
mTextureTextScoreBoard->unload();
|
||||
mTextureTextScoreBoard->unload();
|
||||
delete mTextureTextScoreBoard;
|
||||
mTextureTextScoreBoard = nullptr;
|
||||
|
||||
@@ -182,7 +182,7 @@ Game::~Game()
|
||||
delete mText;
|
||||
mText = nullptr;
|
||||
|
||||
delete mTextScoreBoard;
|
||||
delete mTextScoreBoard;
|
||||
mTextScoreBoard = nullptr;
|
||||
|
||||
delete mTextureTextBig;
|
||||
@@ -401,7 +401,7 @@ void Game::init()
|
||||
mSpriteScoreBoard->init(0, 160, SCREEN_WIDTH, 32, mTextureGameBG, mRenderer);
|
||||
mSpriteScoreBoard->setSpriteClip(0, 160, 256, 32);
|
||||
|
||||
mSpritePowerMeter->init(PLAY_AREA_CENTER_THIRD_QUARTER_X - 20, HISCORE_NUMBER_Y + 4, 40, 8, mTextureGameBG, mRenderer);
|
||||
mSpritePowerMeter->init(PLAY_AREA_CENTER_X - 20, 170, 40, 8, mTextureGameBG, mRenderer);
|
||||
mSpritePowerMeter->setSpriteClip(256, 192 - 8, 40, 8);
|
||||
|
||||
// Vector de jugadores
|
||||
@@ -1592,48 +1592,48 @@ void Game::renderScoreBoard()
|
||||
mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8);
|
||||
mSpritePowerMeter->render();
|
||||
*/
|
||||
const int offset1 = 162;
|
||||
const int offset2 = offset1 + 7;
|
||||
const int offset3 = offset2 + 7;
|
||||
const int offset4 = offset3 + 7;
|
||||
const int offset1 = 163;
|
||||
const int offset2 = offset1 + 8;
|
||||
const int offset3 = offset2 + 8;
|
||||
const int offset4 = offset3 + 8;
|
||||
// PLAYER1 - SCORE
|
||||
mTextScoreBoard->writeCentered(49/2, offset1, mTextStrings[53]);
|
||||
mTextScoreBoard->write(PLAY_AREA_LEFT+1, offset2, updateScoreText(mPlayer[0]->getScore()));
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_LEFT + 30, offset1, mTextStrings[53]);
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_LEFT + 30, offset2, updateScoreText(mPlayer[0]->getScore()));
|
||||
|
||||
// PLAYER1 - MULT
|
||||
mTextScoreBoard->write(PLAY_AREA_LEFT+1, offset3, mTextStrings[55] + std::to_string(mPlayer[0]->getScoreMultiplier()).substr(0, 3));
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_LEFT + 30, offset3, mTextStrings[55] + std::to_string(mPlayer[0]->getScoreMultiplier()).substr(0, 3));
|
||||
|
||||
if (mNumPlayers == 2)
|
||||
{
|
||||
// PLAYER2 - SCORE
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - (49/2), offset1, mTextStrings[54]);
|
||||
mTextScoreBoard->write(PLAY_AREA_RIGHT - 49, offset2, updateScoreText(mPlayer[1]->getScore()));
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset1, mTextStrings[54]);
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset2, updateScoreText(mPlayer[1]->getScore()));
|
||||
|
||||
// PLAYER2 - MULT
|
||||
mTextScoreBoard->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55]+std::to_string(mPlayer[1]->getScoreMultiplier()).substr(0, 3));
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset3, mTextStrings[55] + std::to_string(mPlayer[1]->getScoreMultiplier()).substr(0, 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
// PLAYER2 - SCORE
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - (49/2), offset1, mTextStrings[54]);
|
||||
mTextScoreBoard->write(PLAY_AREA_RIGHT - 49, offset2, "0000000");
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset1, mTextStrings[54]);
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset2, "0000000");
|
||||
|
||||
// PLAYER2 - MULT
|
||||
mTextScoreBoard->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55] + "1.0");
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - 30, offset3, mTextStrings[55] + "1.0");
|
||||
}
|
||||
|
||||
// STAGE
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1, mTextStrings[57] + std::to_string(mStage[mCurrentStage].number));
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1-1, mTextStrings[57] + std::to_string(mStage[mCurrentStage].number));
|
||||
|
||||
// POWER
|
||||
//mSpritePowerMeter->setSpriteClip(256, 184, 40, 8);
|
||||
//mSpritePowerMeter->render();
|
||||
//const float percent = (mStage[mCurrentStage].currentPower * 40.0f) / mStage[mCurrentStage].powerToComplete;
|
||||
//mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8);
|
||||
//mSpritePowerMeter->render();
|
||||
mSpritePowerMeter->setSpriteClip(256, 184, 40, 8);
|
||||
mSpritePowerMeter->render();
|
||||
const float percent = (mStage[mCurrentStage].currentPower * 40.0f) / mStage[mCurrentStage].powerToComplete;
|
||||
mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8);
|
||||
mSpritePowerMeter->render();
|
||||
|
||||
// HI-SCORE
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, mTextStrings[56] + "0000000");
|
||||
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3+1, mTextStrings[56] + updateScoreText(mHiScore));
|
||||
}
|
||||
|
||||
// Actualiza las variables del jugador
|
||||
@@ -2269,10 +2269,10 @@ void Game::resetItems()
|
||||
// Devuelve un item en función del azar
|
||||
Uint8 Game::dropItem()
|
||||
{
|
||||
/*if (mPlayer->isPowerUp() || (mCoffeeMachineEnabled))
|
||||
if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled))
|
||||
return NO_KIND;
|
||||
else
|
||||
return ITEM_COFFEE_MACHINE;*/
|
||||
return ITEM_COFFEE_MACHINE;
|
||||
|
||||
const Uint8 luckyNumber = rand() % 100;
|
||||
const Uint8 item = rand() % 6;
|
||||
|
||||
@@ -19,7 +19,7 @@ Instructions::Instructions(SDL_Renderer *renderer, std::string *fileList, std::s
|
||||
mItemTexture = new LTexture();
|
||||
mTextTexture = new LTexture();
|
||||
mSprite = new Sprite();
|
||||
mText = new Text(mFileList[46], mTextTexture, mRenderer);
|
||||
mText = new Text(mFileList[48], mTextTexture, mRenderer);
|
||||
|
||||
// Crea un backbuffer para el renderizador
|
||||
mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@@ -156,12 +156,12 @@ void Instructions::run(Uint8 mode)
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Escribe el texto
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, mTextStrings[11], 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, mTextStrings[12], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, mTextStrings[13], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, mTextStrings[14], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, mTextStrings[15], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, mTextStrings[16], 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, mTextStrings[11], 1, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, mTextStrings[12], 1, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, mTextStrings[13], 1, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, mTextStrings[14], 1, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, mTextStrings[15], 1, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, mTextStrings[16], 1, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
mText->writeShadowed(84, 92, mTextStrings[17], shdwTxtColor);
|
||||
mText->writeShadowed(84, 108, mTextStrings[18], shdwTxtColor);
|
||||
@@ -170,7 +170,7 @@ void Instructions::run(Uint8 mode)
|
||||
mText->writeShadowed(84, 156, mTextStrings[21], shdwTxtColor);
|
||||
|
||||
if ((mode == INSTRUCTIONS_MODE_MANUAL) && (mCounter % 50 > 14))
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - 12, mTextStrings[22], 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - 12, mTextStrings[22], 1, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
// Disquito
|
||||
mSprite->init(destRect1, mItemTexture, mRenderer);
|
||||
|
||||
@@ -103,7 +103,7 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
|
||||
}
|
||||
}
|
||||
|
||||
// Centra el globo en la posición X
|
||||
// Centra el objeto en la posición X
|
||||
void Item::allignTo(int x)
|
||||
{
|
||||
mPosX = float(x - (mWidth / 2));
|
||||
@@ -125,7 +125,7 @@ void Item::allignTo(int x)
|
||||
shiftColliders();
|
||||
}
|
||||
|
||||
// Pinta el globo en la pantalla
|
||||
// Pinta el objeto en la pantalla
|
||||
void Item::render()
|
||||
{
|
||||
if (mEnabled)
|
||||
@@ -141,7 +141,7 @@ void Item::render()
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza la posición y estados del globo
|
||||
// Actualiza la posición y estados del objeto
|
||||
void Item::move()
|
||||
{
|
||||
mStatus = 0;
|
||||
|
||||
@@ -262,6 +262,13 @@ void MovingSprite::setRotateAmount(double value)
|
||||
mRotateAmount = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::disableRotate()
|
||||
{
|
||||
mRotate = false;
|
||||
mAngle = 0;
|
||||
}
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
void MovingSprite::update()
|
||||
{
|
||||
|
||||
@@ -127,6 +127,9 @@ public:
|
||||
// Establece el valor de la variable
|
||||
void setRotateAmount(double value);
|
||||
|
||||
// Quita el efecto de rotación y deja el sprite en su angulo inicial.
|
||||
void disableRotate();
|
||||
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::stri
|
||||
mDustBitmapL = new AnimatedSprite();
|
||||
mDustBitmapR = new AnimatedSprite();
|
||||
mTile = new Sprite();
|
||||
mText = new Text(mFileList[46], mTextTexture, mRenderer);
|
||||
mText = new Text(mFileList[48], mTextTexture, mRenderer);
|
||||
mMenu.title = new Menu(mRenderer, mText, mInput, mFileList);
|
||||
mMenu.options = new Menu(mRenderer, mText, mInput, mFileList);
|
||||
|
||||
@@ -531,6 +531,26 @@ section_t Title::run(Uint8 subsection)
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el tileado de fondo
|
||||
switch (mBackgroundMode)
|
||||
{
|
||||
case 0: // El tileado de fondo se desplaza en diagonal
|
||||
mBackgroundWindow.x++;
|
||||
mBackgroundWindow.x %= 64;
|
||||
mBackgroundWindow.y++;
|
||||
mBackgroundWindow.y %= 64;
|
||||
break;
|
||||
|
||||
case 1: // El tileado de fondo se desplaza en circulo
|
||||
++mBackgroundCounter %= 360;
|
||||
mBackgroundWindow.x = 128 + (int(mSin[(mBackgroundCounter + 270) % 360] * 128));
|
||||
mBackgroundWindow.y = 96 + (int(mSin[(360 - mBackgroundCounter) % 360] * 96));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba las entradas para el menu
|
||||
if (mMenuVisible == true)
|
||||
mMenu.active->checkInput();
|
||||
@@ -616,27 +636,6 @@ section_t Title::run(Uint8 subsection)
|
||||
// Limpia la pantalla
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Pinta el tileado de fondo
|
||||
switch (mBackgroundMode)
|
||||
{
|
||||
case 0: // El tileado de fondo se desplaza en diagonal
|
||||
mBackgroundWindow.x++;
|
||||
mBackgroundWindow.x %= 64;
|
||||
mBackgroundWindow.y++;
|
||||
mBackgroundWindow.y %= 64;
|
||||
break;
|
||||
|
||||
case 1: // El tileado de fondo se desplaza en circulo
|
||||
++mBackgroundCounter %= 360;
|
||||
mBackgroundWindow.x = 128 + (int(mSin[(mBackgroundCounter + 270) % 360] * 128));
|
||||
mBackgroundWindow.y = 96 + (int(mSin[(360 - mBackgroundCounter) % 360] * 96));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL);
|
||||
|
||||
// Dibuja los objetos
|
||||
@@ -651,10 +650,10 @@ section_t Title::run(Uint8 subsection)
|
||||
|
||||
// PRESS ANY KEY!
|
||||
if ((mCounter % 50 > 14) && (mMenuVisible == false))
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, mTextStrings[23], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, mTextStrings[23], 1, noColor, 1, shdwTxtColor);
|
||||
|
||||
// Texto con el copyright y versión
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor);
|
||||
|
||||
// Fade
|
||||
mFade->render();
|
||||
|
||||
Reference in New Issue
Block a user