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

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