SQC-15_online #1
| @@ -370,6 +370,8 @@ void Engine::Init() { | |||||||
| 	// Init Chunks | 	// Init Chunks | ||||||
| 	m_world.GetChunks().Reset(nullptr); | 	m_world.GetChunks().Reset(nullptr); | ||||||
|  |  | ||||||
|  | 	m_startTime = std::chrono::high_resolution_clock::now(); | ||||||
|  |  | ||||||
| 	// Gestion de souris. | 	// Gestion de souris. | ||||||
| 	CenterMouse(); | 	CenterMouse(); | ||||||
| 	HideCursor(); | 	HideCursor(); | ||||||
| @@ -1102,11 +1104,13 @@ void Engine::Render(float elapsedTime) { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (m_networkgame) { | 		if (m_networkgame) { | ||||||
| 			netprot::Input input; | 			using namespace std::chrono; | ||||||
|  | 			using namespace netprot; | ||||||
|  | 			Input input; | ||||||
|  |  | ||||||
| 			input.sid = m_conn.getId(); | 			input.sid = m_conn.getId(); | ||||||
| 			input.direction = m_player.GetDirection(); | 			input.direction = m_player.GetDirection(); | ||||||
| 			input.timestamp = 12345; // TODO: Implémenter | 			input.timestamp = duration_cast<milliseconds>(high_resolution_clock::now() - m_startTime).count(); | ||||||
| 			input.keys.forward = m_keyW; | 			input.keys.forward = m_keyW; | ||||||
| 			input.keys.backward = m_keyS; | 			input.keys.backward = m_keyS; | ||||||
| 			input.keys.left = m_keyA; | 			input.keys.left = m_keyA; | ||||||
| @@ -1115,7 +1119,10 @@ void Engine::Render(float elapsedTime) { | |||||||
| 			input.keys.block = m_mouseR; | 			input.keys.block = m_mouseR; | ||||||
| 			input.keys.shoot = m_mouseL; | 			input.keys.shoot = m_mouseL; | ||||||
|  |  | ||||||
| 			netprot::sendPackTo<netprot::Input>(m_conn.m_sock_udp, &input, &m_buf, &m_conn.m_srvsockaddr); | 			sendPackTo<Input>(m_conn.m_sock_udp, &input, &m_buf, &m_conn.m_srvsockaddr); | ||||||
|  |  | ||||||
|  | 			// TODO: Faire la gestion de la réception de paquets. | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS) | 	else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS) | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
| #define ENGINE_H__ | #define ENGINE_H__ | ||||||
|  |  | ||||||
| #include <algorithm> | #include <algorithm> | ||||||
|  | #include <chrono> | ||||||
| #include <cmath> | #include <cmath> | ||||||
| #include "../SQCSim-common/array2d.h" | #include "../SQCSim-common/array2d.h" | ||||||
| #include "../SQCSim-common/blockinfo.h" | #include "../SQCSim-common/blockinfo.h" | ||||||
| @@ -89,6 +90,7 @@ private: | |||||||
|  |  | ||||||
|     std::map<uint64_t, Player*> m_players; |     std::map<uint64_t, Player*> m_players; | ||||||
|     netprot::Buffer m_buf; |     netprot::Buffer m_buf; | ||||||
|  |     std::chrono::high_resolution_clock::time_point m_startTime; | ||||||
|  |  | ||||||
|     //Menu |     //Menu | ||||||
|     enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY }; |     enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user