Merge branch 'SQC19_Booster' into online_boosts

This commit is contained in:
MarcEricMartel
2023-12-18 11:19:52 -05:00
15 changed files with 216 additions and 135 deletions

View File

@@ -68,8 +68,8 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
delta.x *= .6f;
delta.z *= .6f;
if ((jump || shoot ) && !m_airborne) {
delta.y += jump? .32f: shoot? .1f : 0.f;
if ((jump || shoot) && !m_airborne) {
delta.y += jump ? .32f : shoot ? .1f : 0.f;
m_airborne = true;
}
if (boostspeed)
@@ -84,7 +84,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
return delta;
}
Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime, Booster booster_table[]) {
Player::Sound snd = Player::Sound::NOSOUND;
static float timing = 0.f;
/* Gestion de collisions */
@@ -184,33 +184,50 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
else isStep = false;
m_POV = m_position.y;
m_POV += m_airborne ? 0 : (sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) * .2f;
TakeBooster(booster_table, elapsedTime);
RemoveBooster(elapsedTime);
return snd;
}
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
if (rel) transformation.ApplyTranslation(-GetPOV());
}
void Player::GetBooster(Booster boosttype)
void Player::TakeBooster(Booster booster_table[], float elapsedtime)
{
if (boosttype == SPEED)
Vector3f playerpos = GetPosition();
for (int i = 0; i < sizeof(booster_table); i++)
{
Vector3f pos = booster_table[i].GetPosition();
if (abs(playerpos.x - pos.x) <= 0.5f && abs(playerpos.y - pos.y) <= 1.0f && abs(playerpos.z - pos.z) <= 0.5f && booster_table[i].GetAvailability() == true)
{
GetBooster(booster_table[i].GetType(), elapsedtime);
booster_table[i].SetAvailability(false);
break;
}
}
}
void Player::GetBooster(BOOST_TYPE boosttype, float elapsedtime)
{
if (boosttype == BTYPE_SPEED)
{
boostspeed = true;
timeboostspeed = 0;
}
if (boosttype == HEAL)
if (boosttype == BTYPE_HEAL)
{
m_hp = 100;
m_hp = 1.0f;
}
if (boosttype == DAMAGE)
if (boosttype == BTYPE_DAMAGE)
{
boostdamage = true;
timeboostdamage = 0;
}
if (boosttype == INVINCIBLE)
if (boosttype == BTYPE_INVINCIBLE)
{
boostinvincible = true;
boostinvincible = 0;
@@ -221,19 +238,17 @@ void Player::RemoveBooster(float elapsedtime)
if (boostspeed)
{
timeboostspeed += elapsedtime;
if (timeboostspeed >= TIME_SPEED_BOOST)
if (timeboostspeed >= TIME_SPEED_BOOST && boostspeed == true)
boostspeed = false;
}
if (boostdamage)
{
timeboostdamage += elapsedtime;
if (timeboostdamage >= TIME_DAMAGE_BOOST)
if (timeboostdamage >= TIME_DAMAGE_BOOST && boostdamage == true)
boostdamage = false;
}
if (boostinvincible)
{
timeboostinvincible += elapsedtime;
if (timeboostinvincible >= TIME_INVINCIBLE_BOOST)
if (timeboostinvincible >= TIME_INVINCIBLE_BOOST && boostinvincible == true)
boostinvincible = false;
}
}