Ça plane pour pasmoi.
This commit is contained in:
parent
ea3d2ffc34
commit
935216e9c3
@ -246,6 +246,8 @@ void Player::RemoveBooster(float elapsedtime)
|
|||||||
}
|
}
|
||||||
void Player::SetDirection(Vector3f dir) { m_direction = dir; }
|
void Player::SetDirection(Vector3f dir) { m_direction = dir; }
|
||||||
|
|
||||||
|
void Player::Move(Vector3f diff) { m_position -= diff; }
|
||||||
|
|
||||||
Vector3f Player::GetPosition() const { return Vector3f(m_position.x + CHUNK_SIZE_X * WORLD_SIZE_X / 2, m_position.y, m_position.z + CHUNK_SIZE_Z * WORLD_SIZE_Y / 2); }
|
Vector3f Player::GetPosition() const { return Vector3f(m_position.x + CHUNK_SIZE_X * WORLD_SIZE_X / 2, m_position.y, m_position.z + CHUNK_SIZE_Z * WORLD_SIZE_Y / 2); }
|
||||||
|
|
||||||
Vector3f Player::GetPositionAbs() const { return m_position; }
|
Vector3f Player::GetPositionAbs() const { return m_position; }
|
||||||
|
@ -25,6 +25,7 @@ public:
|
|||||||
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
||||||
|
|
||||||
void SetDirection(Vector3f dir);
|
void SetDirection(Vector3f dir);
|
||||||
|
void Move(Vector3f diff);
|
||||||
Vector3f GetPosition() const;
|
Vector3f GetPosition() const;
|
||||||
Vector3f GetPositionAbs() const;
|
Vector3f GetPositionAbs() const;
|
||||||
Vector3f GetDirection() const;
|
Vector3f GetDirection() const;
|
||||||
|
@ -75,11 +75,11 @@ void Connection::getPacks(SOCKET sock) {
|
|||||||
|
|
||||||
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns) {
|
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns) {
|
||||||
while (!m_output_vector.empty()) {
|
while (!m_output_vector.empty()) {
|
||||||
std::cout << "c";
|
|
||||||
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;
|
||||||
|
std::cout << "c";
|
||||||
sendPackTo<Output>(sock, &out, &m_bufout, conn->getAddr());
|
sendPackTo<Output>(sock, &out, &m_bufout, conn->getAddr());
|
||||||
}
|
}
|
||||||
m_output_vector.pop_front();
|
m_output_vector.pop_front();
|
||||||
|
@ -400,8 +400,8 @@ void Engine::Init() {
|
|||||||
|
|
||||||
for (auto& [key, player] : m_conn.m_players) {
|
for (auto& [key, player] : m_conn.m_players) {
|
||||||
m_players[key] = new RemotePlayer(player);
|
m_players[key] = new RemotePlayer(player);
|
||||||
RemotePlayer* rt = (RemotePlayer*)m_players[key];
|
//RemotePlayer* rt = (RemotePlayer*)m_players[key];
|
||||||
rt->SetPosition(Vector3f(555, 555, 555));
|
m_players[key]->SetPosition(Vector3f(555, 555, 555));
|
||||||
}
|
}
|
||||||
|
|
||||||
seed = m_conn.getSeed();
|
seed = m_conn.getSeed();
|
||||||
@ -1244,20 +1244,14 @@ void Engine::Render(float elapsedTime) {
|
|||||||
|
|
||||||
gameTime += elapsedTime * 10;
|
gameTime += elapsedTime * 10;
|
||||||
|
|
||||||
//Vector3f dance = Vector3f(sin(gameTime), 0, cos(-gameTime));
|
|
||||||
//dance.Normalize();
|
|
||||||
//m_remotePlayer.ApplyPhysics(dance, &m_world, elapsedTime);
|
|
||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
//m_remotePlayer.Render(m_animeAtlas, m_shader01, all, elapsedTime);
|
|
||||||
|
|
||||||
//m_booster.RenderBillboard({ 195,16,195 }, m_textureAtlas, m_shader01, all);
|
//m_booster.RenderBillboard({ 195,16,195 }, m_textureAtlas, m_shader01, all);
|
||||||
|
|
||||||
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
|
|
||||||
//glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
||||||
//m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
|
|
||||||
|
|
||||||
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
@ -1332,12 +1326,21 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (Deserialize(&sync, pck, &bsize)) {
|
if (Deserialize(&sync, pck, &bsize)) {
|
||||||
if (sync.sid != m_conn.getId())
|
if (sync.sid != m_conn.getId())
|
||||||
break;
|
break;
|
||||||
// TODO: Vérifier si les positions concordent au sync local.
|
if (m_syncs.contains(sync.timestamp)) {
|
||||||
|
Sync comp = m_syncs[sync.timestamp];
|
||||||
|
m_player.InflictDamage(sync.hp - comp.hp);
|
||||||
|
|
||||||
|
Vector3f diff = sync.position - comp.position;
|
||||||
|
if (diff.Length() > .5)
|
||||||
|
m_player.Move(diff);
|
||||||
|
|
||||||
|
// TODO: m_timer = sync.timer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OUTPUT:
|
case OUTPUT:
|
||||||
if (Deserialize(&out, pck, &bsize)) {
|
if (Deserialize(&out, pck, &bsize)) {
|
||||||
RemotePlayer* r = (RemotePlayer*)m_players[out.id];
|
RemotePlayer* r = m_players[out.id];
|
||||||
if (!r)
|
if (!r)
|
||||||
break;
|
break;
|
||||||
r->Feed(out);
|
r->Feed(out);
|
||||||
@ -1350,9 +1353,9 @@ void Engine::Render(float elapsedTime) {
|
|||||||
lsPck.clear();
|
lsPck.clear();
|
||||||
|
|
||||||
for (auto& [key, player] : m_players) {
|
for (auto& [key, player] : m_players) {
|
||||||
RemotePlayer* rt = (RemotePlayer*)player;
|
std::cout << key << ": "; player->GetPosition().Afficher();
|
||||||
rt->Render(m_animeAtlas, m_shader01, all, elapsedTime);
|
player->Render(m_animeAtlas, m_shader01, all, elapsedTime);
|
||||||
m_otherplayerpos = rt->GetPosition();
|
m_otherplayerpos = player->GetPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user