This commit is contained in:
MarcEricMartel
2023-12-02 11:05:00 -05:00
parent 20eb410b08
commit 5a491c5446
10 changed files with 63 additions and 26 deletions

View File

@@ -122,6 +122,13 @@ void Connection::Run(World* world) {
last = m_input_vector.at(m_last_in);
el = (double)(in.timestamp - last.timestamp) / 1000.;
if (m_shoot_acc > 0.) {
m_shoot_acc -= el;
if (m_shoot_acc < 0.)
m_shoot_acc = 0;
}
player.get()->SetDirection(in.direction);
player.get()->ApplyPhysics(player.get()->GetInput(in.keys.forward,
in.keys.backward,
@@ -129,6 +136,13 @@ void Connection::Run(World* world) {
in.keys.right,
in.keys.jump, false, el), world, el);
//if (in.keys.block)
// ChunkDiffs.push_back()
if (in.keys.shoot && m_shoot_acc <= 0.)
Bullets.push_back(Bullet(player.get()->GetPOV() + player.get()->GetDirection(), player.get()->GetDirection()));
out.position = player.get()->GetPositionAbs();
out.direction = in.direction;
out.timestamp = in.timestamp;

View File

@@ -42,8 +42,8 @@ public:
bool m_nsync = true;
std::vector<Bullet> m_bullet_vector;
std::vector<ChunkMod> m_diff_vector;
std::vector<Bullet> Bullets;
std::vector<ChunkMod> ChunkDiffs;
private:
std::unordered_map<Timestamp, Input> m_input_manifest;
@@ -52,6 +52,7 @@ private:
std::deque<Output> m_output_vector;
std::unordered_map<Timestamp, Chat> m_chatlog;
float m_shoot_acc = 0;
SOCKET m_sock;
sockaddr_in m_addr;