Los items ya parecen funcionar. revisar power ball y los puntos al coger items
This commit is contained in:
@@ -7,11 +7,11 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
mSprite = new AnimatedSprite(texture, renderer, file);
|
mSprite = new AnimatedSprite(texture, renderer, file);
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
|
mEnabled = true;
|
||||||
|
|
||||||
switch (kind)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case BALLOON_1:
|
case BALLOON_1:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_1;
|
mWidth = BALLOON_WIDTH_1;
|
||||||
mHeight = BALLOON_WIDTH_1;
|
mHeight = BALLOON_WIDTH_1;
|
||||||
@@ -34,8 +34,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_2:
|
case BALLOON_2:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_2;
|
mWidth = BALLOON_WIDTH_2;
|
||||||
mHeight = BALLOON_WIDTH_2;
|
mHeight = BALLOON_WIDTH_2;
|
||||||
@@ -58,8 +56,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_3:
|
case BALLOON_3:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_3;
|
mWidth = BALLOON_WIDTH_3;
|
||||||
mHeight = BALLOON_WIDTH_3;
|
mHeight = BALLOON_WIDTH_3;
|
||||||
@@ -82,8 +78,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_4:
|
case BALLOON_4:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_4;
|
mWidth = BALLOON_WIDTH_4;
|
||||||
mHeight = BALLOON_WIDTH_4;
|
mHeight = BALLOON_WIDTH_4;
|
||||||
@@ -106,8 +100,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HEXAGON_1:
|
case HEXAGON_1:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_1;
|
mWidth = BALLOON_WIDTH_1;
|
||||||
mHeight = BALLOON_WIDTH_1;
|
mHeight = BALLOON_WIDTH_1;
|
||||||
@@ -130,8 +122,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HEXAGON_2:
|
case HEXAGON_2:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_2;
|
mWidth = BALLOON_WIDTH_2;
|
||||||
mHeight = BALLOON_WIDTH_2;
|
mHeight = BALLOON_WIDTH_2;
|
||||||
@@ -154,8 +144,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HEXAGON_3:
|
case HEXAGON_3:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_3;
|
mWidth = BALLOON_WIDTH_3;
|
||||||
mHeight = BALLOON_WIDTH_3;
|
mHeight = BALLOON_WIDTH_3;
|
||||||
@@ -178,8 +166,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HEXAGON_4:
|
case HEXAGON_4:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_4;
|
mWidth = BALLOON_WIDTH_4;
|
||||||
mHeight = BALLOON_WIDTH_4;
|
mHeight = BALLOON_WIDTH_4;
|
||||||
@@ -202,8 +188,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case POWER_BALL:
|
case POWER_BALL:
|
||||||
mEnabled = true;
|
|
||||||
|
|
||||||
// Alto y ancho del objeto
|
// Alto y ancho del objeto
|
||||||
mWidth = BALLOON_WIDTH_4;
|
mWidth = BALLOON_WIDTH_4;
|
||||||
mHeight = BALLOON_WIDTH_4;
|
mHeight = BALLOON_WIDTH_4;
|
||||||
@@ -231,8 +215,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mEnabled = false;
|
|
||||||
mMenace = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +438,7 @@ void Balloon::disable()
|
|||||||
mSpeed = 0;
|
mSpeed = 0;
|
||||||
mStopped = false;
|
mStopped = false;
|
||||||
mStoppedCounter = 0;
|
mStoppedCounter = 0;
|
||||||
mTimeToLive = 0;
|
//mTimeToLive = 0;
|
||||||
mTravelY = 0;
|
mTravelY = 0;
|
||||||
mVelX = 0.0f;
|
mVelX = 0.0f;
|
||||||
mVelY = 0.0f;
|
mVelY = 0.0f;
|
||||||
@@ -469,9 +451,7 @@ void Balloon::disable()
|
|||||||
void Balloon::pop()
|
void Balloon::pop()
|
||||||
{
|
{
|
||||||
setPopping(true);
|
setPopping(true);
|
||||||
mSprite->setAnimationCounter(0);
|
|
||||||
mSprite->disableRotate();
|
mSprite->disableRotate();
|
||||||
setTimeToLive(120);
|
|
||||||
setStop(true);
|
setStop(true);
|
||||||
setStoppedTimer(2000);
|
setStoppedTimer(2000);
|
||||||
setInvulnerable(true);
|
setInvulnerable(true);
|
||||||
@@ -503,18 +483,18 @@ void Balloon::updateState()
|
|||||||
setStop(true);
|
setStop(true);
|
||||||
if (mSprite->animationIsCompleted())
|
if (mSprite->animationIsCompleted())
|
||||||
{
|
{
|
||||||
mSprite->setAnimationCompleted(BALLOON_POP_ANIMATION, false);
|
//mSprite->setAnimationCompleted(BALLOON_POP_ANIMATION, false);
|
||||||
mTimeToLive = 0;
|
//mTimeToLive = 0;
|
||||||
disable();
|
disable();
|
||||||
}
|
}
|
||||||
else if (mTimeToLive > 0)
|
/*else if (mTimeToLive > 0)
|
||||||
{
|
{
|
||||||
mTimeToLive--;
|
mTimeToLive--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disable();
|
disable();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si se está creando
|
// Si se está creando
|
||||||
@@ -757,18 +737,6 @@ bool Balloon::isPopping()
|
|||||||
return mPopping;
|
return mPopping;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Balloon::setTimeToLive(Uint16 time)
|
|
||||||
{
|
|
||||||
mTimeToLive = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene del valor de la variable
|
|
||||||
Uint16 Balloon::getTimeToLive()
|
|
||||||
{
|
|
||||||
return mTimeToLive;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Balloon::setStoppedTimer(Uint16 time)
|
void Balloon::setStoppedTimer(Uint16 time)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ private:
|
|||||||
Uint16 mCreationCounterIni; // Valor inicial para el temporizador para controlar el estado "creandose"
|
Uint16 mCreationCounterIni; // Valor inicial para el temporizador para controlar el estado "creandose"
|
||||||
Uint16 mScore; // Puntos que da el globo al ser destruido
|
Uint16 mScore; // Puntos que da el globo al ser destruido
|
||||||
Uint16 mStoppedCounter; // Contador para controlar el estado "parado"
|
Uint16 mStoppedCounter; // Contador para controlar el estado "parado"
|
||||||
Uint16 mTimeToLive; // Indica el tiempo de vida que le queda al globo
|
//Uint16 mTimeToLive; // Indica el tiempo de vida que le queda al globo
|
||||||
Uint8 mKind; // Tipo de globo
|
Uint8 mKind; // Tipo de globo
|
||||||
Uint8 mMenace; // Cantidad de amenaza que genera el globo
|
Uint8 mMenace; // Cantidad de amenaza que genera el globo
|
||||||
Uint32 mCounter; // Contador interno
|
Uint32 mCounter; // Contador interno
|
||||||
@@ -138,12 +138,6 @@ private:
|
|||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setBeingCreated(bool state);
|
void setBeingCreated(bool state);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setTimeToLive(Uint16 time);
|
|
||||||
|
|
||||||
// Obtiene del valor de la variable
|
|
||||||
Uint16 getTimeToLive();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::string file, SDL_Renderer *renderer);
|
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::string file, SDL_Renderer *renderer);
|
||||||
|
|||||||
@@ -2165,7 +2165,6 @@ void Game::checkPlayerItemCollision(Player *player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto item : items)
|
for (auto item : items)
|
||||||
// for (int i = 0; i < MAX_ITEMS; i++)
|
|
||||||
{
|
{
|
||||||
if (item->isEnabled())
|
if (item->isEnabled())
|
||||||
{
|
{
|
||||||
@@ -2214,6 +2213,7 @@ void Game::checkPlayerItemCollision(Player *player)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
item->disable();
|
item->disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2255,12 +2255,12 @@ void Game::checkBulletBalloonCollision()
|
|||||||
{
|
{
|
||||||
if (droppeditem != ITEM_COFFEE_MACHINE)
|
if (droppeditem != ITEM_COFFEE_MACHINE)
|
||||||
{
|
{
|
||||||
createItem(balloon->getPosX(), balloon->getPosY(), droppeditem);
|
createItem(droppeditem, balloon->getPosX(), balloon->getPosY());
|
||||||
JA_PlaySound(mSoundItemDrop);
|
JA_PlaySound(mSoundItemDrop);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
createItem(players.at(index)->getPosX(), 0, droppeditem);
|
createItem(droppeditem, players.at(index)->getPosX(), 0);
|
||||||
mCoffeeMachineEnabled = true;
|
mCoffeeMachineEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2325,6 +2325,8 @@ void Game::freeBullets()
|
|||||||
void Game::updateItems()
|
void Game::updateItems()
|
||||||
{
|
{
|
||||||
for (auto item : items)
|
for (auto item : items)
|
||||||
|
{
|
||||||
|
if (item->isEnabled())
|
||||||
{
|
{
|
||||||
item->update();
|
item->update();
|
||||||
if (item->isOnFloor())
|
if (item->isOnFloor())
|
||||||
@@ -2334,6 +2336,7 @@ void Game::updateItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pinta los items activos
|
// Pinta los items activos
|
||||||
void Game::renderItems()
|
void Game::renderItems()
|
||||||
@@ -2354,22 +2357,30 @@ Uint8 Game::dropItem()
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (luckyNumber < mHelper.itemPoints1Odds)
|
if (luckyNumber < mHelper.itemPoints1Odds)
|
||||||
|
{
|
||||||
return ITEM_POINTS_1_DISK;
|
return ITEM_POINTS_1_DISK;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (luckyNumber < mHelper.itemPoints2Odds)
|
if (luckyNumber < mHelper.itemPoints2Odds)
|
||||||
|
{
|
||||||
return ITEM_POINTS_2_GAVINA;
|
return ITEM_POINTS_2_GAVINA;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (luckyNumber < mHelper.itemPoints3Odds)
|
if (luckyNumber < mHelper.itemPoints3Odds)
|
||||||
|
{
|
||||||
return ITEM_POINTS_3_PACMAR;
|
return ITEM_POINTS_3_PACMAR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (luckyNumber < mHelper.itemClockOdds)
|
if (luckyNumber < mHelper.itemClockOdds)
|
||||||
|
{
|
||||||
return ITEM_CLOCK;
|
return ITEM_CLOCK;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
@@ -2415,8 +2426,8 @@ Uint8 Game::dropItem()
|
|||||||
// Crea un objeto item
|
// Crea un objeto item
|
||||||
void Game::createItem(Uint8 type, float x, float y)
|
void Game::createItem(Uint8 type, float x, float y)
|
||||||
{
|
{
|
||||||
Item *i = new Item(mRenderer, mAsset, type, x, y);
|
Item *item = new Item(mRenderer, mAsset, type, x, y);
|
||||||
items.push_back(i);
|
items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacia el vector de items
|
// Vacia el vector de items
|
||||||
|
|||||||
@@ -189,15 +189,12 @@ void Item::disable()
|
|||||||
|
|
||||||
// Actualiza el objeto a su posicion, animación y controla los contadores
|
// Actualiza el objeto a su posicion, animación y controla los contadores
|
||||||
void Item::update()
|
void Item::update()
|
||||||
{
|
|
||||||
if (enabled)
|
|
||||||
{
|
{
|
||||||
move();
|
move();
|
||||||
sprite->animate();
|
sprite->animate();
|
||||||
updateTimeToLive();
|
updateTimeToLive();
|
||||||
checkTimeToLive();
|
checkTimeToLive();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
void Item::updateTimeToLive()
|
void Item::updateTimeToLive()
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Item
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
|
||||||
AnimatedSprite *sprite; // Sprite con los graficos del objeto
|
AnimatedSprite *sprite; // Sprite con los graficos del objeto
|
||||||
LTexture *texture; // Objeto con los graficos del item
|
LTexture *texture; // Objeto con los graficos del item
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user