Envoi des millis avec les Inputs
This commit is contained in:
@@ -370,6 +370,8 @@ void Engine::Init() {
|
||||
// Init Chunks
|
||||
m_world.GetChunks().Reset(nullptr);
|
||||
|
||||
m_startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Gestion de souris.
|
||||
CenterMouse();
|
||||
HideCursor();
|
||||
@@ -1102,11 +1104,13 @@ void Engine::Render(float elapsedTime) {
|
||||
}
|
||||
|
||||
if (m_networkgame) {
|
||||
netprot::Input input;
|
||||
using namespace std::chrono;
|
||||
using namespace netprot;
|
||||
Input input;
|
||||
|
||||
input.sid = m_conn.getId();
|
||||
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.backward = m_keyS;
|
||||
input.keys.left = m_keyA;
|
||||
@@ -1115,7 +1119,10 @@ void Engine::Render(float elapsedTime) {
|
||||
input.keys.block = m_mouseR;
|
||||
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)
|
||||
|
Reference in New Issue
Block a user