SQCSimulator2023/SQCSim2021/remoteplayer.cpp

72 lines
1.5 KiB
C++
Raw Normal View History

#include "remoteplayer.h"
#include <iostream>
#include <cstring>
2023-10-23 15:35:31 -04:00
RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
}
void RemotePlayer::Init() {
}
void RemotePlayer::Feed(const netprot::Output out) {
2023-10-23 15:35:31 -04:00
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
2023-10-23 15:35:31 -04:00
if (current.position != previous.position)
{
2023-10-23 15:35:31 -04:00
Vector3f positionDelta = current.position - previous.position;
m_position = current.position + positionDelta;
m_direction = current.direction;
2023-10-27 13:54:37 -04:00
//Rajouter un get ID public dans la classe player
//m_team_id = current.id;
}
2023-10-23 15:35:31 -04:00
if(current.direction != previous.direction)
{
2023-10-23 15:35:31 -04:00
m_direction = current.direction;
current.direction = current.direction;
}
2023-10-23 15:35:31 -04:00
if (current.states.shooting) {
2023-10-27 13:54:37 -04:00
//true;
m_animstate = Anim::SHOOTING;
}
2023-10-23 15:35:31 -04:00
else if (current.states.jumping) {
2023-10-27 13:54:37 -04:00
//true;
m_animstate = Anim::JUMPING;
}
2023-10-23 15:35:31 -04:00
else if (current.states.dead) {
2023-10-27 13:54:37 -04:00
//true;
m_animstate = Anim::DEAD;
}
2023-10-23 15:35:31 -04:00
else if(current.states.powerup){
2023-10-27 13:54:37 -04:00
//true;
2023-10-23 15:35:31 -04:00
m_animstate = Anim::POWERUP;
}
2023-10-23 15:35:31 -04:00
else if (current.states.still) {
2023-10-27 13:54:37 -04:00
//true;
m_animstate = Anim::STILL;
}
2023-10-23 15:35:31 -04:00
else if (current.states.running) {
2023-10-27 13:54:37 -04:00
//true;
m_animstate = Anim::RUNNING;
}
2023-10-23 15:35:31 -04:00
previous.direction = current.direction;
previous.position = current.position;
previous.states = current.states;
previous.id = current.id;
}