diff --git a/SQCSim2021/remoteplayer.cpp b/SQCSim2021/remoteplayer.cpp index 6dfb3a4..1bf39c9 100644 --- a/SQCSim2021/remoteplayer.cpp +++ b/SQCSim2021/remoteplayer.cpp @@ -3,7 +3,7 @@ #include -RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), next() { +RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() { } @@ -13,52 +13,58 @@ void RemotePlayer::Init() { void RemotePlayer::Feed(const netprot::Output out) { - next.position = out.position; - next.direction = out.direction; - next.states = out.states; - next.id = out.id; + current.position = out.position; + current.direction = out.direction; + current.states = out.states; + current.id = out.id; //a revoir pour le jump et le shoot en meme temps lorsque les test seront possible - if (current.position != next.position) + if (current.position != previous.position) { - Vector3f positionDelta = next.position - current.position; - m_position = next.position + positionDelta; - m_direction = next.direction; - m_team_id = next.id; + Vector3f positionDelta = current.position - previous.position; + m_position = current.position + positionDelta; + m_direction = current.direction; + m_team_id = current.id; } - if(next.direction != current.direction) + if(current.direction != previous.direction) { - m_direction = next.direction; - current.direction = next.direction; + m_direction = current.direction; + current.direction = current.direction; } - if (next.states.shooting) { + if (current.states.shooting) { + true; m_animstate = Anim::SHOOTING; } - else if (next.states.jumping) { + else if (current.states.jumping) { + true; m_animstate = Anim::JUMPING; } - else if (next.states.dead) { + else if (current.states.dead) { + true; m_animstate = Anim::DEAD; } - else if(next.states.jumpshot){ - m_animstate = Anim::JUMPSHOOT; + else if(current.states.powerup){ + true; + m_animstate = Anim::POWERUP; } - else if (next.states.still) { + else if (current.states.still) { + true; m_animstate = Anim::STILL; } - else if (next.states.running) { + else if (current.states.running) { + true; m_animstate = Anim::RUNNING; } - current.direction = next.direction; - current.position = next.position; - current.states = next.states; - current.id = next.id; + previous.direction = current.direction; + previous.position = current.position; + previous.states = current.states; + previous.id = current.id; diff --git a/SQCSim2021/remoteplayer.h b/SQCSim2021/remoteplayer.h index bc84d76..70b585b 100644 --- a/SQCSim2021/remoteplayer.h +++ b/SQCSim2021/remoteplayer.h @@ -8,7 +8,7 @@ class RemotePlayer : public Player { public: - enum Anim { STILL, RUNNING, JUMPING, SHOOTING, JUMPSHOOT, DEAD }; + enum Anim { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 }; RemotePlayer(); @@ -16,7 +16,7 @@ public: void Feed(const netprot::Output out); private: - netprot::Output current, next; + netprot::Output current, previous; float m_aminacc; Anim m_animstate; uint64_t m_team_id;