bug hunting coffee machine on windows

This commit is contained in:
2021-08-27 12:32:34 +02:00
parent 5d6047b642
commit 70324570c8
4 changed files with 48 additions and 34 deletions

View File

@@ -1623,7 +1623,7 @@ void Game::renderScoreBoard()
} }
// STAGE // STAGE
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1-1, 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 // POWER
mSpritePowerMeter->setSpriteClip(256, 184, 40, 8); mSpritePowerMeter->setSpriteClip(256, 184, 40, 8);
@@ -1633,7 +1633,7 @@ void Game::renderScoreBoard()
mSpritePowerMeter->render(); mSpritePowerMeter->render();
// HI-SCORE // HI-SCORE
mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3+1, mTextStrings[56] + updateScoreText(mHiScore)); mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3 + 1, mTextStrings[56] + updateScoreText(mHiScore));
} }
// Actualiza las variables del jugador // Actualiza las variables del jugador
@@ -2110,21 +2110,18 @@ void Game::checkPlayerItemCollision(int index)
{ {
case ITEM_POINTS_1_DISK: case ITEM_POINTS_1_DISK:
mPlayer[index]->addScore(1000); mPlayer[index]->addScore(1000);
//setScore(mPlayer[index]->getScore());
updateHiScore(); updateHiScore();
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m1000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m1000Bitmap); createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m1000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m1000Bitmap);
JA_PlaySound(mSoundItemPickup); JA_PlaySound(mSoundItemPickup);
break; break;
case ITEM_POINTS_2_GAVINA: case ITEM_POINTS_2_GAVINA:
mPlayer[index]->addScore(2500); mPlayer[index]->addScore(2500);
//setScore(mPlayer[index]->getScore());
updateHiScore(); updateHiScore();
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m2500Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m2500Bitmap); createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m2500Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m2500Bitmap);
JA_PlaySound(mSoundItemPickup); JA_PlaySound(mSoundItemPickup);
break; break;
case ITEM_POINTS_3_PACMAR: case ITEM_POINTS_3_PACMAR:
mPlayer[index]->addScore(5000); mPlayer[index]->addScore(5000);
//setScore(mPlayer[index]->getScore());
updateHiScore(); updateHiScore();
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m5000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m5000Bitmap); createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m5000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m5000Bitmap);
JA_PlaySound(mSoundItemPickup); JA_PlaySound(mSoundItemPickup);
@@ -2141,6 +2138,12 @@ void Game::checkPlayerItemCollision(int index)
mPlayer[index]->setPowerUp(true); mPlayer[index]->setPowerUp(true);
JA_PlaySound(mSoundItemPickup); JA_PlaySound(mSoundItemPickup);
mCoffeeMachineEnabled = false; mCoffeeMachineEnabled = false;
{
printf("-collision-\n");
printf("x\t%f\n", mItem[i]->getPosX());
printf("y\t%f\n", mItem[i]->getPosY());
printf("---\n");
}
break; break;
default: default:
@@ -2181,12 +2184,17 @@ void Game::checkBulletBalloonCollision()
const Uint8 droppeditem = dropItem(); const Uint8 droppeditem = dropItem();
if ((droppeditem != NO_KIND) && !(mDemo.enabled) && !(mDemo.recording)) if ((droppeditem != NO_KIND) && !(mDemo.enabled) && !(mDemo.recording))
{ {
createItem(mBalloon[i]->getPosX(), mBalloon[i]->getPosY(), droppeditem);
if (droppeditem != ITEM_COFFEE_MACHINE) if (droppeditem != ITEM_COFFEE_MACHINE)
{
createItem(mBalloon[i]->getPosX(), mBalloon[i]->getPosY(), droppeditem);
JA_PlaySound(mSoundItemDrop); JA_PlaySound(mSoundItemDrop);
}
else else
{
createItem(mPlayer[index]->getPosX(), 0, droppeditem);
mCoffeeMachineEnabled = true; mCoffeeMachineEnabled = true;
} }
}
break; break;
} }
} }

View File

