Powerup face blinking
This commit is contained in:
@@ -30,12 +30,15 @@ void Player::init(float x, int y, LTexture *textureLegs, LTexture *textureBody,
|
||||
|
||||
// Inicializa variables de estado
|
||||
mAlive = true;
|
||||
mDeathCounter = DEATH_COUNTER;
|
||||
mDeathIndex = 0;
|
||||
mStatusWalking = PLAYER_STATUS_WALKING_STOP;
|
||||
mStatusFiring = PLAYER_STATUS_FIRING_NO;
|
||||
mInvulnerable = false;
|
||||
mInvulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
|
||||
mPowerUp = false;
|
||||
mPowerUpCounter = PLAYER_POWERUP_COUNTER;
|
||||
mPowerUpHeadOffset = 0;
|
||||
mExtraHit = false;
|
||||
mCoffees = 0;
|
||||
mInput = true;
|
||||
@@ -368,12 +371,12 @@ void Player::setAnimation()
|
||||
// Actualiza los frames de la animación en función de si se tiene el PowerUp
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_LEFT, i, (mWidth * i) + (mPowerUp * 96), mHeight * (0 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_LEFT, i, (mWidth * i) + (mPowerUp * 96), mHeight * (1 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_RIGHT, i, (mWidth * i) + (mPowerUp * 96), mHeight * (2 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_RIGHT, i, (mWidth * i) + (mPowerUp * 96), mHeight * (3 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_STOP, i, (mWidth * i) + (mPowerUp * 96), mHeight * (4 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_UP, i, (mWidth * i) + (mPowerUp * 96), mHeight * (5 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_LEFT, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (0 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_LEFT, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (1 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_RIGHT, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (2 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_RIGHT, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (3 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_WALKING_STOP, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (4 + (6 * mCoffees)), mWidth, mHeight);
|
||||
mSpriteHead->setAnimationFrames(PLAYER_ANIMATION_HEAD_FIRING_UP, i, (mWidth * i) + mPowerUpHeadOffset, mHeight * (5 + (6 * mCoffees)), mWidth, mHeight);
|
||||
}
|
||||
|
||||
switch (mStatusWalking)
|
||||
@@ -545,6 +548,8 @@ void Player::update()
|
||||
updateCooldown();
|
||||
updatePowerUpCounter();
|
||||
updateInvulnerableCounter();
|
||||
updateDeathCounter();
|
||||
updatePowerUpHeadOffset();
|
||||
}
|
||||
|
||||
// Obtiene la puntuación del jugador
|
||||
@@ -634,15 +639,24 @@ void Player::setInvulnerableCounter(Uint16 value)
|
||||
// Actualiza el valor de la variable
|
||||
void Player::updateInvulnerableCounter()
|
||||
{
|
||||
if (mInvulnerableCounter > 0)
|
||||
{
|
||||
--mInvulnerableCounter;
|
||||
}
|
||||
else
|
||||
{
|
||||
mInvulnerable = false;
|
||||
mInvulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
|
||||
}
|
||||
if (mInvulnerable)
|
||||
if (mInvulnerableCounter > 0)
|
||||
{
|
||||
mInvulnerableCounter--;
|
||||
}
|
||||
else
|
||||
{
|
||||
mInvulnerable = false;
|
||||
mInvulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el valor de la variable
|
||||
void Player::updateDeathCounter()
|
||||
{
|
||||
if (!mAlive)
|
||||
if (mDeathCounter > 0)
|
||||
mDeathCounter--;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
@@ -744,4 +758,28 @@ void Player::shiftColliders()
|
||||
LTexture *Player::getDeadTexture()
|
||||
{
|
||||
return mPlayerDeadTexture;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Player::getDeathCounter()
|
||||
{
|
||||
return mDeathCounter;
|
||||
}
|
||||
|
||||
// Actualiza el valor de la variable
|
||||
void Player::updatePowerUpHeadOffset()
|
||||
{
|
||||
if (!mPowerUp)
|
||||
mPowerUpHeadOffset = 0;
|
||||
else
|
||||
{
|
||||
mPowerUpHeadOffset = 96;
|
||||
if (mPowerUpCounter < 300)
|
||||
{
|
||||
if (mPowerUpCounter % 10 > 4)
|
||||
mPowerUpHeadOffset = 96;
|
||||
else
|
||||
mPowerUpHeadOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user