Début de la classe remoteplayer.cpp, à vérifier

This commit is contained in:
Claudel-D-Roy 2023-10-15 16:23:43 -04:00
parent 183c5f186a
commit d7e55c8446
5 changed files with 76 additions and 1 deletions

2
.gitignore vendored
View File

@ -373,3 +373,5 @@ FodyWeavers.xsd
/x64/Release/SQCSim2023.exe
/x64/Debug/SQCSim2023.exe
/x64/Debug/SQCSim2021.pdb
SQCSim2021/SQCSim2021.vcxproj.filters
SQCSim2021/SQCSim2021.vcxproj

View File

@ -33,7 +33,11 @@ namespace netprot {
bool jumping,
shooting,
hit,
powerup;
powerup,
dead,
still,
jumpshot,
running;
};
struct Input { // cli -> srv UDP ~frame

View File

@ -41,6 +41,7 @@
<ClCompile Include="main.cpp" />
<ClCompile Include="mesh.cpp" />
<ClCompile Include="openglcontext.cpp" />
<ClCompile Include="remoteplayer.cpp" />
<ClCompile Include="shader.cpp" />
<ClCompile Include="skybox.cpp" />
<ClCompile Include="texture.cpp" />

View File

@ -94,5 +94,8 @@
<ClCompile Include="renderer.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="remoteplayer.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,65 @@
#include "remoteplayer.h"
#include <iostream>
#include <cstring>
RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), next() {
}
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;
//a revoir pour le jump et le shoot en meme temps lorsque les test seront possible
if (current.position != next.position)
{
Vector3f positionDelta = next.position - current.position;
m_position = next.position + positionDelta;
m_direction = next.direction;
m_team_id = next.id;
}
if(next.direction != current.direction)
{
m_direction = next.direction;
current.direction = next.direction;
}
if (next.states.shooting) {
m_animstate = Anim::SHOOTING;
}
else if (next.states.jumping) {
m_animstate = Anim::JUMPING;
}
else if (next.states.dead) {
m_animstate = Anim::DEAD;
}
else if(next.states.jumpshot){
m_animstate = Anim::JUMPSHOOT;
}
else if (next.states.still) {
m_animstate = Anim::STILL;
}
else if (next.states.running) {
m_animstate = Anim::RUNNING;
}
current.direction = next.direction;
current.position = next.position;
current.states = next.states;
current.id = next.id;
}