This commit is contained in:
MarcEricMartel 2023-12-13 14:06:22 -05:00
parent f509b01827
commit e31e670720
4 changed files with 12 additions and 6 deletions

View File

@ -272,6 +272,10 @@ std::string Player::GetUsername() const { return m_username; }
float Player::GetHP() const { return m_hp; } float Player::GetHP() const { return m_hp; }
void Player::SetHP(float hp) {
m_hp = hp;
}
void Player::Teleport(int& x, int& z) { void Player::Teleport(int& x, int& z) {
m_position.x -= x * CHUNK_SIZE_X; m_position.x -= x * CHUNK_SIZE_X;
m_position.z -= z * CHUNK_SIZE_Z; m_position.z -= z * CHUNK_SIZE_Z;

View File

@ -33,6 +33,7 @@ public:
Vector3f GetPOV() const; Vector3f GetPOV() const;
std::string GetUsername() const; std::string GetUsername() const;
float GetHP() const; float GetHP() const;
void SetHP(float hp);
void Teleport(int& x, int& z); void Teleport(int& x, int& z);
bool GetIsAirborne() const; bool GetIsAirborne() const;

View File

@ -117,10 +117,10 @@ Timestamp Connection::Run(World* world) {
if (m_input_manifest.size() < 2) if (m_input_manifest.size() < 2)
return tstamp; return tstamp;
if (player->AmIDead()) { //if (player->AmIDead()) {
m_input_manifest.clear(); // m_input_manifest.clear();
return tstamp; // return tstamp;
} //}
while (m_last_in < m_input_vector.size() - 1) { while (m_last_in < m_input_vector.size() - 1) {
in = m_input_vector.at(m_last_in + 1); in = m_input_vector.at(m_last_in + 1);
@ -131,7 +131,7 @@ Timestamp Connection::Run(World* world) {
if (m_shoot_acc > 0.) { if (m_shoot_acc > 0.) {
m_shoot_acc -= el; m_shoot_acc -= el;
if (m_shoot_acc < 0.) if (m_shoot_acc < 0.)
m_shoot_acc = 0; m_shoot_acc = 0.;
} }
player->SetDirection(in.direction); player->SetDirection(in.direction);

View File

@ -618,6 +618,7 @@ bool Engine::StartMultiplayerGame() {
//m_world.SetSeed(m_conn.getSeed()); //m_world.SetSeed(m_conn.getSeed());
m_world.SetSeed(9370707); m_world.SetSeed(9370707);
m_networkgame = true; m_networkgame = true;
m_player.m_username = m_username;
} }
else { else {
std::cout << "Erreur de connexion." << std::endl; std::cout << "Erreur de connexion." << std::endl;
@ -1513,7 +1514,7 @@ void Engine::Render(float elapsedTime) {
std::cout << sync.hp << std::endl; std::cout << sync.hp << std::endl;
m_otherplayerpos = sync.position; m_otherplayerpos = sync.position;
m_player.InflictDamage(sync.hp - m_player.GetHP()); m_player.SetHP(sync.hp);
Vector3f diff = sync.position - comp.position; Vector3f diff = sync.position - comp.position;