Merge branch 'master' into SQC-15_online

This commit is contained in:
MarcEricMartel
2023-12-15 07:13:16 -05:00
9 changed files with 334 additions and 108 deletions

View File

@@ -4,14 +4,15 @@
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) {
m_velocity = Vector3f(0, 0, 0);
m_airborne = true;
m_hp = 1.0f; //TODO: Remettre <20> 1.0f
m_hp = 1.0f;
m_sensitivity = 0.5f;
m_username = "Zelda Bee-Bop56";
}
Player::~Player() {}
void Player::TurnLeftRight(float value) {
m_rotY += value;
void Player::TurnLeftRight(float value, float sensitivity) {
m_rotY += value * sensitivity;
if (m_rotY > 360) m_rotY = 0;
else if (m_rotY < -360) m_rotY = 0;
@@ -25,8 +26,8 @@ void Player::TurnLeftRight(float value) {
m_direction.Normalize();
}
void Player::TurnTopBottom(float value) {
m_rotX += value;
void Player::TurnTopBottom(float value, float sensitivity) {
m_rotX += value * sensitivity;
if (m_rotX > 80) m_rotX = 80;
else if (m_rotX < -80) m_rotX = -80;
@@ -78,7 +79,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
}
if (shoot) // Recoil!
TurnTopBottom(-1);
TurnTopBottom(-1, 1.0f);
return delta;
}
@@ -270,6 +271,18 @@ Vector3f Player::GetDirection() const { return m_direction; }
std::string Player::GetUsername() const { return m_username; }
void Player::SetUsername(std::string username) {
m_username = username;
}
float Player::GetSensitivity() const {
return m_sensitivity;
}
void Player::SetSensitivity(float sensitivity) {
m_sensitivity = sensitivity;
}
float Player::GetHP() const { return m_hp; }
void Player::SetHP(float hp) {

View File

@@ -16,8 +16,8 @@ public:
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
~Player();
void TurnLeftRight(float value);
void TurnTopBottom(float value);
void TurnLeftRight(float value, float sensitivity);
void TurnTopBottom(float value, float sensitivity);
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
void GetBooster(Booster boosttype);
@@ -32,6 +32,9 @@ public:
Vector3f GetVelocity() const;
Vector3f GetPOV() const;
std::string GetUsername() const;
void SetUsername(std::string username);
float GetSensitivity() const;
void SetSensitivity(float sensitivity);
float GetHP() const;
void SetHP(float hp);
void Teleport(int& x, int& z);
@@ -64,6 +67,7 @@ protected:
float timeboostspeed;
float timeboostdamage;
float timeboostinvincible;
float m_sensitivity;
float m_hp;
@@ -72,8 +76,6 @@ protected:
bool boostdamage;
bool boostinvincible;
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
};
#endif //_PLAYER_H__