Update remoteplayer.cpp

This commit is contained in:
Claudel-D-Roy 2023-12-07 12:10:17 -05:00
parent 18f08feb68
commit 1d48242147

View File

@ -10,14 +10,10 @@
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, const Vector3f& pos) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) {
}
@ -98,11 +94,15 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
Vector3f DiffCam = GetPosition() - camera.GetPosition();
Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
Vector3f CrossA = DiffCam.Cross(UpCam);
Vector3f CrossB = DiffCam.Cross(CrossA);
CrossA.Normalize();
CrossB.Normalize();
Vector3f playerPosition = GetPosition() + Vector3f(0.f, -.75f, 0.f);
Vector3f v2 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v1 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v3 = (playerPosition + CrossA * 0.5 * width - CrossB * 0.5 * height);
@ -110,6 +110,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
Vector3f angleRemote = GetDirection();
Vector3f angleCam = (v1 - v2).Cross(v3 - v2);
angleCam.y = 0;
angleRemote.y = 0;
angleCam.Normalize();
@ -122,6 +123,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
static float time = 0.f;
static bool Shooting = false;
bool isLeft = side.y > 0;
time += elapsedTime;
if (time >= 200)
@ -129,25 +131,21 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
time -= 200;
if (!current.states.shooting)
Shooting = false;
else {
else
Shooting = !Shooting;
}
}
bool isLeft = side.y > 0;
if (angle >= 0.75) //Face //side positif
if (angle >= 0.75) //Face - side positif
{
if(current.states.shooting){
if (Shooting)
index = 17;
else
index = 9;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 41;
else
@ -158,20 +156,16 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else if (current.states.running && current.states.still)
index = 0;
}
else if (angle >= 0.25 && isLeft) //Frontleft
{
if (current.states.shooting) {
if (Shooting)
index = 18;
else
index = 10;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 42;
else
@ -185,15 +179,13 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (angle >= -0.25 && isLeft) //ProfileLeft
{
if (current.states.shooting) {
if (Shooting)
index = 20;
else
index = 12;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 44;
else
@ -207,15 +199,13 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (angle >= -0.75 && isLeft) //BackLeft
{
if (current.states.shooting) {
if (Shooting)
index = 22;
else
index = 14;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 46;
else
@ -226,17 +216,15 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else if (current.states.running && current.states.still)
index = 5;
}
else if (angle < -0.75) //Dos //side négatif
else if (angle < -0.75) //Dos - side négatif
{
if (current.states.shooting) {
if (Shooting)
index = 24;
else
index = 16;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 48;
else
@ -250,15 +238,13 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (angle >= 0.25 && !isLeft) //FrontRight
{
if (current.states.shooting) {
if (Shooting)
index = 19;
else
index = 11;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 43;
else
@ -272,15 +258,13 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (angle >= -0.25 && !isLeft) //ProfileRight
{
if (current.states.shooting) {
if (Shooting)
index = 21;
else
index = 13;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 45;
else
@ -294,15 +278,13 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (angle >= -0.75 && !isLeft) //BackRight
{
if (current.states.shooting) {
if (Shooting)
index = 23;
else
index = 15;
}
else if (current.states.jumpshot) {
else if (current.states.jumping && current.states.shooting) {
if (Shooting)
index = 47;
else