Compare commits
	
		
			97 Commits
		
	
	
		
			SQC-15_onl
			...
			DemoReleas
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 82747990d9 | ||
|  | 0782f37e0a | ||
|  | 75f745efb8 | ||
|  | 6efda6122d | ||
|  | 678776d6e6 | ||
|  | 4df53a5f9b | ||
|  | 90892ce7d3 | ||
|  | 5e1e8366ce | ||
|  | 7f9462881c | ||
|  | 2eacc0477b | ||
|  | 745f40bc37 | ||
|  | ba6b383251 | ||
|  | 1065357e70 | ||
|  | 4a4f353250 | ||
|  | 63d1f997ca | ||
|  | da94565c3e | ||
|  | 1c2a691638 | ||
|  | 7803f46a6b | ||
|  | 38bab49806 | ||
|  | 547d0fb3f8 | ||
|  | dec9da6395 | ||
|  | f564e37544 | ||
|  | ca1ab7301d | ||
|  | 7a7ba94cbd | ||
|  | ac50a044c7 | ||
|  | 8062d8e31d | ||
|  | 4d278dfdea | ||
|  | da9fd2477d | ||
|  | de8fe3c1c5 | ||
|  | 5ee3fd143b | ||
|  | 77a982b1fa | ||
|  | e4316e7d8d | ||
|  | 935a977bdf | ||
|  | 82bae1c21a | ||
|  | 58c06f9f84 | ||
|  | 8e77565bb4 | ||
|  | e5b0c742dd | ||
|  | 1af88ba3e3 | ||
|  | 383a19cbd2 | ||
|  | 67270a0b21 | ||
|  | b101add0e7 | ||
|  | 0a0c70883b | ||
|  | 879f93e2cd | ||
|  | f7934be7f9 | ||
|  | 0b4546eee9 | ||
|  | 6ba316aa2d | ||
|  | bb247d0afe | ||
|  | 26d03ca5cc | ||
|  | b8899b8f86 | ||
|  | 325c6b60f9 | ||
|  | 7b350fa403 | ||
|  | 71691c55c8 | ||
|  | 49374a7dea | ||
|  | 5a3ce00cb2 | ||
|  | 136f589975 | ||
|  | 6d4f592278 | ||
|  | 37a86d42a3 | ||
|  | a08a6c7db3 | ||
|  | 2f3260b16a | ||
|  | 08204934c8 | ||
|  | 74875709af | ||
|  | 28dc760cba | ||
|  | c7c38ed44d | ||
|  | 53e0af3f94 | ||
|  | a11c52cf77 | ||
|  | b1fc9d7d92 | ||
|  | a85c5cc626 | ||
|  | 4c3803c02e | ||
|  | 5e09305398 | ||
|  | fd1fe66d13 | ||
|  | edebad86a6 | ||
|  | 2dbaf84844 | ||
|  | e31e670720 | ||
|  | d8cbc27ca9 | ||
|  | c801877a0c | ||
|  | f4347d35df | ||
|  | f509b01827 | ||
|  | 18d6d58203 | ||
|  | 83fc600ce2 | ||
|  | 0e45b2b81e | ||
|  | d3c6353f17 | ||
|  | 8fbb92ec5b | ||
|  | 64655856e9 | ||
|  | a6b6ac870a | ||
|  | 5ef6ab5006 | ||
|  | 7ffccc8bf8 | ||
|  | c9ebfd348c | ||
|  | ae247a58a8 | ||
|  | 2f53f74ca9 | ||
|  | 3d0b35123a | ||
|  | aacfb880f0 | ||
|  | 6c68114fbb | ||
|  | b840e3ad19 | ||
|  | 7a30e43001 | ||
|  | c099a3b8eb | ||
|  | 7498076d7a | ||
|  | 7c1f70646a | 
| @@ -48,7 +48,7 @@ | |||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||||
|     <ConfigurationType>StaticLibrary</ConfigurationType> |     <ConfigurationType>StaticLibrary</ConfigurationType> | ||||||
|     <UseDebugLibraries>false</UseDebugLibraries> |     <UseDebugLibraries>false</UseDebugLibraries> | ||||||
|     <PlatformToolset>ClangCL</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> |     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||||
|     <CharacterSet>Unicode</CharacterSet> |     <CharacterSet>Unicode</CharacterSet> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   | |||||||
| @@ -3,26 +3,33 @@ | |||||||
|  |  | ||||||
| Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {} | Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {} | ||||||
|  |  | ||||||
| Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {} | Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id) : m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id, bool canhurt): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id), m_canhurt(canhurt) {} | ||||||
|  |  | ||||||
| Bullet::~Bullet() {} | Bullet::~Bullet() {} | ||||||
|  |  | ||||||
| bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> mapPlayer, netprot::ChunkMod** chunkmod) { | bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> mapPlayer, netprot::ChunkMod** chunkmod) { | ||||||
| 	int max = 100 / perframe; | 	int max = 100 / perframe; | ||||||
| 	float damage = 0.057f; | 	float damage = 0.098f; | ||||||
| 	for (int x = 0; x < max; ++x) { | 	for (int x = 0; x < max; ++x) { | ||||||
| 		m_currentpos += m_velocity * elapsedtime; | 		m_currentpos += m_velocity * elapsedtime; | ||||||
|  |  | ||||||
| 		for (auto& [key, player] : mapPlayer) { | 		for (auto& [key, player] : mapPlayer) { | ||||||
|  | 			if (key == m_shooter_id) | ||||||
|  | 				continue; | ||||||
|  |  | ||||||
| 			bool hit = false; | 			bool hit = false; | ||||||
| 			if ((m_currentpos - player->GetPosition()).Length() < .6f) { | 			if ((m_currentpos - player->GetPosition()).Length() < 1.5f) { | ||||||
| 				hit = true; | 				hit = true; | ||||||
| 			} | 			} | ||||||
| 			if ((m_currentpos - player->GetPOV()).Length() < .2f) { | 			else if ((m_currentpos - player->GetPOV()).Length() < .7f) { | ||||||
| 				damage *= 2; // HEADSHOT! | 				damage *= 2; // HEADSHOT! | ||||||
| 				hit = true; | 				hit = true; | ||||||
| 			} | 			} | ||||||
| 			if (hit && !player->AmIDead()) { | 			if (hit && !player->AmIDead()) { | ||||||
|  | 				if (m_canhurt) | ||||||
| 					player->InflictDamage(damage); | 					player->InflictDamage(damage); | ||||||
| 				player->m_hit = true; | 				player->m_hit = true; | ||||||
|  |  | ||||||
| @@ -36,6 +43,7 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere | |||||||
| 		if (!world->ChunkAt(m_currentpos)) | 		if (!world->ChunkAt(m_currentpos)) | ||||||
| 			return true; | 			return true; | ||||||
| 		else if (world->BlockAt(m_currentpos) != BTYPE_AIR) { | 		else if (world->BlockAt(m_currentpos) != BTYPE_AIR) { | ||||||
|  | 			if (m_canhurt) { | ||||||
| 				if (chunkmod) { | 				if (chunkmod) { | ||||||
| 					using namespace netprot; | 					using namespace netprot; | ||||||
| 					*chunkmod = new ChunkMod(); | 					*chunkmod = new ChunkMod(); | ||||||
| @@ -45,6 +53,7 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				world->ChangeBlockAtPosition(BTYPE_AIR, m_currentpos); | 				world->ChangeBlockAtPosition(BTYPE_AIR, m_currentpos); | ||||||
|  | 			} | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true; | 		else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true; | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ class Bullet { | |||||||
| public: | public: | ||||||
| 	Bullet(Vector3f pos, Vector3f dir); | 	Bullet(Vector3f pos, Vector3f dir); | ||||||
| 	Bullet(Vector3f pos, Vector3f dir, uint64_t tid); | 	Bullet(Vector3f pos, Vector3f dir, uint64_t tid); | ||||||
|  | 	Bullet(Vector3f pos, Vector3f dir, uint64_t tid, bool canhurt); | ||||||
| 	~Bullet(); | 	~Bullet(); | ||||||
|  |  | ||||||
| 	bool Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> m_mapPlayer, netprot::ChunkMod** chunkmod); | 	bool Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> m_mapPlayer, netprot::ChunkMod** chunkmod); | ||||||
| @@ -28,6 +29,8 @@ private: | |||||||
| 			 m_velocity; | 			 m_velocity; | ||||||
| 	uint64_t m_shooter_id = 0; | 	uint64_t m_shooter_id = 0; | ||||||
|  |  | ||||||
|  | 	bool m_canhurt = true; | ||||||
|  | 	 | ||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,7 +35,10 @@ | |||||||
| #define TIME_DAMAGE_BOOST 10	//secondes | #define TIME_DAMAGE_BOOST 10	//secondes | ||||||
| #define TIME_INVINCIBLE_BOOST 4	//secondes | #define TIME_INVINCIBLE_BOOST 4	//secondes | ||||||
| #define STRENGTH_SPEED_BOOST 10	//Pourcentage | #define STRENGTH_SPEED_BOOST 10	//Pourcentage | ||||||
| #define BULLET_TIME .1 | #define BULLET_TIME .2 //secondes | ||||||
|  |  | ||||||
|  | #define SYNC_ACC 600  // ms | ||||||
|  | #define CMOD_ACC 1000  // ms | ||||||
|  |  | ||||||
| typedef uint8_t BlockType; | typedef uint8_t BlockType; | ||||||
| enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST }; | enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST }; | ||||||
|   | |||||||
| @@ -4,14 +4,15 @@ | |||||||
| 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 = 1.0f; //TODO: Remettre <20> 1.0f | 	m_hp = 1.0f; | ||||||
|  | 	m_sensitivity = 0.5f; | ||||||
| 	m_username = "Zelda Bee-Bop56"; | 	m_username = "Zelda Bee-Bop56"; | ||||||
| } | } | ||||||
|  |  | ||||||
| Player::~Player() {} | Player::~Player() {} | ||||||
|  |  | ||||||
| void Player::TurnLeftRight(float value) { | void Player::TurnLeftRight(float value, float sensitivity) { | ||||||
| 	m_rotY += value; | 	m_rotY += value * sensitivity; | ||||||
| 	if (m_rotY > 360) m_rotY = 0; | 	if (m_rotY > 360) m_rotY = 0; | ||||||
| 	else if (m_rotY < -360) m_rotY = 0; | 	else if (m_rotY < -360) m_rotY = 0; | ||||||
|  |  | ||||||
| @@ -25,8 +26,8 @@ void Player::TurnLeftRight(float value) { | |||||||
| 	m_direction.Normalize(); | 	m_direction.Normalize(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void Player::TurnTopBottom(float value) { | void Player::TurnTopBottom(float value, float sensitivity) { | ||||||
| 	m_rotX += value; | 	m_rotX += value * sensitivity; | ||||||
| 	if (m_rotX > 80) m_rotX = 80; | 	if (m_rotX > 80) m_rotX = 80; | ||||||
| 	else if (m_rotX < -80) m_rotX = -80; | 	else if (m_rotX < -80) m_rotX = -80; | ||||||
|  |  | ||||||
| @@ -78,7 +79,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (shoot) // Recoil! | 	if (shoot) // Recoil! | ||||||
| 		TurnTopBottom(-1); | 		TurnTopBottom(-1, 1.0f); | ||||||
|  |  | ||||||
| 	return delta; | 	return delta; | ||||||
| } | } | ||||||
| @@ -122,35 +123,55 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi | |||||||
| 	bt1 = world->BlockAt(GetPosition().x + input.x, GetPosition().y, 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); | 	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); | 	bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z); | ||||||
| 	if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) { | 	if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { | ||||||
| 		if (input.x > 0) | 		//input.x = m_velocity.x = 0; | ||||||
| 			input.x = m_velocity.x = 0.5f; | 		m_velocity.y += .04f; | ||||||
| 		else |  | ||||||
| 			input.x = m_velocity.x = -0.5f; |  | ||||||
| 		m_velocity.y = 0.3; |  | ||||||
| 		m_velocity.z *= .5f; |  | ||||||
| 	} |  | ||||||
| 	else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { |  | ||||||
| 		input.x = m_velocity.x = 0; |  | ||||||
| 		m_velocity.z *= .5f; | 		m_velocity.z *= .5f; | ||||||
|  | 		m_velocity.x *= .5f; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	bt1 = world->BlockAt(GetPosition().x, GetPosition().y, 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); | 	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); | 	bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z); | ||||||
| 	if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) { | 	if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { | ||||||
| 		if (input.z > 0) | 		//input.z = m_velocity.z = 0; | ||||||
| 			input.z = m_velocity.z = 0.5f; | 		m_velocity.y += .04f; | ||||||
| 		else | 		m_velocity.z *= .5f;  | ||||||
| 			input.z = m_velocity.z = -0.5f; |  | ||||||
| 		m_velocity.y = 0.3; |  | ||||||
| 		m_velocity.x *= .5f; |  | ||||||
| 	} |  | ||||||
| 	else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { |  | ||||||
| 		input.z = m_velocity.z = 0; |  | ||||||
| 		m_velocity.x *= .5f; | 		m_velocity.x *= .5f; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	//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) { | ||||||
|  | 	//	if (input.x > 0) | ||||||
|  | 	//		input.x = m_velocity.x = 0.5f; | ||||||
|  | 	//	else | ||||||
|  | 	//		input.x = m_velocity.x = -0.5f; | ||||||
|  | 	//	m_velocity.y = 0.3; | ||||||
|  | 	//	m_velocity.z *= .5f; | ||||||
|  | 	//} | ||||||
|  | 	//else 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); | ||||||
|  | 	//if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) { | ||||||
|  | 	//	if (input.z > 0) | ||||||
|  | 	//		input.z = m_velocity.z = 0.5f; | ||||||
|  | 	//	else | ||||||
|  | 	//		input.z = m_velocity.z = -0.5f; | ||||||
|  | 	//	m_velocity.y = 0.3; | ||||||
|  | 	//	m_velocity.x *= .5f; | ||||||
|  | 	//} | ||||||
|  | 	//else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) { | ||||||
|  | 	//	input.z = m_velocity.z = 0; | ||||||
|  | 	//	m_velocity.x *= .5f; | ||||||
|  | 	//} | ||||||
|  |  | ||||||
| 	/* Fin gestion de collisions */ | 	/* Fin gestion de collisions */ | ||||||
| 	/* Gestion de la friction */ | 	/* Gestion de la friction */ | ||||||
|  |  | ||||||
| @@ -204,11 +225,7 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi | |||||||
| void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const { | void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const { | ||||||
| 	transformation.ApplyRotation(-m_rotX, 1, 0, 0); | 	transformation.ApplyRotation(-m_rotX, 1, 0, 0); | ||||||
| 	transformation.ApplyRotation(-m_rotY, 0, 1, 0); | 	transformation.ApplyRotation(-m_rotY, 0, 1, 0); | ||||||
| 	 |  | ||||||
|  |  | ||||||
| 	if (rel) transformation.ApplyTranslation(-GetPOV()); | 	if (rel) transformation.ApplyTranslation(-GetPOV()); | ||||||
| 	 |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void Player::GetBooster(Booster boosttype) | void Player::GetBooster(Booster boosttype) | ||||||
| @@ -270,8 +287,24 @@ Vector3f Player::GetDirection() const { return m_direction; } | |||||||
|  |  | ||||||
| std::string Player::GetUsername() const { return m_username; } | std::string Player::GetUsername() const { return m_username; } | ||||||
|  |  | ||||||
|  | void Player::SetUsername(std::string username) { | ||||||
|  | 	m_username = username; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | float Player::GetSensitivity() const { | ||||||
|  | 	return m_sensitivity; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void Player::SetSensitivity(float sensitivity) { | ||||||
|  | 	m_sensitivity = sensitivity; | ||||||
|  | } | ||||||
|  |  | ||||||
| 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; | ||||||
| @@ -285,9 +318,6 @@ void Player::InflictDamage(float hitPoints) { | |||||||
|  |  | ||||||
| 	if (m_hp < 0) | 	if (m_hp < 0) | ||||||
| 		m_hp == 0; | 		m_hp == 0; | ||||||
| 	//if (AmIDead()) |  | ||||||
| 	//{ // Quand le joueur est mort. |  | ||||||
| 	//} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int Player::getScore() const { return m_score; } | int Player::getScore() const { return m_score; } | ||||||
|   | |||||||
| @@ -16,8 +16,8 @@ public: | |||||||
| 	Player(const Vector3f& position, float rotX = 0, float rotY = 0); | 	Player(const Vector3f& position, float rotX = 0, float rotY = 0); | ||||||
| 	~Player(); | 	~Player(); | ||||||
|  |  | ||||||
| 	void TurnLeftRight(float value); | 	void TurnLeftRight(float value, float sensitivity); | ||||||
| 	void TurnTopBottom(float value); | 	void TurnTopBottom(float value, float sensitivity); | ||||||
| 	Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime); | 	Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime); | ||||||
| 	Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime); | 	Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime); | ||||||
| 	void GetBooster(Booster boosttype); | 	void GetBooster(Booster boosttype); | ||||||
| @@ -32,7 +32,11 @@ public: | |||||||
| 	Vector3f GetVelocity() const; | 	Vector3f GetVelocity() const; | ||||||
| 	Vector3f GetPOV() const; | 	Vector3f GetPOV() const; | ||||||
| 	std::string GetUsername() const; | 	std::string GetUsername() const; | ||||||
|  | 	void SetUsername(std::string username); | ||||||
|  | 	float GetSensitivity() const; | ||||||
|  | 	void SetSensitivity(float sensitivity); | ||||||
| 	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; | ||||||
| @@ -44,6 +48,8 @@ public: | |||||||
| 	std::string m_username; | 	std::string m_username; | ||||||
| 	bool m_hit = false; | 	bool m_hit = false; | ||||||
|  |  | ||||||
|  | 	bool Eulogy = false; | ||||||
|  |  | ||||||
| private: | private: | ||||||
| 	uint64_t getId() const; | 	uint64_t getId() const; | ||||||
|  |  | ||||||
| @@ -61,6 +67,7 @@ protected: | |||||||
| 	float timeboostspeed; | 	float timeboostspeed; | ||||||
| 	float timeboostdamage; | 	float timeboostdamage; | ||||||
| 	float timeboostinvincible; | 	float timeboostinvincible; | ||||||
|  | 	float m_sensitivity; | ||||||
|  |  | ||||||
| 	float m_hp; | 	float m_hp; | ||||||
|  |  | ||||||
| @@ -69,8 +76,6 @@ protected: | |||||||
| 	bool boostdamage; | 	bool boostdamage; | ||||||
| 	bool boostinvincible; | 	bool boostinvincible; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 	Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now); | 	Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now); | ||||||
| }; | }; | ||||||
| #endif //_PLAYER_H__ | #endif //_PLAYER_H__ | ||||||
|   | |||||||
| @@ -49,8 +49,6 @@ void World::RemoveChunk(int nbReduit) | |||||||
| 			if (x > WORLD_SIZE_X - nbReduit) | 			if (x > WORLD_SIZE_X - nbReduit) | ||||||
| 				chk = m_chunks.Remove(x, y); | 				chk = m_chunks.Remove(x, y); | ||||||
|  |  | ||||||
| 			// TODO: MakeDirty() les voisins pour qu'ils se redessinent. |  | ||||||
|  |  | ||||||
| 			if (!chk) | 			if (!chk) | ||||||
| 				continue; | 				continue; | ||||||
|  |  | ||||||
| @@ -167,7 +165,6 @@ void World::GetScope(unsigned int& x, unsigned int& y) { | |||||||
|  |  | ||||||
| void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) { | void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) { | ||||||
| 	UpdateWorld(player_pos, blockinfo); | 	UpdateWorld(player_pos, blockinfo); | ||||||
| 	//TransposeWorld(player_pos, bullets); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| netprot::ChunkMod* World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net) { | netprot::ChunkMod* World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net) { | ||||||
| @@ -258,7 +255,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST] | |||||||
| 	int side = 0; | 	int side = 0; | ||||||
| 	int threads = 0; | 	int threads = 0; | ||||||
| 	std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS]; | 	std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS]; | ||||||
| 	//std::future<void> delThList[THREADS_DELETE_CHUNKS]; |  | ||||||
| 	 | 	 | ||||||
| 	if (frameGenerate > 0) --frameGenerate; | 	if (frameGenerate > 0) --frameGenerate; | ||||||
| 	if (frameUpdate > 0) --frameUpdate; | 	if (frameUpdate > 0) --frameUpdate; | ||||||
| @@ -349,101 +345,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST] | |||||||
|  |  | ||||||
| 	side = 0; | 	side = 0; | ||||||
| 	threads = 0; | 	threads = 0; | ||||||
|  |  | ||||||
| 	//if (!frameUpdate) |  | ||||||
| 	//	while (side * CHUNK_SIZE_X <= VIEW_DISTANCE * 2) { |  | ||||||
| 	//		int tx = -side, ty = -side; |  | ||||||
|  |  | ||||||
| 	//		for (; tx <= side; ++tx) { |  | ||||||
| 	//			if (frameUpdate) |  | ||||||
| 	//				break; |  | ||||||
| 	//			unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z; |  | ||||||
| 	//			if (ChunkAt(chx, 1, chy) && |  | ||||||
| 	//				ChunkAt(chx, 1, chy)->IsDirty()) { |  | ||||||
| 	//				updateThList[threads++] = |  | ||||||
| 	//					std::async(std::launch::async, |  | ||||||
| 	//						[](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) { |  | ||||||
| 	//							chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); |  | ||||||
| 	//				if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; |  | ||||||
| 	//			} |  | ||||||
| 	//		} |  | ||||||
| 	//		for (; ty <= side; ++ty) { |  | ||||||
| 	//			if (frameUpdate) |  | ||||||
| 	//				break; |  | ||||||
| 	//			unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z; |  | ||||||
| 	//			if (ChunkAt(chx, 1, chy) && |  | ||||||
| 	//				ChunkAt(chx, 1, chy)->IsDirty()) { |  | ||||||
| 	//				updateThList[threads++] = |  | ||||||
| 	//					std::async(std::launch::async, |  | ||||||
| 	//						[](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) { |  | ||||||
| 	//							chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); |  | ||||||
| 	//				if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; |  | ||||||
| 	//			} |  | ||||||
| 	//		} |  | ||||||
| 	//		for (; tx >= -side; --tx) { |  | ||||||
| 	//			if (frameUpdate) |  | ||||||
| 	//				break; |  | ||||||
| 	//			unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z; |  | ||||||
| 	//			if (ChunkAt(chx, 1, chy) && |  | ||||||
| 	//				ChunkAt(chx, 1, chy)->IsDirty()) { |  | ||||||
| 	//				updateThList[threads++] = |  | ||||||
| 	//					std::async(std::launch::async, |  | ||||||
| 	//						[](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) { |  | ||||||
| 	//							chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); |  | ||||||
| 	//				if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; |  | ||||||
| 	//			} |  | ||||||
| 	//		} |  | ||||||
| 	//		for (; ty >= -side; --ty) { |  | ||||||
| 	//			if (frameUpdate) |  | ||||||
| 	//				break; |  | ||||||
| 	//			unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z; |  | ||||||
| 	//			if (ChunkAt(chx, 1, chy) && |  | ||||||
| 	//				ChunkAt(chx, 1, chy)->IsDirty()) { |  | ||||||
| 	//				updateThList[threads++] = |  | ||||||
| 	//					std::async(std::launch::async, |  | ||||||
| 	//						[](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) { |  | ||||||
| 	//							chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); |  | ||||||
| 	//				if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; |  | ||||||
| 	//			} |  | ||||||
| 	//		} |  | ||||||
| 	//		if (frameUpdate) |  | ||||||
| 	//			break; |  | ||||||
| 	//		++side; |  | ||||||
| 	//	} |  | ||||||
|  |  | ||||||
| 	//if (threads > 0) { |  | ||||||
| 	//	for (int i = 0; i < threads; ++i) { |  | ||||||
| 	//		updateThList[i].wait(); |  | ||||||
| 	//		Chunk* chunk = updateThList[i].get(); |  | ||||||
| 	//		chunk->FlushMeshToVBO(); |  | ||||||
| 	//	} |  | ||||||
| 	//} |  | ||||||
|  |  | ||||||
| 	threads = 0; |  | ||||||
|  |  | ||||||
| 	//int del = THREADS_DELETE_CHUNKS; |  | ||||||
| 	//while (!m_tbDeleted.empty() && del--) { // Moins rapide que le bout en dessous, mais -beaucoup- plus stable. |  | ||||||
| 	//	m_tbDeleted.back()->FlushVBO(); |  | ||||||
| 	//	m_tbDeleted.back()->~Chunk(); |  | ||||||
| 	//	m_tbDeleted.pop_back(); |  | ||||||
| 	//} |  | ||||||
|  |  | ||||||
| 	/*while (!m_tbDeleted.empty() && !frameDelete) { |  | ||||||
| 		if (m_tbDeleted.back()) { |  | ||||||
| 			m_tbDeleted.back()->FlushVBO(); |  | ||||||
| 			delThList[threads] = |  | ||||||
| 				std::async(std::launch::async, |  | ||||||
| 					[](Chunk* chunk) { delete chunk; }, m_tbDeleted.back()); |  | ||||||
| 			m_tbDeleted.pop_back(); |  | ||||||
| 			if (++threads > THREADS_DELETE_CHUNKS) frameDelete = FRAMES_DELETE_CHUNKS; |  | ||||||
| 		} |  | ||||||
| 		else m_tbDeleted.pop_back(); |  | ||||||
| 	}*/ |  | ||||||
|  |  | ||||||
| 	/*for (int x = 0; x < threads; ++x) { |  | ||||||
| 		delThList[x].wait(); |  | ||||||
| 		delThList[x].get(); |  | ||||||
| 	}*/ |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int World::GettbDeleted() const { return m_tbDeleted.size(); } | int World::GettbDeleted() const { return m_tbDeleted.size(); } | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ | |||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||||
|     <ConfigurationType>Application</ConfigurationType> |     <ConfigurationType>Application</ConfigurationType> | ||||||
|     <UseDebugLibraries>false</UseDebugLibraries> |     <UseDebugLibraries>false</UseDebugLibraries> | ||||||
|     <PlatformToolset>ClangCL</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> |     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||||
|     <CharacterSet>Unicode</CharacterSet> |     <CharacterSet>Unicode</CharacterSet> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   | |||||||
| @@ -59,7 +59,9 @@ void Connection::getPacks(SOCKET sock) { | |||||||
| 		switch (netprot::getType(pck, 1)) { | 		switch (netprot::getType(pck, 1)) { | ||||||
| 			using enum netprot::PACKET_TYPE; | 			using enum netprot::PACKET_TYPE; | ||||||
| 		case INPUT: | 		case INPUT: | ||||||
| 			if (Deserialize(&in, pck, &bsize)) { | 			if (player->AmIDead()) | ||||||
|  | 				break; | ||||||
|  | 			else if (Deserialize(&in, pck, &bsize)) { | ||||||
| 				m_input_manifest[in.timestamp] = in; | 				m_input_manifest[in.timestamp] = in; | ||||||
| 				m_input_vector.push_back(in); | 				m_input_vector.push_back(in); | ||||||
| 			} | 			} | ||||||
| @@ -77,8 +79,23 @@ void Connection::getPacks(SOCKET sock) { | |||||||
| void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer) { | void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer) { | ||||||
| 	static int outs = 0; | 	static int outs = 0; | ||||||
| 	static Timestamp last = 0; | 	static Timestamp last = 0; | ||||||
|  | 	static uint32_t lasttimer = timer; | ||||||
|  |  | ||||||
|  | 	if (m_output_vector.empty() && player->AmIDead()) { | ||||||
|  | 		if (timer != lasttimer) { | ||||||
|  | 			lasttimer = timer; | ||||||
|  | 			Sync sync; | ||||||
|  | 			sync.timestamp = sync.sid = m_loginfo.sid; | ||||||
|  | 			sync.hp = 0; | ||||||
|  | 			sync.ammo = -1; | ||||||
|  | 			sync.timer = timer; | ||||||
|  | 			sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	while (!m_output_vector.empty()) { | 	while (!m_output_vector.empty()) { | ||||||
| 		Output out = m_output_vector.front(); | 		Output out = m_output_vector.front(); | ||||||
|  | 		 | ||||||
| 		for (auto& [key, conn] : conns) { | 		for (auto& [key, conn] : conns) { | ||||||
| 			if (m_playinfo.id == conn->GetHash(false)) | 			if (m_playinfo.id == conn->GetHash(false)) | ||||||
| 				continue; | 				continue; | ||||||
| @@ -91,16 +108,23 @@ void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection* | |||||||
|  |  | ||||||
| 		outs += out.timestamp + last; | 		outs += out.timestamp + last; | ||||||
|  |  | ||||||
| 		if (outs >= 1000) { | 		static bool syncdead = false; | ||||||
| 			outs -= 1000; | 		bool dead = player->AmIDead(); | ||||||
|  |  | ||||||
|  | 		if (outs >= SYNC_ACC || (!syncdead && dead)) { | ||||||
| 			Sync sync; | 			Sync sync; | ||||||
| 			sync.hp = player->GetHP(); | 			outs -= SYNC_ACC; | ||||||
| 			sync.timestamp = out.timestamp; | 			sync.timestamp = out.timestamp; | ||||||
| 			sync.position = out.position; | 			sync.position = out.position; | ||||||
| 			sync.sid = m_loginfo.sid; | 			sync.sid = m_loginfo.sid; | ||||||
| 			sync.timer = timer; | 			sync.timer = timer; | ||||||
| 			sync.timestamp = out.timestamp; | 			sync.timestamp = out.timestamp; | ||||||
| 			sync.ammo = -1; | 			sync.ammo = -1; | ||||||
|  | 			sync.hp = player->GetHP(); | ||||||
|  | 			if (dead) { | ||||||
|  | 				sync.timestamp = m_loginfo.sid; | ||||||
|  | 				syncdead = true; | ||||||
|  | 			} | ||||||
| 			sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr); | 			sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -114,27 +138,33 @@ Timestamp Connection::Run(World* world) { | |||||||
| 	Timestamp tstamp = 0; | 	Timestamp tstamp = 0; | ||||||
| 	float el; | 	float el; | ||||||
|  |  | ||||||
| 	if (m_input_manifest.size() < 2) | 	bool dead = player->AmIDead(); | ||||||
|  |  | ||||||
|  | 	if (m_input_manifest.size() < 2 && !dead) | ||||||
| 		return tstamp; | 		return tstamp; | ||||||
|  |  | ||||||
| 	if (player->AmIDead()) { | 	while (m_last_in < m_input_vector.size() - 1 || dead) { | ||||||
| 		m_input_manifest.clear(); | 		if (!dead) { | ||||||
| 		return tstamp; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	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); | ||||||
| 			last = m_input_vector.at(m_last_in); | 			last = m_input_vector.at(m_last_in); | ||||||
|  | 			if (in.timestamp <= m_tstamp) { | ||||||
|  | 				++m_last_in; | ||||||
|  | 				continue; | ||||||
|  | 			} | ||||||
| 			el = (double)(in.timestamp - last.timestamp) / 1000.; | 			el = (double)(in.timestamp - last.timestamp) / 1000.; | ||||||
|  |  | ||||||
| 			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); | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			el = 1. / 60.; | ||||||
|  | 			in = Input(); | ||||||
|  | 			 | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		player->SetDirection(in.direction); |  | ||||||
| 		player->ApplyPhysics(player->GetInput(in.keys.forward, | 		player->ApplyPhysics(player->GetInput(in.keys.forward, | ||||||
| 			in.keys.backward, | 			in.keys.backward, | ||||||
| 			in.keys.left, | 			in.keys.left, | ||||||
| @@ -147,7 +177,10 @@ Timestamp Connection::Run(World* world) { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		out.states.jumping = player->GetIsAirborne(); | 		out.states.jumping = player->GetIsAirborne(); | ||||||
| 		out.states.running = player->GetVelocity().Length() > .5f; |  | ||||||
|  | 		Vector3f horSpeed = player->GetVelocity(); | ||||||
|  | 		horSpeed.y = 0; | ||||||
|  | 		out.states.running = horSpeed.Length() > .2f; | ||||||
| 		out.states.still = !out.states.running && !out.states.jumping; | 		out.states.still = !out.states.running && !out.states.jumping; | ||||||
| 		out.states.hit = player->m_hit; | 		out.states.hit = player->m_hit; | ||||||
| 		player->m_hit = false; | 		player->m_hit = false; | ||||||
| @@ -180,7 +213,7 @@ Timestamp Connection::Run(World* world) { | |||||||
| 		else out.states.jumpshot = false; | 		else out.states.jumpshot = false; | ||||||
|  |  | ||||||
| 		if (in.keys.shoot && m_shoot_acc <= 0.) { | 		if (in.keys.shoot && m_shoot_acc <= 0.) { | ||||||
| 			Bullets.push_back(std::move(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true)))); | 			Bullets.emplace_back(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true))); | ||||||
| 			m_shoot_acc = BULLET_TIME; | 			m_shoot_acc = BULLET_TIME; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -190,9 +223,12 @@ Timestamp Connection::Run(World* world) { | |||||||
| 		out.id = m_playinfo.id; | 		out.id = m_playinfo.id; | ||||||
| 		m_output_manifest[out.timestamp] = out; | 		m_output_manifest[out.timestamp] = out; | ||||||
| 		m_output_vector.push_back(out); | 		m_output_vector.push_back(out); | ||||||
| 		tstamp = out.timestamp; | 		m_tstamp = tstamp = out.timestamp; | ||||||
|  |  | ||||||
|  | 		if (!dead) | ||||||
| 			++m_last_in; | 			++m_last_in; | ||||||
|  |  | ||||||
|  | 		dead = false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return tstamp; | 	return tstamp; | ||||||
|   | |||||||
| @@ -202,8 +202,8 @@ void Server::Run() { | |||||||
| 			m_conns.erase(key); | 			m_conns.erase(key); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 		int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 8, | 		int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 16, | ||||||
| 			y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 8; | 			y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 16; | ||||||
| 		conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f)); | 		conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f)); | ||||||
| 		conn->player->m_username = conn->GetName(); | 		conn->player->m_username = conn->GetName(); | ||||||
| 		m_players[key] = conn->player; | 		m_players[key] = conn->player; | ||||||
| @@ -217,7 +217,7 @@ void Server::Run() { | |||||||
| 		sendPackTo<Sync>(m_sock_udp, &sync, &m_buf, conn->getAddr()); | 		sendPackTo<Sync>(m_sock_udp, &sync, &m_buf, conn->getAddr()); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	int timer = m_game.countdown, sync_acc = 0, deadplayers = 0; | 	int timer = m_game.countdown, timer_acc = 0, deadplayers = 0; | ||||||
| 	std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); | 	std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); | ||||||
| 	Timestamp last = 0; | 	Timestamp last = 0; | ||||||
| 	std::vector<Chat*> chatlog; | 	std::vector<Chat*> chatlog; | ||||||
| @@ -230,21 +230,22 @@ void Server::Run() { | |||||||
| 	Chat* startchat = new Chat(); | 	Chat* startchat = new Chat(); | ||||||
| 	startchat->src_id = 0; | 	startchat->src_id = 0; | ||||||
| 	char startmess[] = "How would -YOU- like to die today, motherf-words?"; | 	char startmess[] = "How would -YOU- like to die today, motherf-words?"; | ||||||
|  | 	float endtime = 0.; | ||||||
| 	strcpy(startchat->mess, 140, startmess); | 	strcpy(startchat->mess, 140, startmess); | ||||||
|  |  | ||||||
| 	chatlog.emplace_back(startchat); | 	chatlog.emplace_back(startchat); | ||||||
| 		 | 		 | ||||||
| 	while (!endgame) { | 	while (!endgame && endtime < 1.) { | ||||||
| 		using namespace std::chrono; | 		using namespace std::chrono; | ||||||
| 		Timestamp tstamp = duration_cast<milliseconds>(high_resolution_clock::now() - start).count(); | 		Timestamp tstamp = duration_cast<milliseconds>(high_resolution_clock::now() - start).count(); | ||||||
|  |  | ||||||
| 		if (last == 0) | 		if (last == 0) | ||||||
| 			last = tstamp; | 			last = tstamp; | ||||||
| 		sync_acc += tstamp - last; | 		timer_acc += tstamp - last; | ||||||
| 		if (sync_acc >= 1000) { | 		if (timer_acc >= 1000) { | ||||||
| 			while (sync_acc >= 1000) | 			while (timer_acc >= 1000) | ||||||
| 				sync_acc -= 1000; | 				timer_acc -= 1000; | ||||||
|  | 			if (!endgame) | ||||||
| 				--timer; | 				--timer; | ||||||
| 			std::string str = "Timer: "; | 			std::string str = "Timer: "; | ||||||
| 			Log(str.append(std::to_string(timer)), false, false); | 			Log(str.append(std::to_string(timer)), false, false); | ||||||
| @@ -275,34 +276,43 @@ void Server::Run() { | |||||||
| 				default: break; | 				default: break; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | 			if (!lsPck.empty()) | ||||||
| 				lsPck.clear(); | 				lsPck.clear(); | ||||||
|  |  | ||||||
| 			/* Process */ | 			/* Process */ | ||||||
|  |  | ||||||
| 			if (conn->m_nsync) { | 			if (conn->m_nsync) { | ||||||
|  |  | ||||||
| 				Timestamp tstamp = conn->Run(m_world); | 				Timestamp tstamp = conn->Run(m_world); | ||||||
|  |  | ||||||
| 				if (conn->player->AmIDead()) { | 				if (conn->player->AmIDead() && !conn->player->Eulogy) { | ||||||
| 					Chat* chat = new Chat(); | 					Chat* chat = new Chat(); | ||||||
| 					chat->dest_id = chat->dest_team_id = chat->src_id = 0; | 					chat->dest_id = chat->dest_team_id = chat->src_id = 0; | ||||||
|  |  | ||||||
| 					std::string killer = m_conns.at(conn->player->Killer)->player->GetUsername(); | 					Player* murderer = m_conns.at(conn->player->Killer)->player; | ||||||
|  |  | ||||||
|  | 					if (murderer != conn->player) | ||||||
|  | 						murderer->addPoint(); | ||||||
|  |  | ||||||
|  | 					std::string killer = murderer->GetUsername(); | ||||||
| 					 | 					 | ||||||
| 					std::string mess = getDeathMessage(conn->player->GetUsername(), killer); | 					std::string mess = getDeathMessage(conn->player->GetUsername(), killer); | ||||||
| 					 | 					 | ||||||
| 					strcpy(chat->mess, 140, mess.c_str()); | 					strcpy(chat->mess, 140, mess.c_str()); | ||||||
| 					chatlog.emplace_back(chat); | 					chatlog.emplace_back(chat); | ||||||
| 					++deadplayers; | 					++deadplayers; | ||||||
|  |  | ||||||
|  | 					conn->player->Eulogy = true; | ||||||
| 					conn->m_nsync = false; | 					conn->m_nsync = false; | ||||||
| 				} | 				} | ||||||
| 				else { | 				else { | ||||||
| 					for (auto& chmo : conn->ChunkDiffs) | 					for (auto& chmo : conn->ChunkDiffs) | ||||||
| 						chunkdiffs.emplace_back(std::move(chmo)); | 						chunkdiffs.emplace_back(std::move(chmo)); | ||||||
|  | 					if (!conn->ChunkDiffs.empty()) | ||||||
| 						conn->ChunkDiffs.clear(); | 						conn->ChunkDiffs.clear(); | ||||||
|  |  | ||||||
| 					for (auto& bull : conn->Bullets) { | 					for (auto& bull : conn->Bullets) { | ||||||
| 						bullets.emplace_back(bull); | 						bullets.emplace_back(bull); | ||||||
| 						//Log("POW!", false, false); |  | ||||||
| 						BulletAdd* nbul = new BulletAdd(); | 						BulletAdd* nbul = new BulletAdd(); | ||||||
| 						nbul->pos = bull->getPos(); | 						nbul->pos = bull->getPos(); | ||||||
| 						nbul->dir = bull->getVel(); | 						nbul->dir = bull->getVel(); | ||||||
| @@ -311,15 +321,50 @@ void Server::Run() { | |||||||
|  |  | ||||||
| 						netbull.emplace_back(std::move(nbul)); | 						netbull.emplace_back(std::move(nbul)); | ||||||
| 					} | 					} | ||||||
|  | 					if (!conn->Bullets.empty()) | ||||||
| 						conn->Bullets.clear(); | 						conn->Bullets.clear(); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				/* Out */ |  | ||||||
|  |  | ||||||
| 				conn->sendPacks(m_sock_udp, m_conns, timer); |  | ||||||
| 			} | 			} | ||||||
| 			if ((deadplayers == players - 1 && deadplayers != 0) || timer <= 0) | 			/* Out */ | ||||||
|  | 			conn->sendPacks(m_sock_udp, m_conns, timer); | ||||||
|  |  | ||||||
|  | 			if ((deadplayers == players - 1 && deadplayers != 0) || timer < 0) { | ||||||
|  | 				if (!endgame) { | ||||||
|  | 					Chat* gameover = new Chat(); | ||||||
|  | 					gameover->dest_id = gameover->dest_team_id = gameover->src_id = 0; | ||||||
|  | 					std::string winner, winmess; | ||||||
|  | 					int score = 0;  | ||||||
|  | 					bool plural = false; | ||||||
|  | 					for (auto& [key, conn] : m_conns) { | ||||||
|  | 						if (conn->player->getScore() > score) { | ||||||
|  | 							winner = conn->player->GetUsername(); | ||||||
|  | 							score = conn->player->getScore(); | ||||||
|  | 							plural = false; | ||||||
|  | 						} | ||||||
|  | 						else if (conn->player->getScore() == score) { | ||||||
|  | 							winner = winner.append(" and ").append(conn->player->GetUsername()); | ||||||
|  | 							plural = true; | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  |  | ||||||
|  | 					winmess = "And the winner"; | ||||||
|  | 					if (!plural) | ||||||
|  | 						winmess = winmess.append(" is "); | ||||||
|  | 					else winmess = winmess.append("s are "); | ||||||
|  | 				 | ||||||
|  | 					winmess = winmess.append(winner).append(" with ").append(std::to_string(score)).append(" point"); | ||||||
|  |  | ||||||
|  | 					if (score > 1) | ||||||
|  | 						winmess = winmess.append("s."); | ||||||
|  | 					else winmess = winmess.append("."); | ||||||
|  |  | ||||||
|  | 					strcpy(gameover->mess, 140, winmess.c_str()); | ||||||
|  | 					 | ||||||
|  | 					chatlog.emplace_back(gameover); | ||||||
|  | 				} | ||||||
| 				endgame = true; | 				endgame = true; | ||||||
|  | 				endtime += .001; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		for (auto& bull : netbull) { | 		for (auto& bull : netbull) { | ||||||
| @@ -328,20 +373,25 @@ void Server::Run() { | |||||||
| 					sendPackTo<BulletAdd>(m_sock_udp, bull, &m_buf, conn->getAddr()); | 					sendPackTo<BulletAdd>(m_sock_udp, bull, &m_buf, conn->getAddr()); | ||||||
| 			delete bull; | 			delete bull; | ||||||
| 		} | 		} | ||||||
|  | 		if (!netbull.empty()) | ||||||
| 			netbull.clear(); | 			netbull.clear(); | ||||||
|  |  | ||||||
| 		for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) { | 		for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) { | ||||||
| 			ChunkMod* cmod = nullptr; | 			ChunkMod* cmod = nullptr; | ||||||
| 			Bullet* bullet = *bull; | 			Bullet* bullet = *bull; | ||||||
| 			if (bullet->Update(m_world, (1. / 60.), 20, m_players, &cmod)) { | 			if (bullet->Update(m_world, (1. / 60.), 50, m_players, &cmod)) { | ||||||
| 				if (cmod) | 				if (cmod) | ||||||
| 					chunkdiffs.emplace_back(cmod); | 					chunkdiffs.emplace_back(cmod); | ||||||
| 				bullit.push_back(bull); | 				bullit.push_back(bull); | ||||||
| 				delete bullet; |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		for (auto& bull: bullit) |  | ||||||
|  | 		for (auto& bull : bullit) { | ||||||
|  | 			delete* bull; | ||||||
| 			bullets.erase(bull); | 			bullets.erase(bull); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if (!bullit.empty()) | ||||||
| 			bullit.clear(); | 			bullit.clear(); | ||||||
|  |  | ||||||
| 		for (auto& chat : chatlog) { | 		for (auto& chat : chatlog) { | ||||||
| @@ -350,6 +400,7 @@ void Server::Run() { | |||||||
| 				sendPackTo<Chat>(m_sock_udp, chat, &m_buf, conn->getAddr()); | 				sendPackTo<Chat>(m_sock_udp, chat, &m_buf, conn->getAddr()); | ||||||
| 			delete chat; | 			delete chat; | ||||||
| 		} | 		} | ||||||
|  | 		if (!chatlog.empty()) | ||||||
| 			chatlog.clear(); | 			chatlog.clear(); | ||||||
|  |  | ||||||
| 		for (auto& chmo : chunkdiffs) { | 		for (auto& chmo : chunkdiffs) { | ||||||
| @@ -357,6 +408,7 @@ void Server::Run() { | |||||||
| 				sendPackTo<ChunkMod>(m_sock_udp, chmo, &m_buf, conn->getAddr()); | 				sendPackTo<ChunkMod>(m_sock_udp, chmo, &m_buf, conn->getAddr()); | ||||||
| 			delete chmo; | 			delete chmo; | ||||||
| 		} | 		} | ||||||
|  | 		if (!chunkdiffs.empty()) | ||||||
| 			chunkdiffs.clear(); | 			chunkdiffs.clear(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -367,8 +419,7 @@ void Server::Run() { | |||||||
|  |  | ||||||
| 	for (auto& [key, conn] : m_conns) { | 	for (auto& [key, conn] : m_conns) { | ||||||
| 		std::string str = conn->player->GetUsername(); | 		std::string str = conn->player->GetUsername(); | ||||||
| 		Log(str.append(" ").append(std::to_string(conn->player->GetHP())), false, false); | 		Log(str.append(" ").append(std::to_string(conn->player->getScore())), false, false); | ||||||
| 		 |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for (auto& [key, conn] : m_conns) | 	for (auto& [key, conn] : m_conns) | ||||||
|   | |||||||
| @@ -91,7 +91,7 @@ | |||||||
|     <UseDebugLibraries>false</UseDebugLibraries> |     <UseDebugLibraries>false</UseDebugLibraries> | ||||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> |     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||||
|     <CharacterSet>Unicode</CharacterSet> |     <CharacterSet>Unicode</CharacterSet> | ||||||
|     <PlatformToolset>ClangCL</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||||
|   <ImportGroup Label="ExtensionSettings"> |   <ImportGroup Label="ExtensionSettings"> | ||||||
| @@ -196,7 +196,7 @@ | |||||||
|       <FloatingPointModel>Fast</FloatingPointModel> |       <FloatingPointModel>Fast</FloatingPointModel> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <Link> |     <Link> | ||||||
|       <SubSystem>Console</SubSystem> |       <SubSystem>Windows</SubSystem> | ||||||
|       <GenerateDebugInformation>false</GenerateDebugInformation> |       <GenerateDebugInformation>false</GenerateDebugInformation> | ||||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> |       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||||
|       <OptimizeReferences>true</OptimizeReferences> |       <OptimizeReferences>true</OptimizeReferences> | ||||||
|   | |||||||
| @@ -2,26 +2,40 @@ | |||||||
|  |  | ||||||
| Audio::Audio() { | Audio::Audio() { | ||||||
| 	m_engine = irrklang::createIrrKlangDevice(); | 	m_engine = irrklang::createIrrKlangDevice(); | ||||||
| 	m_engine->setDopplerEffectParameters(10); | 	m_engine->setDopplerEffectParameters(1); | ||||||
| 	m_engine->setRolloffFactor(2); | 	m_engine->setRolloffFactor(1); | ||||||
| 	m_engine->setDefault3DSoundMinDistance(.1); | 	m_engine->setDefault3DSoundMinDistance(1); | ||||||
| 	m_engine->setDefault3DSoundMaxDistance(1000); | 	m_engine->setDefault3DSoundMaxDistance(1000); | ||||||
| } | } | ||||||
|  |  | ||||||
| Audio::Audio(const char * music) { | Audio::Audio(const char * music, const char* menumusic) { | ||||||
| 	m_engine = irrklang::createIrrKlangDevice(); | 	m_engine = irrklang::createIrrKlangDevice(); | ||||||
| 	m_engine->setDopplerEffectParameters(1); | 	m_engine->setDopplerEffectParameters(1); | ||||||
| 	m_engine->setRolloffFactor(2); | 	m_engine->setRolloffFactor(1); | ||||||
| 	m_engine->setDefault3DSoundMinDistance(.1); | 	m_engine->setDefault3DSoundMinDistance(1); | ||||||
| 	m_engine->setDefault3DSoundMaxDistance(1000); | 	m_engine->setDefault3DSoundMaxDistance(100); | ||||||
| 	m_music = m_engine->play2D(music, true, true, true, irrklang::ESM_STREAMING); | 	m_music = m_engine->play2D(music, true, true, true, irrklang::ESM_STREAMING); | ||||||
|  | 	m_menumusic = m_engine->play2D(menumusic, true, true, true, irrklang::ESM_STREAMING); | ||||||
|  | 	m_music->setVolume(.5); | ||||||
|  | 	m_menumusic->setVolume(.5); | ||||||
|  | 	m_mainvolume = 0.5f; | ||||||
|  | 	m_engine->setSoundVolume(m_mainvolume); | ||||||
|  | 	m_sfxvolume = 0.5f; | ||||||
| } | } | ||||||
|  |  | ||||||
| Audio::~Audio() {  | Audio::~Audio() {  | ||||||
| 	if (m_music) m_music->drop(); | 	if (m_music) m_music->drop(); | ||||||
|  | 	if (m_menumusic) m_menumusic->drop(); | ||||||
| 	if (m_engine) m_engine->drop(); | 	if (m_engine) m_engine->drop(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void Audio::playSound(const char* name, float volume = 1.) { | ||||||
|  | 	irrklang::ISound* sfx = m_engine->play2D(name, false, true); | ||||||
|  | 	sfx->setVolume(volume); | ||||||
|  | 	sfx->setIsPaused(false); | ||||||
|  | 	m_sfxes.push_back(sfx); | ||||||
|  | } | ||||||
|  |  | ||||||
| void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { | void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { | ||||||
| 	m_engine->setListenerPosition(irrklang::vec3df(pos.x, pos.y, pos.z), | 	m_engine->setListenerPosition(irrklang::vec3df(pos.x, pos.y, pos.z), | ||||||
| 								  irrklang::vec3df(dir.x, dir.y, dir.z), | 								  irrklang::vec3df(dir.x, dir.y, dir.z), | ||||||
| @@ -29,9 +43,10 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { | |||||||
| } | } | ||||||
|  |  | ||||||
| irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) { | irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) { | ||||||
| 	sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true); | 	sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, true, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true); | ||||||
| 	sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z)); | 	sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z)); | ||||||
| 	sound->setVolume(volume); | 	sound->setVolume(volume); | ||||||
|  | 	sound->setIsPaused(false); | ||||||
| 	return sound; | 	return sound; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -45,10 +60,76 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v | |||||||
| //	m_music = m_engine->play2D(music, false, false, false, irrklang::ESM_STREAMING); | //	m_music = m_engine->play2D(music, false, false, false, irrklang::ESM_STREAMING); | ||||||
| //} | //} | ||||||
|  |  | ||||||
| void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); } | void Audio::CleanupSFX() { | ||||||
|  | 	while (!m_sfxes.empty()) { | ||||||
|  | 		irrklang::ISound* sfx = m_sfxes.back(); | ||||||
|  | 		if (sfx->isFinished()) { | ||||||
|  | 			sfx->drop(); // drop() fait deja la job du delete sfx. | ||||||
|  | 		} | ||||||
|  | 		else break; | ||||||
|  | 		m_sfxes.pop_back(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void Audio::ToggleMusicState(GameState state) { | ||||||
|  | 	if (m_music_on) { | ||||||
|  | 		switch (state) { | ||||||
|  | 		case PLAY: | ||||||
|  | 			m_music->setIsPaused(false); | ||||||
|  | 			m_menumusic->setIsPaused(true); | ||||||
|  | 			break; | ||||||
|  | 		case PAUSE: | ||||||
|  | 			m_music->setIsPaused(true); | ||||||
|  | 			m_menumusic->setIsPaused(true); | ||||||
|  | 			break; | ||||||
|  | 		default: | ||||||
|  | 			m_music->setIsPaused(true); | ||||||
|  | 			m_menumusic->setIsPaused(false); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		m_music->setIsPaused(true); | ||||||
|  | 		m_menumusic->setIsPaused(true); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void Audio::SetMusic(bool ison, GameState state) { | ||||||
|  | 	m_music_on = state; | ||||||
|  | 	if (!state) { | ||||||
|  | 		m_music->setIsPaused(true); | ||||||
|  | 		m_menumusic->setIsPaused(true); | ||||||
|  | 	} | ||||||
|  | 	else ToggleMusicState(state); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | bool Audio::GetMusic() { | ||||||
|  | 	return m_music_on; | ||||||
|  | } | ||||||
|  |  | ||||||
| void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); } | void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); } | ||||||
|  |  | ||||||
| float Audio::GetMusicVolume() const { | float Audio::GetMusicVolume() const { | ||||||
| 	return m_music->getVolume(); | 	return m_music->getVolume(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void Audio::SetMusicVolume(float volume) { | ||||||
|  | 	m_music->setVolume(volume); | ||||||
|  | 	m_menumusic->setVolume(volume); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | float Audio::GetMainVolume() const { | ||||||
|  | 	return m_engine->getSoundVolume(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void Audio::SetMainVolume(float volume) { | ||||||
|  | 	m_engine->setSoundVolume(volume); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | float Audio::GetSfxVolume() const { | ||||||
|  | 	return m_sfxvolume; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void Audio::SetSfxVolume(float volume) { | ||||||
|  | 	m_sfxvolume = volume; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -15,26 +15,46 @@ | |||||||
| class Audio { | class Audio { | ||||||
| private: | private: | ||||||
| 	irrklang::ISound* m_music; | 	irrklang::ISound* m_music; | ||||||
|  | 	irrklang::ISound* m_menumusic; | ||||||
|  | 	float m_mainvolume; | ||||||
|  | 	float m_sfxvolume; | ||||||
|  | 	bool m_music_on = true; | ||||||
|  | 	std::vector<irrklang::ISound*> m_sfxes; | ||||||
|  |  | ||||||
| public: | public: | ||||||
| 	Audio(); | 	Audio(); | ||||||
| 	Audio(const char* music); | 	Audio(const char* music, const char* menumusic); | ||||||
| 	~Audio(); | 	~Audio(); | ||||||
| 	irrklang::ISoundEngine* m_engine; | 	irrklang::ISoundEngine* m_engine; | ||||||
|  |  | ||||||
| 	void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed); | 	void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed); | ||||||
|  |  | ||||||
|  |  | ||||||
| 	irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume); | 	irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume); | ||||||
|  |  | ||||||
| 	void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume); | 	void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume); | ||||||
|  |  | ||||||
| 	//void PlaySong(const char* music); | 	//void PlaySong(const char* music); | ||||||
|  |  | ||||||
| 	void ToggleMusicState(); | 	void CleanupSFX(); | ||||||
|  |  | ||||||
|  | 	void ToggleMusicState(GameState state); | ||||||
|  |  | ||||||
|  | 	void playSound(const char* sound, float volume); | ||||||
|  |  | ||||||
|  | 	void SetMusic(bool ison, GameState state); | ||||||
|  | 	bool GetMusic(); | ||||||
|  |  | ||||||
| 	void PauseEngine(); | 	void PauseEngine(); | ||||||
|  |  | ||||||
|  | 	float GetMainVolume() const; | ||||||
|  | 	void SetMainVolume(float volume); | ||||||
|  |  | ||||||
| 	float GetMusicVolume() const; | 	float GetMusicVolume() const; | ||||||
|  | 	void SetMusicVolume(float volume); | ||||||
|  |  | ||||||
|  | 	float GetSfxVolume() const; | ||||||
|  | 	void SetSfxVolume(float volume); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // AUDIO_H__ | #endif // AUDIO_H__ | ||||||
|   | |||||||
| @@ -25,8 +25,8 @@ | |||||||
|  |  | ||||||
| #define BULLET_UPDATES_PER_FRAME 20 | #define BULLET_UPDATES_PER_FRAME 20 | ||||||
|  |  | ||||||
| #define BASE_WIDTH 640 | #define BASE_WIDTH 1280 | ||||||
| #define BASE_HEIGHT 480 | #define BASE_HEIGHT 720 | ||||||
|  |  | ||||||
|  |  | ||||||
| #define ANIME_PATH_JUMP		"./media/textures/AssetOtherPlayer/FinalPNGJumping/" | #define ANIME_PATH_JUMP		"./media/textures/AssetOtherPlayer/FinalPNGJumping/" | ||||||
| @@ -50,7 +50,6 @@ enum GameState { | |||||||
| 	SPLASH, | 	SPLASH, | ||||||
| 	LOBBY, | 	LOBBY, | ||||||
| 	OPTIONS, | 	OPTIONS, | ||||||
| 	QUIT, |  | ||||||
| 	PLAY,  | 	PLAY,  | ||||||
| 	PAUSE | 	PAUSE | ||||||
| }; | }; | ||||||
| @@ -59,7 +58,7 @@ enum Resolution { | |||||||
| 	HD = 0,		// 1280x720	 (High Definition) | 	HD = 0,		// 1280x720	 (High Definition) | ||||||
| 	FHD,		// 1920x1080 (Full HD) | 	FHD,		// 1920x1080 (Full HD) | ||||||
| 	QHD,		// 2560x1440 (Quad HD) | 	QHD,		// 2560x1440 (Quad HD) | ||||||
| 	UHD			// 3840x2160 (Ultra HD) | 	UHD,		// 3840x2160 (Ultra HD) | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // DEFINE_H__ | #endif // DEFINE_H__ | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -49,6 +49,7 @@ private: | |||||||
|     bool StartMultiplayerGame(); |     bool StartMultiplayerGame(); | ||||||
|  |  | ||||||
|     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 ChangeResolution(Resolution resolution); | ||||||
|  |  | ||||||
|     void InstantDamage(); |     void InstantDamage(); | ||||||
|     void SystemNotification(std::string systemLog); |     void SystemNotification(std::string systemLog); | ||||||
| @@ -73,6 +74,8 @@ private: | |||||||
|     void SetPlayerUsername(float elapsedTime); |     void SetPlayerUsername(float elapsedTime); | ||||||
|     void SetServerAddress(float elapsedTime); |     void SetServerAddress(float elapsedTime); | ||||||
|  |  | ||||||
|  |     void DisplayPauseMenu(float elapsedTime); | ||||||
|  |  | ||||||
|     void DisplayOptionsMenu(); |     void DisplayOptionsMenu(); | ||||||
|     void DisplayAudioMenu(float centerX, float centerY); |     void DisplayAudioMenu(float centerX, float centerY); | ||||||
|     void DisplayGraphicsMenu(float centerX, float centerY); |     void DisplayGraphicsMenu(float centerX, float centerY); | ||||||
| @@ -86,8 +89,7 @@ private: | |||||||
|     char SimulateKeyboard(unsigned char key); |     char SimulateKeyboard(unsigned char key); | ||||||
|     void HandlePlayerInput(float elapsedTime); |     void HandlePlayerInput(float elapsedTime); | ||||||
|  |  | ||||||
|     //udio m_menuaudio = Audio(AUDIO_PATH "menumusic.wav"); |     Audio m_audio = Audio(AUDIO_PATH "music01.wav", AUDIO_PATH "menumusic01.wav"); | ||||||
|     Audio m_audio = Audio(AUDIO_PATH "music01.wav"); |  | ||||||
|     irrklang::ISound* m_powpow, * m_scream; |     irrklang::ISound* m_powpow, * m_scream; | ||||||
|     irrklang::ISound* m_whoosh[MAX_BULLETS]; |     irrklang::ISound* m_whoosh[MAX_BULLETS]; | ||||||
|  |  | ||||||
| @@ -138,6 +140,9 @@ private: | |||||||
|     Texture m_textureCheck; |     Texture m_textureCheck; | ||||||
|     Texture m_textureChecked; |     Texture m_textureChecked; | ||||||
|  |  | ||||||
|  |     Texture m_texturePauseResume; | ||||||
|  |     Texture m_texturePauseMainMenu; | ||||||
|  |  | ||||||
|     Texture m_textureOptAudio; |     Texture m_textureOptAudio; | ||||||
|     Texture m_textureOptBack; |     Texture m_textureOptBack; | ||||||
|     Texture m_textureOptGameplay; |     Texture m_textureOptGameplay; | ||||||
| @@ -172,10 +177,10 @@ private: | |||||||
|     int m_nbReductionChunk = 4; |     int m_nbReductionChunk = 4; | ||||||
|     int m_timerReductionChunk = 30; |     int m_timerReductionChunk = 30; | ||||||
|  |  | ||||||
|     float m_volPrincipal = 0.0f; |     float m_mainvolume; | ||||||
|     float m_volMusique = 0.0f; |     float m_musicvolume; | ||||||
|     float m_volEffets = 0.0f; |     float m_sfxvolume; | ||||||
|     float m_volSensible = 0.0f; |     float m_sensitivity; | ||||||
|  |  | ||||||
|     int m_selectedOption = 0; |     int m_selectedOption = 0; | ||||||
|  |  | ||||||
| @@ -204,13 +209,18 @@ private: | |||||||
|     std::string m_currentInputString; |     std::string m_currentInputString; | ||||||
|     std::string m_username; |     std::string m_username; | ||||||
|     std::string m_serverAddr; |     std::string m_serverAddr; | ||||||
|  |  | ||||||
|     char m_inputChar = 0; |     char m_inputChar = 0; | ||||||
|     bool m_invalidChar = false; |     bool m_invalidChar = false; | ||||||
|     bool m_charChanged = false; |     bool m_charChanged = false; | ||||||
|     bool m_settingUsername = false; |     bool m_settingUsername = false; | ||||||
|     bool m_settingServer = false; |     bool m_settingServer = false; | ||||||
|  |     bool m_selectedSinglePlayer = false; | ||||||
|  |     bool m_selectedMultiPlayer = false; | ||||||
|  |     bool m_singleReady = false; | ||||||
|     bool m_multiReady = false; |     bool m_multiReady = false; | ||||||
|  |  | ||||||
|  |      | ||||||
|     bool m_key1 = false; |     bool m_key1 = false; | ||||||
|     bool m_key2 = false; |     bool m_key2 = false; | ||||||
|     bool m_keyK = false; |     bool m_keyK = false; | ||||||
| @@ -239,6 +249,7 @@ private: | |||||||
|     std::deque<netprot::ChunkMod*> m_chunkmod_manifest; |     std::deque<netprot::ChunkMod*> m_chunkmod_manifest; | ||||||
|     std::chrono::high_resolution_clock::time_point m_startTime; |     std::chrono::high_resolution_clock::time_point m_startTime; | ||||||
|     std::unordered_map<uint64_t, Player*> m_players; |     std::unordered_map<uint64_t, Player*> m_players; | ||||||
|  |     std::set<uint64_t> m_deadplayers; | ||||||
|     netprot::Buffer m_buf, m_bufout; |     netprot::Buffer m_buf, m_bufout; | ||||||
|     netprot::ChunkMod* m_chunkmod = nullptr; |     netprot::ChunkMod* m_chunkmod = nullptr; | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/audio/menumusic01.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SQCSim2021/media/audio/menumusic01.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/audio/snap.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SQCSim2021/media/audio/snap.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 562 KiB After Width: | Height: | Size: 596 KiB | 
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/menus/buttons/pause/pauseMainMenu.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/menus/buttons/pause/pauseMainMenu.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 9.5 KiB | 
							
								
								
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/menus/buttons/pause/pauseResume.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SQCSim2021/media/textures/menus/buttons/pause/pauseResume.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 6.8 KiB | 
| @@ -53,9 +53,9 @@ protected: | |||||||
|     void ShowCrossCursor() const; |     void ShowCrossCursor() const; | ||||||
|  |  | ||||||
|     bool m_istarted = false; |     bool m_istarted = false; | ||||||
|  |     void InitWindow(int width, int height); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void InitWindow(int width, int height); |  | ||||||
|     MOUSE_BUTTON ConvertMouseButton(sf::Mouse::Button button) const; |     MOUSE_BUTTON ConvertMouseButton(sf::Mouse::Button button) const; | ||||||
|  |  | ||||||
| private: | private: | ||||||
|   | |||||||
| @@ -8,11 +8,11 @@ | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)){ | RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)) { | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) { | RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo, const Vector3f& pos) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) { | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -31,54 +31,9 @@ void RemotePlayer::Feed(const netprot::Output out) { | |||||||
|  |  | ||||||
| 	m_position = Vector3f(out.position); | 	m_position = Vector3f(out.position); | ||||||
| 	m_direction = Vector3f(out.direction); | 	m_direction = Vector3f(out.direction); | ||||||
|  |  | ||||||
| 	current.states = out.states; | 	current.states = out.states; | ||||||
| 	 | 	 | ||||||
| 	//current.position = out.position; |  | ||||||
| 	//current.direction = out.direction; |  | ||||||
| 	//current.states = out.states; |  | ||||||
| 	//current.id = out.id; |  | ||||||
|  |  | ||||||
| 	//if (current.position != previous.position) |  | ||||||
| 	//{ |  | ||||||
| 	//	Vector3f positionDelta = current.position - previous.position; |  | ||||||
| 	//	m_position = current.position + positionDelta; |  | ||||||
| 	//	m_direction = current.direction;		 |  | ||||||
|  |  | ||||||
| 	//} |  | ||||||
|  |  | ||||||
| 	//if(current.direction != previous.direction) |  | ||||||
| 	//{ |  | ||||||
| 	//	m_direction = current.direction; |  | ||||||
| 	//	current.direction = current.direction; |  | ||||||
| 	//} |  | ||||||
|  |  | ||||||
| 	//if (current.states.shooting) { |  | ||||||
| 	//	m_animstate = Anim::SHOOTING; |  | ||||||
| 	//} |  | ||||||
| 	//else if (current.states.jumping) { |  | ||||||
| 	//	m_animstate = Anim::JUMPING; |  | ||||||
| 	//} |  | ||||||
| 	//else if (current.states.dead) { |  | ||||||
| 	//	m_animstate = Anim::DEAD; |  | ||||||
| 	//} |  | ||||||
| 	//else if(current.states.powerup){ |  | ||||||
| 	//	m_animstate = Anim::POWERUP; |  | ||||||
| 	//} |  | ||||||
| 	//else if (current.states.still) { |  | ||||||
| 	//	m_animstate = Anim::STILL; |  | ||||||
| 	//} |  | ||||||
| 	//else if (current.states.running) { |  | ||||||
| 	//	m_animstate = Anim::RUNNING; |  | ||||||
| 	//} |  | ||||||
|  |  | ||||||
| 	//previous.direction = current.direction; |  | ||||||
| 	//previous.position = current.position; |  | ||||||
| 	//previous.states = current.states; |  | ||||||
| 	//previous.id = current.id; |  | ||||||
|  |  | ||||||
| 	//m_direction = current.direction; |  | ||||||
| 	//m_position = current.position; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -118,26 +73,25 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 	int index = 0; | 	int index = 0; | ||||||
| 	angle = -angle; | 	angle = -angle; | ||||||
| 	Vector3f side = angleRemote.Cross(angleCam); | 	Vector3f side = angleRemote.Cross(angleCam); | ||||||
|  | 	side = -side; | ||||||
|  |  | ||||||
| 	static float time = 0.f; | 	static float time = 0.f; | ||||||
| 	static bool Shooting = false; | 	static bool Shooting = false; | ||||||
| 	bool isLeft = side.y > 0; | 	bool isLeft = side.y > 0; | ||||||
|  |  | ||||||
| 	time += elapsedTime; | 	time += elapsedTime; | ||||||
| 	if (time >= 200) | 	if (time >= 0.05) | ||||||
| 	{ | 	{ | ||||||
| 			time -= 200; | 		time -= 0.05; | ||||||
| 		if (!current.states.shooting) |  | ||||||
| 			Shooting = false; |  | ||||||
| 		else  |  | ||||||
| 		Shooting = !Shooting; | 		Shooting = !Shooting; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	//std::cout << "shooting : " << current.states.shooting << " jumping : " << current.states.jumping <<  " jumpshot : " << current.states.jumpshot << " running : " << current.states.running << " still : " << current.states.still << " dead : " << current.states.dead << " hit : " << current.states.hit << std::endl; | ||||||
|  |  | ||||||
| 	if (angle >= 0.75) //Face - side positif | 	if (angle >= 0.75) //Face - side positif | ||||||
| 	{ | 	{ | ||||||
| 		if(current.states.shooting){ | 		if (current.states.shooting) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| 				index = 17; | 				index = 17; | ||||||
| 			else | 			else | ||||||
| @@ -151,7 +105,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping) | 		else if (current.states.jumping) | ||||||
| 			index = 25; | 			index = 25; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 0; | 			index = 0; | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| @@ -162,6 +116,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 				index = 18; | 				index = 18; | ||||||
| 			else | 			else | ||||||
| 				index = 10; | 				index = 10; | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumpshot) { | 		else if (current.states.jumpshot) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| @@ -169,11 +124,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 			else | 			else | ||||||
| 				index = 34; | 				index = 34; | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping ) | 		else if (current.states.jumping) | ||||||
| 			index = 26; | 			index = 26; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 1; | 			index = 1; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle >= -0.25 && isLeft) //ProfileLeft | 	else if (angle >= -0.25 && isLeft) //ProfileLeft | ||||||
| 	{ | 	{ | ||||||
| @@ -182,18 +138,20 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 				index = 20; | 				index = 20; | ||||||
| 			else | 			else | ||||||
| 				index = 12; | 				index = 12; | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumpshot ) { | 		else if (current.states.jumpshot) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| 				index = 44; | 				index = 44; | ||||||
| 			else | 			else | ||||||
| 				index = 36; | 				index = 36; | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping ) | 		else if (current.states.jumping) | ||||||
| 			index = 28; | 			index = 28; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 3; | 			index = 3; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle >= -0.75 && isLeft) //BackLeft | 	else if (angle >= -0.75 && isLeft) //BackLeft | ||||||
| 	{ | 	{ | ||||||
| @@ -202,6 +160,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 				index = 22; | 				index = 22; | ||||||
| 			else | 			else | ||||||
| 				index = 14; | 				index = 14; | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumpshot) { | 		else if (current.states.jumpshot) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| @@ -211,8 +170,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping) | 		else if (current.states.jumping) | ||||||
| 			index = 30; | 			index = 30; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 5; | 			index = 5; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle < -0.75) //Dos - side n<>gatif | 	else if (angle < -0.75) //Dos - side n<>gatif | ||||||
| 	{ | 	{ | ||||||
| @@ -221,6 +182,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 				index = 24; | 				index = 24; | ||||||
| 			else | 			else | ||||||
| 				index = 16; | 				index = 16; | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumpshot) { | 		else if (current.states.jumpshot) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| @@ -228,13 +190,14 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 			else | 			else | ||||||
| 				index = 40; | 				index = 40; | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping ) | 		else if (current.states.jumping) | ||||||
| 			index = 32; | 			index = 32; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 7; | 			index = 7; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle >= 0.25 && !isLeft) //FrontRight | 	else if (angle >= 0.25 && !isLeft) //FrontRight //REVOIR L'ANIME DE SHOOTING EST PAS DRETTE | ||||||
| 	{ | 	{ | ||||||
| 		if (current.states.shooting) { | 		if (current.states.shooting) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| @@ -250,9 +213,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping) | 		else if (current.states.jumping) | ||||||
| 			index = 27; | 			index = 27; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 2; | 			index = 2; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle >= -0.25 && !isLeft) //ProfileRight | 	else if (angle >= -0.25 && !isLeft) //ProfileRight | ||||||
| 	{ | 	{ | ||||||
| @@ -270,9 +234,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping) | 		else if (current.states.jumping) | ||||||
| 			index = 29; | 			index = 29; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 4; | 			index = 4; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if (angle >= -0.75 && !isLeft) //BackRight | 	else if (angle >= -0.75 && !isLeft) //BackRight | ||||||
| 	{ | 	{ | ||||||
| @@ -281,6 +246,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 				index = 23; | 				index = 23; | ||||||
| 			else | 			else | ||||||
| 				index = 15; | 				index = 15; | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumpshot) { | 		else if (current.states.jumpshot) { | ||||||
| 			if (Shooting) | 			if (Shooting) | ||||||
| @@ -290,9 +256,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 		} | 		} | ||||||
| 		else if (current.states.jumping) | 		else if (current.states.jumping) | ||||||
| 			index = 31; | 			index = 31; | ||||||
| 		else if (current.states.running && current.states.still) | 		else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) | ||||||
| 			index = 6; | 			index = 6; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -304,10 +271,25 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr | |||||||
| 	atlas.TextureIndexToCoord(index, u, v, w, h); | 	atlas.TextureIndexToCoord(index, u, v, w, h); | ||||||
|  |  | ||||||
| 	glEnable(GL_BLEND); | 	glEnable(GL_BLEND); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	if (current.states.hit) | ||||||
|  | 	{ | ||||||
|  | 		glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR); | ||||||
|  | 		glBlendColor(1.f, 0.f, 0.f, 1.f); | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
| 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	glBlendEquation(GL_FUNC_ADD); | 	glBlendEquation(GL_FUNC_ADD); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 	glLoadMatrixf(tran.GetMatrix().GetInternalValues()); | 	glLoadMatrixf(tran.GetMatrix().GetInternalValues()); | ||||||
|  | 	glDepthFunc(GL_LEQUAL); | ||||||
| 	glBegin(GL_QUADS); | 	glBegin(GL_QUADS); | ||||||
| 	glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z); | 	glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z); | ||||||
| 	glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z); | 	glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z); | ||||||
|   | |||||||
| @@ -14,8 +14,8 @@ class RemotePlayer : public Player { | |||||||
| public: | public: | ||||||
| 	enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16,  DEAD = 32 }; // A REVOIR VOIR DEFINE.H POUR LES ANIMES | 	enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16,  DEAD = 32 }; // A REVOIR VOIR DEFINE.H POUR LES ANIMES | ||||||
| 	 | 	 | ||||||
| 	RemotePlayer(netprot::PlayerInfo pinfo); | 	RemotePlayer(netprot::PlayerInfo* pinfo); | ||||||
| 	RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos); | 	RemotePlayer(netprot::PlayerInfo* pinfo, const Vector3f& pos); | ||||||
| 	~RemotePlayer(); | 	~RemotePlayer(); | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ Settings::Settings(Audio& audio) | |||||||
|     m_fullscreen(false), |     m_fullscreen(false), | ||||||
|     m_brightness(0.5f), |     m_brightness(0.5f), | ||||||
|     m_contrast(0.5f), |     m_contrast(0.5f), | ||||||
|     m_mouseSensitivity(0.5f) { |     m_mouseSensitivity(0.0f) { | ||||||
|     ApplyResolution(m_resolution); |     ApplyResolution(m_resolution); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								docs/Plan_de_test.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/Plan_de_test.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								docs/analyse_préliminaire.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/analyse_préliminaire.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								docs/documentation_developpeurs.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/documentation_developpeurs.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user