fix bullet owner bug
This commit is contained in:
@@ -34,7 +34,7 @@ void Bullet::init(int x, int y, int kind, bool poweredUp, int owner, LTexture *t
|
|||||||
mKind = kind;
|
mKind = kind;
|
||||||
|
|
||||||
// Identificador del dueño del objeto
|
// Identificador del dueño del objeto
|
||||||
mOwner = -1;
|
mOwner = owner;
|
||||||
|
|
||||||
// Textura con los gráficos del objeto
|
// Textura con los gráficos del objeto
|
||||||
mSprite->setTexture(texture);
|
mSprite->setTexture(texture);
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ void Director::init()
|
|||||||
mInput1->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
mInput1->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
||||||
mInput1->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
mInput1->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
||||||
#endif
|
#endif
|
||||||
mInput1->bindKey(INPUT_BUTTON_4, SDL_SCANCODE_ESCAPE); // PAUSE
|
mInput1->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
||||||
mInput1->bindKey(INPUT_BUTTON_5, SDL_SCANCODE_ESCAPE); // ESCAPE
|
mInput1->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); // ESCAPE
|
||||||
|
|
||||||
mInput2->bindGameController(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
mInput2->bindGameController(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
mInput2->bindGameController(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
mInput2->bindGameController(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
@@ -108,8 +108,8 @@ void Director::init()
|
|||||||
mInput2->bindGameController(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
mInput2->bindGameController(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
||||||
mInput2->bindGameController(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
mInput2->bindGameController(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
||||||
mInput2->bindGameController(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
mInput2->bindGameController(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
||||||
mInput2->bindGameController(INPUT_BUTTON_4, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
mInput2->bindGameController(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||||
mInput2->bindGameController(INPUT_BUTTON_5, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
mInput2->bindGameController(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
|
|||||||
@@ -2107,7 +2107,7 @@ void Game::checkBulletBalloonCollision()
|
|||||||
if (checkCollision(mBalloon[i]->getCollider(), mBullet[j]->getCollider()))
|
if (checkCollision(mBalloon[i]->getCollider(), mBullet[j]->getCollider()))
|
||||||
{
|
{
|
||||||
// Otorga los puntos correspondientes al globo al jugador que disparó la bala
|
// Otorga los puntos correspondientes al globo al jugador que disparó la bala
|
||||||
const int index = mBullet[j]->getOwner();
|
int index = mBullet[j]->getOwner();
|
||||||
mPlayer[index]->incScoreMultiplier();
|
mPlayer[index]->incScoreMultiplier();
|
||||||
mPlayer[index]->addScore(Uint32(mBalloon[i]->getScore() * mPlayer[index]->getScoreMultiplier()));
|
mPlayer[index]->addScore(Uint32(mBalloon[i]->getScore() * mPlayer[index]->getScoreMultiplier()));
|
||||||
//setScore(mPlayer[index]->getScore());
|
//setScore(mPlayer[index]->getScore());
|
||||||
@@ -2727,7 +2727,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de pausa
|
// Comprueba el input de pausa
|
||||||
if (mInput[0]->checkInput(INPUT_PAUSE, REPEAT_FALSE))
|
if (mInput[0]->checkInput(INPUT_BUTTON_PAUSE, REPEAT_FALSE))
|
||||||
mSection.name = PROG_SECTION_TITLE;
|
mSection.name = PROG_SECTION_TITLE;
|
||||||
|
|
||||||
// Incrementa el contador de la demo
|
// Incrementa el contador de la demo
|
||||||
@@ -2811,7 +2811,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de pausa
|
// Comprueba el input de pausa
|
||||||
if (mInput[i]->checkInput(INPUT_CANCEL, REPEAT_FALSE))
|
if (mInput[i]->checkInput(INPUT_BUTTON_PAUSE, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
mSection.subsection = GAME_SECTION_PAUSE;
|
mSection.subsection = GAME_SECTION_PAUSE;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Input::Input(int source)
|
Input::Input(int source)
|
||||||
{
|
{
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
for (int i = 0; i < 15; i++)
|
for (int i = 0; i < 17; i++)
|
||||||
{
|
{
|
||||||
mKeyBindings[i].scancode = 0;
|
mKeyBindings[i].scancode = 0;
|
||||||
mKeyBindings[i].active = false;
|
mKeyBindings[i].active = false;
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#define INPUT_BUTTON_6 12
|
#define INPUT_BUTTON_6 12
|
||||||
#define INPUT_BUTTON_7 13
|
#define INPUT_BUTTON_7 13
|
||||||
#define INPUT_BUTTON_8 14
|
#define INPUT_BUTTON_8 14
|
||||||
|
#define INPUT_BUTTON_PAUSE 15
|
||||||
|
#define INPUT_BUTTON_ESCAPE 16
|
||||||
|
|
||||||
#define REPEAT_TRUE true
|
#define REPEAT_TRUE true
|
||||||
#define REPEAT_FALSE false
|
#define REPEAT_FALSE false
|
||||||
@@ -35,14 +37,14 @@ private:
|
|||||||
Uint8 scancode; // Scancode asociado
|
Uint8 scancode; // Scancode asociado
|
||||||
bool active; // Indica si está activo
|
bool active; // Indica si está activo
|
||||||
};
|
};
|
||||||
keyBindings_t mKeyBindings[15]; // Vector con las teclas asociadas a los inputs predefinidos
|
keyBindings_t mKeyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
|
|
||||||
struct GameControllerBindings_t
|
struct GameControllerBindings_t
|
||||||
{
|
{
|
||||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||||
bool active; // Indica si está activo
|
bool active; // Indica si está activo
|
||||||
};
|
};
|
||||||
GameControllerBindings_t mGameControllerBindings[15]; // Vector con las teclas asociadas a los inputs predefinidos
|
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
|
|
||||||
SDL_GameController *mGameController; // Manejador para el mando
|
SDL_GameController *mGameController; // Manejador para el mando
|
||||||
//SDL_Haptic *mControllerHaptic; // Manejador para el mando con vibración
|
//SDL_Haptic *mControllerHaptic; // Manejador para el mando con vibración
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void Player::init(float x, int y, LTexture *textureLegs, LTexture *textureBody,
|
|||||||
mScore = 0;
|
mScore = 0;
|
||||||
|
|
||||||
// Establece el multiplicador de puntos inicial
|
// Establece el multiplicador de puntos inicial
|
||||||
mScoreMultiplier = 1.0f;
|
mScoreMultiplier = 2.0f;
|
||||||
|
|
||||||
// Inicia el contador para la cadencia de disparo
|
// Inicia el contador para la cadencia de disparo
|
||||||
mCooldown = 10;
|
mCooldown = 10;
|
||||||
@@ -593,18 +593,18 @@ void Player::setScoreMultiplier(float value)
|
|||||||
void Player::incScoreMultiplier()
|
void Player::incScoreMultiplier()
|
||||||
{
|
{
|
||||||
if (mScoreMultiplier < 5.0f)
|
if (mScoreMultiplier < 5.0f)
|
||||||
{
|
|
||||||
mScoreMultiplier += 0.1f;
|
mScoreMultiplier += 0.1f;
|
||||||
}
|
else
|
||||||
|
mScoreMultiplier = 5.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrementa el valor de la variable hasta un mínimo
|
// Decrementa el valor de la variable hasta un mínimo
|
||||||
void Player::decScoreMultiplier()
|
void Player::decScoreMultiplier()
|
||||||
{
|
{
|
||||||
if (mScoreMultiplier > 1.0f)
|
if (mScoreMultiplier > 1.0f)
|
||||||
{
|
|
||||||
mScoreMultiplier -= 0.1f;
|
mScoreMultiplier -= 0.1f;
|
||||||
}
|
else
|
||||||
|
mScoreMultiplier = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
|
|||||||
Reference in New Issue
Block a user