SQC-15_online #1

Merged
memartel merged 349 commits from SQC-15_online into master 2023-12-10 17:41:26 -05:00
4 changed files with 34 additions and 2 deletions
Showing only changes of commit b943a268ae - Show all commits

View File

@@ -4,7 +4,7 @@
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) { 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_velocity = Vector3f(0, 0, 0);
m_airborne = true; m_airborne = true;
m_hp = 0.75f; //TODO: Remettre <20> 1.0f m_hp = 1.0f; //TODO: Remettre <20> 1.0f
m_username = "Zelda Bee-Bop56"; m_username = "Zelda Bee-Bop56";
} }
@@ -206,3 +206,19 @@ 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;
} }
void Player::InflictDamage(Player playerHit, float hitPoints)
{
playerHit.m_hp -= hitPoints;
if (playerHit.GetHP() <= 0)
{ // Quand l'autre joueur est mort.
}
}

View File

@@ -26,6 +26,9 @@ public:
float GetHP() const; float GetHP() const;
void Teleport(int& x, int& z); void Teleport(int& x, int& z);
void InflictDamage(Player playerHit, float hitPoints);
private: private:
Vector3f m_position; Vector3f m_position;
Vector3f m_velocity; Vector3f m_velocity;

View File

@@ -131,6 +131,12 @@ void Engine::LoadResource() {
void Engine::UnloadResource() {} void Engine::UnloadResource() {}
void Engine::InstantDamage()
{
m_player.InflictDamage(m_player, 0.10f);
m_damage = false;
}
void Engine::SystemNotification(std::string systemLog) { void Engine::SystemNotification(std::string systemLog) {
std::string message = ""; std::string message = "";
@@ -536,7 +542,8 @@ void Engine::Render(float elapsedTime) {
m_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo); m_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo);
if (m_isSkybox) m_skybox.Render(skybox); if (m_isSkybox) m_skybox.Render(skybox);
if (m_damage)
InstantDamage();
ProcessNotificationQueue(); ProcessNotificationQueue();
DrawHud(elapsedTime, bloc); DrawHud(elapsedTime, bloc);
@@ -604,6 +611,9 @@ void Engine::KeyPressEvent(unsigned char key) {
break; break;
case 8: // I - Ignorer case 8: // I - Ignorer
break; break;
case 9: // J - InstantDamage
m_damage = true;
break;
case 17: // R - Ignorer case 17: // R - Ignorer
break; break;
case 19: // T - Ignorer case 19: // T - Ignorer

View File

@@ -43,6 +43,7 @@ private:
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
void InstantDamage();
void SystemNotification(std::string systemLog); void SystemNotification(std::string systemLog);
void KillNotification(Player killer, Player killed); void KillNotification(Player killer, Player killed);
void DisplayNotification(std::string message); void DisplayNotification(std::string message);
@@ -83,6 +84,8 @@ private:
int m_renderCount = 0; int m_renderCount = 0;
int m_countdown = COUNTDOWN; int m_countdown = COUNTDOWN;
bool m_damage = false;
bool m_wireframe = false; bool m_wireframe = false;
bool m_isSkybox = true; bool m_isSkybox = true;
bool m_block = false; bool m_block = false;