working on "How to play"

This commit is contained in:
2021-04-05 17:56:15 +02:00
parent d84137daa7
commit 36bb6b8fe8
16 changed files with 648 additions and 392 deletions

View File

@@ -34,8 +34,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_1;
mHeight = BALLOON_SIZE_1;
mWidth = BALLOON_WIDTH_1;
mHeight = BALLOON_WIDTH_1;
mSize = BALLOON_SIZE_1;
mPower = 1;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -45,7 +47,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = 2.6f;
// Puntos que da el globo al ser destruido
mScore = 50;
mScore = BALLOON_SCORE_1;
// Amenaza que genera el globo
mMenace = 1;
@@ -66,8 +68,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_2;
mHeight = BALLOON_SIZE_2;
mWidth = BALLOON_WIDTH_2;
mHeight = BALLOON_WIDTH_2;
mSize = BALLOON_SIZE_2;
mPower = 3;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -77,7 +81,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = 3.5f;
// Puntos que da el globo al ser destruido
mScore = 100;
mScore = BALLOON_SCORE_2;
// Amenaza que genera el globo
mMenace = 2;
@@ -98,8 +102,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_3;
mHeight = BALLOON_SIZE_3;
mWidth = BALLOON_WIDTH_3;
mHeight = BALLOON_WIDTH_3;
mSize = BALLOON_SIZE_3;
mPower = 7;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -109,7 +115,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = 4.50f;
// Puntos que da el globo al ser destruido
mScore = 200;
mScore = BALLOON_SCORE_3;
// Amenaza que genera el globo
mMenace = 4;
@@ -130,8 +136,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_4;
mHeight = BALLOON_SIZE_4;
mWidth = BALLOON_WIDTH_4;
mHeight = BALLOON_WIDTH_4;
mSize = BALLOON_SIZE_4;
mPower = 15;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -141,7 +149,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = 4.95f;
// Puntos que da el globo al ser destruido
mScore = 400;
mScore = BALLOON_SCORE_4;
// Amenaza que genera el globo
mMenace = 8;
@@ -162,8 +170,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_1;
mHeight = BALLOON_SIZE_1;
mWidth = BALLOON_WIDTH_1;
mHeight = BALLOON_WIDTH_1;
mSize = BALLOON_SIZE_1;
mPower = 1;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -173,7 +183,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = abs(velx) * 2;
// Puntos que da el globo al ser destruido
mScore = 50;
mScore = BALLOON_SCORE_1;
// Amenaza que genera el globo
mMenace = 1;
@@ -194,8 +204,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_2;
mHeight = BALLOON_SIZE_2;
mWidth = BALLOON_WIDTH_2;
mHeight = BALLOON_WIDTH_2;
mSize = BALLOON_SIZE_2;
mPower = 3;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -205,7 +217,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = abs(velx) * 2;
// Puntos que da el globo al ser destruido
mScore = 100;
mScore = BALLOON_SCORE_2;
// Amenaza que genera el globo
mMenace = 2;
@@ -226,8 +238,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_3;
mHeight = BALLOON_SIZE_3;
mWidth = BALLOON_WIDTH_3;
mHeight = BALLOON_WIDTH_3;
mSize = BALLOON_SIZE_3;
mPower = 7;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -237,7 +251,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = abs(velx) * 2;
// Puntos que da el globo al ser destruido
mScore = 200;
mScore = BALLOON_SCORE_3;
// Amenaza que genera el globo
mMenace = 4;
@@ -258,8 +272,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_4;
mHeight = BALLOON_SIZE_4;
mWidth = BALLOON_WIDTH_4;
mHeight = BALLOON_WIDTH_4;
mSize = BALLOON_SIZE_4;
mPower = 15;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -269,7 +285,7 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mDefaultVelY = abs(velx) * 2;
// Puntos que da el globo al ser destruido
mScore = 400;
mScore = BALLOON_SCORE_4;
// Amenaza que genera el globo
mMenace = 8;
@@ -290,8 +306,10 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mEnabled = true;
// Alto y ancho del objeto
mWidth = BALLOON_SIZE_4;
mHeight = BALLOON_SIZE_4;
mWidth = BALLOON_WIDTH_4;
mHeight = BALLOON_WIDTH_4;
mSize = 4;
mPower = 0;
// Inicializa los valores de velocidad y gravedad
mVelX = velx;
@@ -311,11 +329,15 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16
mSprite->setAnimationFrames(BALLOON_MOVING_ANIMATION, i, OFFSET_POWER_BALL, 37 * i, getWidth(), getHeight());
for (Uint8 i = 0; i < NUM_FRAMES_BALLON_BORN; i++)
mSprite->setAnimationFrames(BALLOON_BORN_ANIMATION, i, OFFSET_BLUE_BALLOONS, 37 * i, getWidth(), getHeight());
mSprite->setAnimationFrames(BALLOON_BORN_ANIMATION, i, OFFSET_POWER_BALL, 37 * i, getWidth(), getHeight());
for (Uint8 i = 0; i < NUM_FRAMES_BALLON_POP; i++)
mSprite->setAnimationFrames(BALLOON_POP_ANIMATION, i, OFFSET_EXPLOSIONS, 37 * i, getWidth(), getHeight());
// Añade rotación al sprite
mSprite->setRotate(false);
mSprite->setRotateSpeed(1);
mSprite->setRotateAmount(2.0);
break;
default:
@@ -471,6 +493,9 @@ void Balloon::move()
// Invierte sentido
mVelX = -mVelX;
// Invierte la rotación
mSprite->switchRotate();
// Activa el efecto de rebote
bounceStart();
}
@@ -539,33 +564,38 @@ void Balloon::move()
// Deshabilita el globo y pone a cero todos los valores
void Balloon::disable()
{
mEnabled = false;
mPosX = 0.0f;
mPosY = 0.0f;
mWidth = 0;
mHeight = 0;
mVelX = 0.0f;
mVelY = 0.0f;
mGravity = 0.0f;
mDefaultVelY = 0.0f;
mMaxVelY = 0.0f;
mBeingCreated = false;
mBlinking = false;
mInvulnerable = false;
mPopping = false;
mStopped = false;
mVisible = false;
mCollider.r = 0;
mCollider.x = 0;
mCollider.y = 0;
mCollider.r = 0;
mCounter = 0;
mCreationCounter = 0;
mCreationCounterIni = 0;
mDefaultVelY = 0.0f;
mEnabled = false;
mGravity = 0.0f;
mHeight = 0;
mInvulnerable = false;
mKind = 0;
mMaxVelY = 0.0f;
mMenace = 0;
mPopping = false;
mPosX = 0.0f;
mPosY = 0.0f;
mPower = 0;
mScore = 0;
mSize = 0;
mSpeed = 0;
mStopped = false;
mStoppedCounter = 0;
mTimeToLive = 0;
mKind = 0;
mMenace = 0;
mTravelY = 0;
mVelX = 0.0f;
mVelY = 0.0f;
mVisible = false;
mWidth = 0;
mSprite->clear();
}
// Explosiona el globo
@@ -585,6 +615,7 @@ void Balloon::update()
{
if (mEnabled)
{
mSprite->MovingSprite::update();
move();
updateAnimation();
updateColliders();
@@ -661,6 +692,14 @@ void Balloon::updateState()
setStop(false);
setVisible(true);
setInvulnerable(false);
if (mKind == POWER_BALL)
{
mSprite->setRotate(true);
if (mVelX > 0.0f)
mSprite->setRotateAmount(2.0);
else
mSprite->setRotateAmount(-2.0);
}
}
}
// Solo comprueba el estado detenido cuando no se está creando
@@ -741,6 +780,12 @@ int Balloon::getKind()
return mKind;
}
// Obtiene del valor de la variable
Uint8 Balloon::getSize()
{
return mSize;
}
// Obtiene la clase a la que pertenece el globo
Uint8 Balloon::getClass()
{
@@ -877,6 +922,12 @@ Uint8 Balloon::getMenace()
return 0;
}
// Obtiene le valor de la variable
Uint8 Balloon::getPower()
{
return mPower;
}
void Balloon::bounceStart()
{
mBouncing.enabled = true;