Jump and Shoot! 🎶

This commit is contained in:
MarcEricMartel 2023-12-07 12:32:36 -05:00
parent e9e2a56be6
commit 74b808f46b
4 changed files with 9 additions and 7 deletions

View File

@ -276,11 +276,9 @@ void Player::Teleport(int& x, int& z) {
m_position.x -= x * CHUNK_SIZE_X;
m_position.z -= z * CHUNK_SIZE_Z;
}
bool Player::AmIDead()
{
return m_hp <= 0;
}
bool Player::GetIsAirborne() const { return m_airborne; }
bool Player::AmIDead() { return m_hp <= 0; }
void Player::InflictDamage(float hitPoints) {
m_hp -= hitPoints;

View File

@ -35,6 +35,7 @@ public:
float GetHP() const;
void Teleport(int& x, int& z);
bool GetIsAirborne() const;
bool AmIDead();
void InflictDamage(float hitPoints);
int getScore() const;

View File

@ -144,8 +144,8 @@ Timestamp Connection::Run(World* world) {
player->Killer = GetHash(true);
}
out.states.jumping = abs(player->GetVelocity().y) > .2f;
out.states.running = player->GetVelocity().Length() > .3f;
out.states.jumping = player->GetIsAirborne(); //abs(player->GetVelocity().y) > .2f;
out.states.running = player->GetVelocity().Length() > .5f;
out.states.still = !out.states.running;
out.states.hit = player->m_hit;
player->m_hit = false;

View File

@ -1319,7 +1319,7 @@ void Engine::Render(float elapsedTime) {
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
died = true;
}
if (m_player.GetPosition().y < -15.f || died) {
if (m_player.GetPosition().y < -21.f || died) {
died = false;
std::string user = m_player.m_username.append(" (Dead)");
m_player = Player(Vector3f(.5, CHUNK_SIZE_Y + 1.7f, .5), 0, 0);
@ -1432,6 +1432,9 @@ void Engine::Render(float elapsedTime) {
}
RemotePlayer* rt = static_cast<RemotePlayer*>(m_players[out.id]);
rt->Feed(out);
if (rt->AmIDead()) {
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
}
}
break;
case CHUNKMOD: