++Performance;
This commit is contained in:
		| @@ -64,25 +64,25 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum | ||||
| 	return delta; | ||||
| } | ||||
|  | ||||
| void Player::ApplyPhysics(Vector3f input, World world, float elapsedTime, Audio* audio) { | ||||
| void Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime, Audio* audio) { | ||||
| 	static irrklang::ISound* step; // Pour les sons de pas. | ||||
| 	static float timing = 0.f; | ||||
| 	/* Gestion de collisions */ | ||||
| 	BlockType bt1, bt2, bt3; | ||||
|  | ||||
| 	bt1 = world.BlockAt(GetPosition().x, GetPosition().y + input.y, GetPosition().z); | ||||
| 	bt2 = world.BlockAt(GetPosition().x, GetPosition().y + input.y - 0.9f, GetPosition().z); | ||||
| 	bt3 = world.BlockAt(GetPosition().x, GetPosition().y + input.y - 1.7f, GetPosition().z); | ||||
| 	bt1 = world->BlockAt(GetPosition().x, GetPosition().y + input.y, GetPosition().z); | ||||
| 	bt2 = world->BlockAt(GetPosition().x, GetPosition().y + input.y - 0.9f, GetPosition().z); | ||||
| 	bt3 = world->BlockAt(GetPosition().x, GetPosition().y + input.y - 1.7f, GetPosition().z); | ||||
| 	if ((bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) && m_position.y < 129.7f) { | ||||
| 		bt1 = world.BlockAt(GetPosition().x, GetPosition().y + .3f, GetPosition().z); | ||||
| 		bt1 = world->BlockAt(GetPosition().x, GetPosition().y + .3f, GetPosition().z); | ||||
| 		if (bt1 == BTYPE_AIR) m_position.y = (int)m_position.y + .7f; | ||||
| 		m_velocity.y = input.y = 0; | ||||
| 		m_airborne = false; | ||||
| 	} | ||||
| 	else { | ||||
| 		if (abs(m_velocity.y) < 1.1f) m_velocity.y += input.y - 1.1f * elapsedTime; | ||||
| 		bt3 = world.BlockAt(GetPosition().x, GetPosition().y + m_velocity.y - 1.7f, GetPosition().z); | ||||
| 		bt1 = world.BlockAt(GetPosition().x, GetPosition().y + .3f, GetPosition().z); | ||||
| 		bt3 = world->BlockAt(GetPosition().x, GetPosition().y + m_velocity.y - 1.7f, GetPosition().z); | ||||
| 		bt1 = world->BlockAt(GetPosition().x, GetPosition().y + .3f, GetPosition().z); | ||||
| 		if (bt3 != BTYPE_AIR) { | ||||
| 			m_velocity.y = 0; | ||||
| 			if (timing == 0.f) { | ||||
| @@ -100,17 +100,17 @@ void Player::ApplyPhysics(Vector3f input, World world, float elapsedTime, Audio* | ||||
| 	if (timing > 0.f) timing -= elapsedTime; | ||||
| 	if (timing < 0.f) timing = 0.f; | ||||
|  | ||||
| 	bt1 = world.BlockAt(GetPosition().x + input.x, GetPosition().y, GetPosition().z); | ||||
| 	bt2 = world.BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z); | ||||
| 	bt3 = world.BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z); | ||||
| 	bt1 = world->BlockAt(GetPosition().x + input.x, GetPosition().y, GetPosition().z); | ||||
| 	bt2 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z); | ||||
| 	bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z); | ||||
| 	if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { | ||||
| 		input.x = m_velocity.x = 0; | ||||
| 		m_velocity.z *= .5f; | ||||
| 	} | ||||
|  | ||||
| 	bt1 = world.BlockAt(GetPosition().x, GetPosition().y, GetPosition().z + input.z); | ||||
| 	bt2 = world.BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z); | ||||
| 	bt3 = world.BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z); | ||||
| 	bt1 = world->BlockAt(GetPosition().x, GetPosition().y, GetPosition().z + input.z); | ||||
| 	bt2 = world->BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z); | ||||
| 	bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z); | ||||
| 	if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { | ||||
| 		input.z = m_velocity.z = 0; | ||||
| 		m_velocity.x *= .5f; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user