Jump and Shoot! 🎶
This commit is contained in:
		| @@ -276,11 +276,9 @@ 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; | ||||||
| } | } | ||||||
| bool Player::AmIDead() | bool Player::GetIsAirborne() const { return m_airborne; } | ||||||
| { |  | ||||||
| 	return m_hp <= 0; |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | bool Player::AmIDead() { return m_hp <= 0; } | ||||||
|  |  | ||||||
| void Player::InflictDamage(float hitPoints) { | void Player::InflictDamage(float hitPoints) { | ||||||
| 	m_hp -= hitPoints; | 	m_hp -= hitPoints; | ||||||
|   | |||||||
| @@ -35,6 +35,7 @@ public: | |||||||
| 	float GetHP() const; | 	float GetHP() const; | ||||||
| 	void Teleport(int& x, int& z); | 	void Teleport(int& x, int& z); | ||||||
|  |  | ||||||
|  | 	bool GetIsAirborne() const; | ||||||
| 	bool AmIDead(); | 	bool AmIDead(); | ||||||
| 	void InflictDamage(float hitPoints); | 	void InflictDamage(float hitPoints); | ||||||
| 	int getScore() const; | 	int getScore() const; | ||||||
|   | |||||||
| @@ -144,8 +144,8 @@ Timestamp Connection::Run(World* world) { | |||||||
| 			player->Killer = GetHash(true); | 			player->Killer = GetHash(true); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		out.states.jumping = abs(player->GetVelocity().y) > .2f; | 		out.states.jumping = player->GetIsAirborne(); //abs(player->GetVelocity().y) > .2f; | ||||||
| 		out.states.running = player->GetVelocity().Length() > .3f; | 		out.states.running = player->GetVelocity().Length() > .5f; | ||||||
| 		out.states.still = !out.states.running; | 		out.states.still = !out.states.running; | ||||||
| 		out.states.hit = player->m_hit; | 		out.states.hit = player->m_hit; | ||||||
| 		player->m_hit = false; | 		player->m_hit = false; | ||||||
|   | |||||||
| @@ -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); | 			m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f); | ||||||
| 			died = true; | 			died = true; | ||||||
| 		} | 		} | ||||||
| 		if (m_player.GetPosition().y < -15.f || died) { | 		if (m_player.GetPosition().y < -21.f || died) { | ||||||
| 			died = false; | 			died = false; | ||||||
| 			std::string user = m_player.m_username.append(" (Dead)"); | 			std::string user = m_player.m_username.append(" (Dead)"); | ||||||
| 			m_player = Player(Vector3f(.5, CHUNK_SIZE_Y + 1.7f, .5), 0, 0); | 			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]); | 						RemotePlayer* rt = static_cast<RemotePlayer*>(m_players[out.id]); | ||||||
| 						rt->Feed(out); | 						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; | 					break; | ||||||
| 				case CHUNKMOD: | 				case CHUNKMOD: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user