added poerup and helper

This commit is contained in:
2021-08-22 16:15:10 +02:00
parent eb8f84a4b8
commit 2fd4334259
7 changed files with 152 additions and 56 deletions

View File

@@ -29,6 +29,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;
mCollider.r = mWidth / 2;
shiftColliders();
@@ -83,7 +84,8 @@ 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 = (rand() % (PLAY_AREA_WIDTH - mWidth - 3)) + 3;
mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth));
mPosY = PLAY_AREA_TOP - mHeight;
mVelX = 0.0f;
mVelY = -2.0f;
@@ -142,6 +144,8 @@ void Item::render()
// Actualiza la posición y estados del globo
void Item::move()
{
mStatus = 0;
// Calcula la nueva posición
mPosX += mVelX;
mPosY += mVelY;
@@ -182,6 +186,7 @@ void Item::move()
mAccelX = 0;
mAccelY = 0;
mPosY = PLAY_AREA_BOTTOM - mHeight;
if (mClass == ITEM_COFFEE_MACHINE) mStatus = 1;
}
// Actualiza la posición del sprite
@@ -196,7 +201,7 @@ void Item::erase()
}
// Actualiza el objeto a su posicion, animación y controla los contadores
void Item::update()
int Item::update()
{
if (mEnabled)
{
@@ -206,6 +211,8 @@ void Item::update()
updateTimeToLive();
checkTimeToLive();
}
return mStatus;
}
// Actualiza el contador