Merge remote-tracking branch 'origin/SQC-15_animation' into SQC-15_paquets
This commit is contained in:
commit
e011e2f1fc
@ -106,7 +106,11 @@ namespace netprot {
|
|||||||
uint64_t id = 0,
|
uint64_t id = 0,
|
||||||
tid = 0;
|
tid = 0;
|
||||||
PlayerInfo() {}
|
PlayerInfo() {}
|
||||||
PlayerInfo(PlayerInfo* log) : id(log->id), tid(log->tid) { strcpy(log->name, name); }
|
PlayerInfo(PlayerInfo* log) : id(log->id), tid(log->tid) {
|
||||||
|
strcpy(log->name, name);
|
||||||
|
};
|
||||||
|
PlayerInfo(int id, int tid, std::string strname) : id(id), tid(tid) { memcpy((void*)strname.c_str(), name, strname.length());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameInfo { // cli <-> srv TCP event (before game start)/ once
|
struct GameInfo { // cli <-> srv TCP event (before game start)/ once
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
@ -51,6 +52,8 @@ protected:
|
|||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -11,12 +11,13 @@ struct Notification {
|
|||||||
float displayStartTime = 0.0f;
|
float displayStartTime = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Use a queue to manage notifications
|
// Use a queue to manage notifications
|
||||||
//std::queue<Notification> notificationQueue;
|
//std::queue<Notification> notificationQueue;
|
||||||
// Use a vector to manage notifications
|
// Use a vector to manage notifications
|
||||||
std::vector<Notification> notifications;
|
std::vector<Notification> notifications;
|
||||||
|
|
||||||
Engine::Engine() {}
|
Engine::Engine() : m_remotePlayer(&m_pinfo), m_pinfo(){}
|
||||||
|
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
m_world.CleanUpWorld(m_renderCount, true);
|
m_world.CleanUpWorld(m_renderCount, true);
|
||||||
@ -316,7 +317,6 @@ void Engine::DrawPause()
|
|||||||
|
|
||||||
void Engine::Init() {
|
void Engine::Init() {
|
||||||
|
|
||||||
|
|
||||||
GLenum glewErr = glewInit();
|
GLenum glewErr = glewInit();
|
||||||
if (glewErr != GLEW_OK) {
|
if (glewErr != GLEW_OK) {
|
||||||
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
||||||
@ -415,6 +415,7 @@ void Engine::Init() {
|
|||||||
|
|
||||||
m_startTime = std::chrono::high_resolution_clock::now();
|
m_startTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
|
||||||
// Gestion de souris.
|
// Gestion de souris.
|
||||||
CenterMouse();
|
CenterMouse();
|
||||||
HideCursor();
|
HideCursor();
|
||||||
@ -844,6 +845,7 @@ void Engine::DisplaySingleOrMultiplayerMenu() {
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
|
||||||
// Single Player and Multiplayer button background quads
|
// Single Player and Multiplayer button background quads
|
||||||
float buttonWidthProportion = 0.4f;
|
float buttonWidthProportion = 0.4f;
|
||||||
float buttonHeightProportion = 0.075f;
|
float buttonHeightProportion = 0.075f;
|
||||||
@ -1077,6 +1079,11 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
||||||
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
m_remotePlayer.Render(m_textureAtlas, m_shader01, elapsedTime);
|
||||||
|
//m_remotePlayer.ApplyTransformation(all);
|
||||||
|
|
||||||
if (m_mouseWU) bloc++;
|
if (m_mouseWU) bloc++;
|
||||||
else if (m_mouseWD) bloc--;
|
else if (m_mouseWD) bloc--;
|
||||||
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
|
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
|
||||||
@ -1131,7 +1138,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
//m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "remoteplayer.h"
|
#include "remoteplayer.h"
|
||||||
|
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
@ -148,7 +149,8 @@ private:
|
|||||||
float m_mousemy = 0;
|
float m_mousemy = 0;
|
||||||
|
|
||||||
bool m_networkgame = false;
|
bool m_networkgame = false;
|
||||||
|
netprot::PlayerInfo m_pinfo;
|
||||||
|
RemotePlayer m_remotePlayer;
|
||||||
std::string m_messageNotification = "";
|
std::string m_messageNotification = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,26 @@
|
|||||||
#include "remoteplayer.h"
|
#include "remoteplayer.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include "texture.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
|
||||||
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : Player(Vector3f(0, 0, 0), 0, 0), m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
|
|
||||||
|
|
||||||
|
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), 0, 0) {
|
||||||
|
|
||||||
|
LoadTexture(m_texture_front, TEXTURE_PATH "AssetOtherPlayer/FinalPNGStanding/BlueFrontRight.png", false, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//RemotePlayer::RemotePlayer()
|
||||||
|
//{
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
RemotePlayer::~RemotePlayer()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::Init() {
|
void RemotePlayer::Init() {
|
||||||
@ -68,3 +84,30 @@ void RemotePlayer::Feed(const netprot::Output out) {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, float elapsedTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_texture_front.Bind();
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 0); glVertex2f(0, 500);
|
||||||
|
glTexCoord2f(1, 0); glVertex2f(500, 500);
|
||||||
|
glTexCoord2f(1, 1); glVertex2f(500, 0);
|
||||||
|
glTexCoord2f(0, 1); glVertex2f(0, 0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemotePlayer::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError)
|
||||||
|
{
|
||||||
|
texture.Load(filename, useMipmaps);
|
||||||
|
if (!texture.IsValid()) {
|
||||||
|
std::cerr << "Unable to load texture (" << filename << ")" << std::endl;
|
||||||
|
if (stopOnError)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -5,15 +5,24 @@
|
|||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
#include "texture.h"
|
||||||
|
#include "openglcontext.h"
|
||||||
|
|
||||||
class RemotePlayer : public Player {
|
class RemotePlayer : public Player {
|
||||||
public:
|
public:
|
||||||
enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
||||||
|
|
||||||
|
/*RemotePlayer();*/
|
||||||
|
|
||||||
RemotePlayer(netprot::PlayerInfo pinfo);
|
RemotePlayer(netprot::PlayerInfo pinfo);
|
||||||
|
|
||||||
|
~RemotePlayer();
|
||||||
|
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Feed(const netprot::Output out);
|
void Feed(const netprot::Output out);
|
||||||
|
void Render(TextureAtlas& atlas, Shader& shader, float elapsedTime);
|
||||||
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
netprot::Output current, previous;
|
netprot::Output current, previous;
|
||||||
@ -22,6 +31,8 @@ private:
|
|||||||
float m_aminacc;
|
float m_aminacc;
|
||||||
Anim m_animstate;
|
Anim m_animstate;
|
||||||
uint64_t m_team_id;
|
uint64_t m_team_id;
|
||||||
|
Texture m_texture_front;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user