@@ -43,6 +43,8 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
mSprite->setAnimationSpeed(0, 10); mSprite->setAnimationSpeed(0, 10);
mSprite->setAnimationLoop(0, true); mSprite->setAnimationLoop(0, true);
mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0)); mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0));
mSprite->setPosX(mPosX);
mSprite->setPosY(mPosY);
switch (value) switch (value)
{ {
@@ -86,15 +88,19 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
mWidth = 32; mWidth = 32;
mHeight = 32; mHeight = 32;
//mPosX = (rand() % (PLAY_AREA_WIDTH - mWidth - 3)) + 3; //mPosX = (rand() % (PLAY_AREA_WIDTH - mWidth - 3)) + 3;
mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth)); mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth - 5)) + 2;
mPosY = PLAY_AREA_TOP - mHeight; mPosY = PLAY_AREA_TOP - mHeight;
mVelX = 0.0f; mVelX = 0.0f;
mVelY = -2.0f; mVelY = -0.1f;
mAccelY = 0.15f;
mSprite->setAnimationNumFrames(0, 4); mSprite->setAnimationNumFrames(0, 4);
mSprite->setAnimationFrames(0, 0, 32 * 0, 16 * 2, mWidth, mHeight); mSprite->setAnimationFrames(0, 0, 32 * 0, 16 * 2, mWidth, mHeight);
mSprite->setAnimationFrames(0, 1, 32 * 1, 16 * 2, mWidth, mHeight); mSprite->setAnimationFrames(0, 1, 32 * 1, 16 * 2, mWidth, mHeight);
mSprite->setAnimationFrames(0, 2, 32 * 2, 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->setAnimationFrames(0, 3, 32 * 3, 16 * 2, mWidth, mHeight);
//mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0));
mSprite->setPosX(mPosX);
mSprite->setPosY(mPosY);
mCollider.r = mWidth / 2; mCollider.r = mWidth / 2;
shiftColliders(); shiftColliders();
break; break;
@@ -105,12 +111,12 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
if (mClass == ITEM_COFFEE_MACHINE) if (mClass == ITEM_COFFEE_MACHINE)
{ {
printf("---\n"); printf("-creation-\n");
printf("x\t%f\n", mPosX); printf("x\t%f\n", mPosX);
printf("y\t%f\n", mPosY); printf("y\t%f\n", mPosY);
printf("ax\t%f\n", mAccelX); printf("ax\t%f\n", mAccelX);
printf("ay\t%f\n", mAccelY); printf("ay\t%f\n", mAccelY);
printf("r\t%f\n", mCollider.r); printf("r\t%i\n", mCollider.r);
printf("---\n"); printf("---\n");
} }
} }
@@ -156,15 +162,15 @@ 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()
{ {
if (mClass == ITEM_COFFEE_MACHINE) //if (mClass == ITEM_COFFEE_MACHINE)
{ //{
printf("---\n"); // printf("-move-\n");
printf("x\t%f\n", mPosX); // printf("x\t%f\n", mPosX);
printf("y\t%f\n", mPosY); // printf("y\t%f\n", mPosY);
printf("ax\t%f\n", mAccelX); // printf("ax\t%f\n", mAccelX);
printf("ay\t%f\n", mAccelY); // printf("ay\t%f\n", mAccelY);
printf("---\n"); // printf("---\n");
} //}
mStatus = 0; mStatus = 0;
@@ -187,14 +193,14 @@ void Item::move()
} }
// Si se sale por arriba // Si se sale por arriba
if (mPosY < PLAY_AREA_TOP) //if (mPosY < PLAY_AREA_TOP)
{ //{
// 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)
@@ -305,6 +311,6 @@ circle_t &Item::getCollider()
// Alinea el circulo de colisión con la posición del objeto // Alinea el circulo de colisión con la posición del objeto
void Item::shiftColliders() void Item::shiftColliders()
{ {
mCollider.x = Uint16(mPosX + mCollider.r); mCollider.x = int(mPosX + mCollider.r);
mCollider.y = Uint16(mPosY + mCollider.r); mCollider.y = int(mPosY + mCollider.r);
} }

View File

@@ -736,8 +736,8 @@ circle_t &Player::getCollider()
// Actualiza el circulo de colisión a la posición del jugador // Actualiza el circulo de colisión a la posición del jugador
void Player::shiftColliders() void Player::shiftColliders()
{ {
mCollider.x = Uint16(mPosX + (mWidth / 2)); mCollider.x = int(mPosX + (mWidth / 2));
mCollider.y = mPosY + (mHeight / 2); mCollider.y = int(mPosY + (mHeight / 2));
} }
// Obtiene el puntero a la textura con los gráficos de la animación de morir // Obtiene el puntero a la textura con los gráficos de la animación de morir

View File

@@ -8,9 +8,9 @@
// Estructura para definir un circulo // Estructura para definir un circulo
struct circle_t struct circle_t
{ {
Uint16 x; int x;
Uint16 y; int y;
Uint8 r; int r;
}; };
// Estructura para definir un color // Estructura para definir un color