Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online

This commit is contained in:
MarcEricMartel 2023-12-13 16:10:34 -05:00
commit 7b350fa403

View File

@ -8,7 +8,7 @@
RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)){ RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)) {
} }
@ -24,7 +24,7 @@ RemotePlayer::~RemotePlayer()
void RemotePlayer::Init() void RemotePlayer::Init()
{ {
} }
void RemotePlayer::Feed(const netprot::Output out) { void RemotePlayer::Feed(const netprot::Output out) {
@ -108,7 +108,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
Vector3f angleRemote = GetDirection(); Vector3f angleRemote = GetDirection();
Vector3f angleCam = (v1 - v2).Cross(v3 - v2); Vector3f angleCam = (v1 - v2).Cross(v3 - v2);
angleCam.y = 0; angleCam.y = 0;
angleRemote.y = 0; angleRemote.y = 0;
angleCam.Normalize(); angleCam.Normalize();
@ -127,21 +127,16 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
time += elapsedTime; time += elapsedTime;
if (time >= 0.05) if (time >= 0.05)
{ {
time -= 0.05; time -= 0.05;
Shooting = !Shooting; Shooting = !Shooting;
/*if (!current.states.shooting)
Shooting = false;
else
Shooting = true;*/
} }
std::cout << Shooting << std::endl;
//std::cout << time << std::endl; std::cout << "shooting : " << current.states.shooting << " jumping : " << current.states.jumping << " jumpshot : " << current.states.jumpshot << " running : " << current.states.running << " still : " << current.states.still << " dead : " << current.states.dead << " hit : " << current.states.hit << std::endl;
//std::cout << "shooting : " << current.states.shooting << " jumping : " << current.states.jumping << " jumpshot : " << current.states.jumpshot << " running : " << current.states.running << " still : " << current.states.still << " dead : " << current.states.dead << " hit : " << current.states.hit << std::endl;
if (angle >= 0.75) //Face - side positif if (angle >= 0.75) //Face - side positif
{ {
if(current.states.shooting){ if (current.states.shooting) {
if (Shooting) if (Shooting)
index = 17; index = 17;
else else
@ -174,12 +169,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else else
index = 34; index = 34;
} }
else if (current.states.jumping ) else if (current.states.jumping)
index = 26; index = 26;
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 1; index = 1;
} }
else if (angle >= -0.25 && isLeft) //ProfileLeft else if (angle >= -0.25 && isLeft) //ProfileLeft
{ {
@ -190,18 +185,18 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 12; index = 12;
} }
else if (current.states.jumpshot ) { else if (current.states.jumpshot) {
if (Shooting) if (Shooting)
index = 44; index = 44;
else else
index = 36; index = 36;
} }
else if (current.states.jumping ) else if (current.states.jumping)
index = 28; index = 28;
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 3; index = 3;
} }
else if (angle >= -0.75 && isLeft) //BackLeft else if (angle >= -0.75 && isLeft) //BackLeft
{ {
@ -240,12 +235,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else else
index = 40; index = 40;
} }
else if (current.states.jumping ) else if (current.states.jumping)
index = 32; index = 32;
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot) else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 7; index = 7;
} }
else if (angle >= 0.25 && !isLeft) //FrontRight //REVOIR L'ANIME DE SHOOTING EST PAS DRETTE else if (angle >= 0.25 && !isLeft) //FrontRight //REVOIR L'ANIME DE SHOOTING EST PAS DRETTE
{ {
@ -311,7 +306,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
} }
float u, v, w, h; float u, v, w, h;
@ -321,9 +316,23 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
atlas.TextureIndexToCoord(index, u, v, w, h); atlas.TextureIndexToCoord(index, u, v, w, h);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (current.states.hit)
{
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendColor(1.f, 0.f, 0.f, 1.f);
}
else {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues()); glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z); glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);