Compare commits
5 Commits
sqc-14_cla
...
SQC_17_HUD
Author | SHA1 | Date | |
---|---|---|---|
|
fc4a22e844 | ||
|
c7271f6217 | ||
|
8ebe7b95fc | ||
|
df5b7960b2 | ||
|
db0a39f64a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -373,5 +373,3 @@ FodyWeavers.xsd
|
|||||||
/x64/Release/SQCSim2023.exe
|
/x64/Release/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2023.exe
|
/x64/Debug/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2021.pdb
|
/x64/Debug/SQCSim2021.pdb
|
||||||
SQCSim2021/SQCSim2021.vcxproj.filters
|
|
||||||
SQCSim2021/SQCSim2021.vcxproj
|
|
||||||
|
@@ -33,11 +33,7 @@ namespace netprot {
|
|||||||
bool jumping,
|
bool jumping,
|
||||||
shooting,
|
shooting,
|
||||||
hit,
|
hit,
|
||||||
powerup,
|
powerup;
|
||||||
dead,
|
|
||||||
still,
|
|
||||||
jumpshot,
|
|
||||||
running;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Input { // cli -> srv UDP ~frame
|
struct Input { // cli -> srv UDP ~frame
|
||||||
|
@@ -8,8 +8,6 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
|
|||||||
m_username = "Zelda Bee-Bop56";
|
m_username = "Zelda Bee-Bop56";
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player() {}
|
|
||||||
|
|
||||||
void Player::TurnLeftRight(float value) {
|
void Player::TurnLeftRight(float value) {
|
||||||
m_rotY += value;
|
m_rotY += value;
|
||||||
if (m_rotY > 360) m_rotY = 0;
|
if (m_rotY > 360) m_rotY = 0;
|
||||||
@@ -208,9 +206,3 @@ void Player::Teleport(int& x, int& z) {
|
|||||||
m_position.x -= x * CHUNK_SIZE_X;
|
m_position.x -= x * CHUNK_SIZE_X;
|
||||||
m_position.z -= z * CHUNK_SIZE_Z;
|
m_position.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Player::getId() const { return id; }
|
|
||||||
|
|
||||||
Vector3f Player::InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now) {
|
|
||||||
return Vector3f();
|
|
||||||
}
|
|
||||||
|
@@ -12,8 +12,6 @@ public:
|
|||||||
enum Sound { NOSOUND, STEP, FALL };
|
enum Sound { NOSOUND, STEP, FALL };
|
||||||
|
|
||||||
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
||||||
~Player();
|
|
||||||
|
|
||||||
void TurnLeftRight(float value);
|
void TurnLeftRight(float value);
|
||||||
void TurnTopBottom(float value);
|
void TurnTopBottom(float value);
|
||||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||||
@@ -28,13 +26,12 @@ public:
|
|||||||
float GetHP() const;
|
float GetHP() const;
|
||||||
void Teleport(int& x, int& z);
|
void Teleport(int& x, int& z);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
Vector3f m_position;
|
Vector3f m_position;
|
||||||
Vector3f m_velocity;
|
Vector3f m_velocity;
|
||||||
Vector3f m_direction;
|
Vector3f m_direction;
|
||||||
|
|
||||||
std::string m_username;
|
std::string m_username;
|
||||||
uint64_t id = 0;
|
|
||||||
|
|
||||||
float m_rotX = 0;
|
float m_rotX = 0;
|
||||||
float m_rotY = 0;
|
float m_rotY = 0;
|
||||||
@@ -43,9 +40,6 @@ protected:
|
|||||||
float m_hp;
|
float m_hp;
|
||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
|
|
||||||
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //_PLAYER_H__
|
#endif //_PLAYER_H__
|
||||||
|
|
||||||
|
@@ -25,14 +25,13 @@
|
|||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
<ClInclude Include="mesh.h" />
|
<ClInclude Include="mesh.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
<ClInclude Include="remoteplayer.h" />
|
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
<ClInclude Include="textureatlas.h" />
|
<ClInclude Include="textureatlas.h" />
|
||||||
<ClInclude Include="tool.h" />
|
<ClInclude Include="tool.h" />
|
||||||
<ClInclude Include="vertexbuffer.h" />
|
<ClInclude Include="vertexbuffer.h" />
|
||||||
<ClInclude Include="renderer.h" />
|
<ClInclude Include="worldrenderer.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="audio.cpp" />
|
<ClCompile Include="audio.cpp" />
|
||||||
@@ -41,14 +40,13 @@
|
|||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="mesh.cpp" />
|
<ClCompile Include="mesh.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
<ClCompile Include="remoteplayer.cpp" />
|
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
<ClCompile Include="textureatlas.cpp" />
|
<ClCompile Include="textureatlas.cpp" />
|
||||||
<ClCompile Include="tool.cpp" />
|
<ClCompile Include="tool.cpp" />
|
||||||
<ClCompile Include="vertexbuffer.cpp" />
|
<ClCompile Include="vertexbuffer.cpp" />
|
||||||
<ClCompile Include="renderer.cpp" />
|
<ClCompile Include="worldrenderer.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
||||||
|
@@ -47,10 +47,7 @@
|
|||||||
<ClInclude Include="mesh.h">
|
<ClInclude Include="mesh.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="renderer.h">
|
<ClInclude Include="worldrenderer.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="remoteplayer.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -91,10 +88,7 @@
|
|||||||
<ClCompile Include="mesh.cpp">
|
<ClCompile Include="mesh.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="renderer.cpp">
|
<ClCompile Include="worldrenderer.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="remoteplayer.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -17,8 +17,6 @@ public:
|
|||||||
|
|
||||||
//void SendInput();
|
//void SendInput();
|
||||||
//int Sync();
|
//int Sync();
|
||||||
|
|
||||||
// void updateRemotePlayers(std::map<RemotePlayers> rplayers);
|
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA m_wsaData;
|
WSADATA m_wsaData;
|
||||||
|
@@ -20,12 +20,12 @@
|
|||||||
#define SRV_ADDR "127.0.0.1"
|
#define SRV_ADDR "127.0.0.1"
|
||||||
#define COUNTDOWN 300
|
#define COUNTDOWN 300
|
||||||
|
|
||||||
#define BASE_WIDTH 1920
|
#define BASE_WIDTH 1600
|
||||||
#define BASE_HEIGHT 1080
|
#define BASE_HEIGHT 900
|
||||||
|
|
||||||
#define TEXTURE_PATH "./media/textures/"
|
#define TEXTURE_PATH "./media/textures/"
|
||||||
#define SHADER_PATH "./media/shaders/"
|
#define SHADER_PATH "./media/shaders/"
|
||||||
#define AUDIO_PATH "./media/audio/"
|
#define AUDIO_PATH "./media/audio/"
|
||||||
#define CHUNK_PATH "./media/chunks/"
|
#define CHUNK_PATH "./media/chunks/"
|
||||||
|
|
||||||
#endif // DEFINE_H__
|
#endif // DEFINE_H__
|
||||||
|
@@ -5,8 +5,6 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Define a structure to represent notifications
|
// Define a structure to represent notifications
|
||||||
struct Notification {
|
struct Notification {
|
||||||
std::string message;
|
std::string message;
|
||||||
@@ -96,6 +94,9 @@ void Engine::LoadResource() {
|
|||||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
||||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
||||||
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
|
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
|
||||||
|
LoadTexture(m_texturePovGun, TEXTURE_PATH "GUN.png", false);
|
||||||
|
LoadTexture(m_textureSoloMultiMenu, TEXTURE_PATH "single_multi.png", false);
|
||||||
|
LoadTexture(m_textureTitle, TEXTURE_PATH "title.png", false);
|
||||||
|
|
||||||
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
||||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
||||||
@@ -146,7 +147,6 @@ void Engine::KillNotification(Player killer, Player killed) {
|
|||||||
DisplayNotification(message);
|
DisplayNotification(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Engine::DisplayNotification(std::string message) {
|
void Engine::DisplayNotification(std::string message) {
|
||||||
|
|
||||||
if (message.length() > 45) {
|
if (message.length() > 45) {
|
||||||
@@ -162,17 +162,22 @@ void Engine::DisplayNotification(std::string message) {
|
|||||||
|
|
||||||
// Add a method to process the notification queue
|
// Add a method to process the notification queue
|
||||||
void Engine::ProcessNotificationQueue() {
|
void Engine::ProcessNotificationQueue() {
|
||||||
m_textureFont.Bind();
|
//PrintText(fPosX, fUsernamePosY, ss.str(), 1.5f);
|
||||||
float scale = GetScale();
|
//float fPosX = (Width() / 100.0f) * scaleX;
|
||||||
unsigned int xOffset = Width() - Width() * 0.26;
|
//float fPosY = Height() - (Height() * 0.05) * scaleY;
|
||||||
unsigned int yOffset = Height() - (Height() / 2.2);
|
|
||||||
|
m_textureFont.Bind();
|
||||||
|
|
||||||
|
auto [scaleX, scaleY] = GetScale();
|
||||||
|
|
||||||
|
float xOffset = (Width() / 1.5f) * scaleX;
|
||||||
|
float yOffset = (Height() / 1.2f) * scaleY;
|
||||||
|
|
||||||
// Iterate through the notifications and display them
|
|
||||||
for (auto it = notifications.begin(); it != notifications.end(); ) {
|
for (auto it = notifications.begin(); it != notifications.end(); ) {
|
||||||
float timeSinceDisplay = m_time - it->displayStartTime;
|
float timeSinceDisplay = m_time - it->displayStartTime;
|
||||||
|
|
||||||
// Display the notification message with vertical offset
|
float y = yOffset - (20.0f * scaleX * (it - notifications.begin()));
|
||||||
unsigned int y = yOffset - (static_cast<unsigned int>(scale * 20) * (it - notifications.begin()));
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
@@ -188,9 +193,7 @@ void Engine::ProcessNotificationQueue() {
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
PrintText(xOffset, y, it->message);
|
||||||
|
|
||||||
PrintText(xOffset, y, scale, it->message);
|
|
||||||
|
|
||||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
@@ -200,94 +203,155 @@ void Engine::ProcessNotificationQueue() {
|
|||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
// Check if it's time to remove the notification (display for 2 seconds)
|
|
||||||
if (timeSinceDisplay >= 4.0f) {
|
if (timeSinceDisplay >= 4.0f) {
|
||||||
it = notifications.erase(it); // Remove the notification
|
it = notifications.erase(it);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Engine::DisplayCrosshair() {
|
void Engine::DisplayCrosshair() {
|
||||||
m_textureCrosshair.Bind();
|
m_textureCrosshair.Bind();
|
||||||
static const int crossSize = 32;
|
static const int crossSize = 32;
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslated(Width() / 2 - crossSize / 2, Height() / 2 - crossSize / 2, 0);
|
glTranslated(Width() / 2 - crossSize / 2, Height() / 2 - crossSize / 2, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0);
|
glTexCoord2f(0, 0);
|
||||||
glVertex2i(0, 0);
|
glVertex2i(0, 0);
|
||||||
glTexCoord2f(1, 0);
|
glTexCoord2f(1, 0);
|
||||||
glVertex2i(crossSize, 0);
|
glVertex2i(crossSize, 0);
|
||||||
glTexCoord2f(1, 1);
|
glTexCoord2f(1, 1);
|
||||||
glVertex2i(crossSize, crossSize);
|
glVertex2i(crossSize, crossSize);
|
||||||
glTexCoord2f(0, 1);
|
glTexCoord2f(0, 1);
|
||||||
glVertex2i(0, crossSize);
|
glVertex2i(0, crossSize);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::DisplayPovGun() {
|
||||||
|
// Setter le blend function, tout ce qui sera noir sera transparent
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
float scaleX = (Width()) / BASE_WIDTH;
|
||||||
|
float scaleY = (Height()) / BASE_HEIGHT;
|
||||||
|
float baseXOffset = 0.4958 * BASE_WIDTH;
|
||||||
|
float baseWidth = 0.4688 * BASE_WIDTH;
|
||||||
|
float baseHeight = 0.5787 * BASE_HEIGHT;
|
||||||
|
float xTranslation = baseXOffset * scaleX;
|
||||||
|
float quadWidth = baseWidth * scaleX;
|
||||||
|
float quadHeight = baseHeight * scaleY;
|
||||||
|
|
||||||
|
m_texturePovGun.Bind();
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslated(xTranslation, 0, 0);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2i(0, 0);
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2i(quadWidth, 0);
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2i(quadWidth, quadHeight);
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2i(0, quadHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Reset du blend function
|
||||||
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::DisplayCurrentItem() {
|
void Engine::DisplayCurrentItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DisplayHud(int timer) {
|
void Engine::DisplayHud(int timer) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glDisable(GL_BLEND);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
auto [scaleX, scaleY] = GetScale();
|
||||||
|
|
||||||
|
float fBackPosX = (Width() / 25.0f) * scaleX;
|
||||||
|
float fBackPosY = (Height() - (Height() * 0.815) * scaleY);
|
||||||
|
float fBackWidth = (Width() / 4.0f) * scaleX;
|
||||||
|
float fBackHeight = (Height() / 5.5f) * scaleY;
|
||||||
|
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2f(fBackPosX, fBackPosY);
|
||||||
|
glVertex2f(fBackPosX + fBackWidth, fBackPosY);
|
||||||
|
glVertex2f(fBackPosX + fBackWidth, fBackPosY + fBackHeight);
|
||||||
|
glVertex2f(fBackPosX, fBackPosY + fBackHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// HP Bar
|
||||||
|
float fBarWidth = (Width() / 4.0f) * scaleX;
|
||||||
|
float fBarHeight = (Height() / 25.0f) * scaleY;
|
||||||
|
float fPosX = (Width() / 25.0f) * scaleX;
|
||||||
|
float fBarPosY = (Height() - (Height() * 0.775) * scaleY);
|
||||||
|
|
||||||
// Barre HP
|
|
||||||
float fBarWidth = Width() / 4;
|
|
||||||
float fBarHeight = Height() / 25;
|
|
||||||
float fPosX = Width() / 20;
|
|
||||||
float fPosY = Height() - (Height() - (fBarHeight * 4));
|
|
||||||
float playerHp = m_player.GetHP();
|
float playerHp = m_player.GetHP();
|
||||||
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
||||||
|
|
||||||
// Arri<EFBFBD>re-plan (Barre HP)
|
// HP Bar Background
|
||||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
glVertex2f(fPosX, fBarPosY - fBarHeight);
|
||||||
glVertex2f(fPosX + fBarWidth, fPosY - fBarHeight); // Bas-Droite
|
glVertex2f(fPosX + fBarWidth, fBarPosY - fBarHeight);
|
||||||
glVertex2f(fPosX + fBarWidth, fPosY); // Haut-Droite
|
glVertex2f(fPosX + fBarWidth, fBarPosY);
|
||||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
glVertex2f(fPosX, fBarPosY);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//TODO: Associer avec m<>chanique de vie du joueur
|
// Current HP
|
||||||
|
|
||||||
// Barre HP
|
|
||||||
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
glVertex2f(fPosX, fBarPosY - fBarHeight);
|
||||||
glVertex2f(fPosX + fBarWidth * playerHp, fPosY - fBarHeight); // Bas-Droite
|
glVertex2f(fPosX + fBarWidth * playerHp, fBarPosY - fBarHeight);
|
||||||
glVertex2f(fPosX + fBarWidth * playerHp, fPosY); // Haut-Droite
|
glVertex2f(fPosX + fBarWidth * playerHp, fBarPosY);
|
||||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
glVertex2f(fPosX, fBarPosY);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// Barre <20>quip
|
// Equip Bar
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||||
|
|
||||||
|
float fEquipWidth = (Width() * 0.175f) * scaleX;
|
||||||
|
float fEquipHeight = (fEquipWidth / 2.5) * scaleY;
|
||||||
|
float fEquipPosY = (Height() - (Height() * 0.765) * scaleY);
|
||||||
|
|
||||||
|
glTranslatef(fPosX, fEquipPosY, 0);
|
||||||
|
|
||||||
m_textureGun.Bind();
|
m_textureGun.Bind();
|
||||||
|
|
||||||
float margin = Width() * 0.05;
|
|
||||||
float itemWidth = Width() * 0.33;
|
|
||||||
float itemHeight = itemWidth / 2.208;
|
|
||||||
float startX = Width() - itemWidth - margin;
|
|
||||||
float startY = margin;
|
|
||||||
|
|
||||||
glTranslated(startX, startY, 0);
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(1, 0); glVertex2i(0, 0);
|
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||||
glTexCoord2f(0, 0); glVertex2i(itemWidth, 0);
|
glTexCoord2f(1, 0); glVertex2i(fEquipWidth, 0);
|
||||||
glTexCoord2f(0, 1); glVertex2i(itemWidth, itemHeight);
|
glTexCoord2f(1, 1); glVertex2i(fEquipWidth, fEquipHeight);
|
||||||
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
|
glTexCoord2f(0, 1); glVertex2i(0, fEquipHeight);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
@@ -295,54 +359,161 @@ void Engine::DisplayHud(int timer) {
|
|||||||
// Username
|
// Username
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor3f(1.0f, 1.0f, 1.0f);
|
||||||
float scale = GetScale();
|
|
||||||
m_textureFont.Bind();
|
m_textureFont.Bind();
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << m_player.GetUsername();
|
float fUsernamePosY = fBarPosY - (fBarHeight * 2) * scaleY;
|
||||||
PrintText(fPosX, fPosY, scale, ss.str());
|
|
||||||
|
|
||||||
//Countdown
|
ss.str("");
|
||||||
|
ss << m_player.GetUsername();
|
||||||
|
PrintText(fPosX, fUsernamePosY, ss.str(), 1.5f);
|
||||||
|
|
||||||
|
ss.str("");
|
||||||
|
ss << m_player.GetHP() * 100 << "%";
|
||||||
|
PrintText(fPosX * 6.25, fUsernamePosY, ss.str(), 1.5f);
|
||||||
|
|
||||||
|
// Countdown
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "Time: " << (int)(timer / 60) << ":" << std::setw(2) << std::setfill('0') << timer % 60;
|
ss << "Time: " << (int)(timer / 60) << ":" << std::setw(2) << std::setfill('0') << timer % 60;
|
||||||
PrintText(Width() - Width() * 0.15, Height() - (Height() / 19.2), scale, ss.str());
|
PrintText(Width() - (Width() * 0.2f) * scaleX, Height() - (Height() * 0.1) * scaleY, ss.str(), 2.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||||
// Bind de la texture pour le font
|
|
||||||
m_textureFont.Bind();
|
m_textureFont.Bind();
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
|
|
||||||
float scale = GetScale();
|
auto [scaleX, scaleY] = GetScale();
|
||||||
unsigned int x = Width() / 25;
|
|
||||||
|
float fPosX = (Width() / 100.0f) * scaleX;
|
||||||
|
float fPosY = Height() - (Height() * 0.05) * scaleY;
|
||||||
|
float charSize = 20 + (24 - 20) * (Width() - 1600) / (1920 - 1600);
|
||||||
|
|
||||||
ss << " Fps : " << GetFps(elapsedTime);
|
ss << " Fps : " << GetFps(elapsedTime);
|
||||||
PrintText(x, Height() - (Height() / 19.2), scale, ss.str());
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
ss << " Rendered Chunks : " << m_renderCount;
|
ss << " Rendered Chunks : " << m_renderCount;
|
||||||
PrintText(x, Height() - (Height() / 13.7), scale, ss.str());
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
||||||
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
fPosY -= charSize;
|
||||||
PrintText(x, Height() / 48, scale, ss.str());
|
|
||||||
|
float fPosYJump = ((Height() - (Height() * 0.9f)) * scaleY);
|
||||||
|
fPosY = fPosYJump;
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
|
ss << " Velocity : " << m_player.GetVelocity();
|
||||||
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
ss << " Direction : " << m_player.GetDirection();
|
ss << " Direction : " << m_player.GetDirection();
|
||||||
PrintText(x, Height() / 24, scale, ss.str());
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
ss << " Position : " << m_player.GetPosition();
|
ss << " Position : " << m_player.GetPosition();
|
||||||
PrintText(x, Height() / 16, scale, ss.str());
|
PrintText(fPosX, fPosY, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
|
fPosY -= charSize;
|
||||||
|
|
||||||
ss << " Block : ";
|
ss << " Block : ";
|
||||||
|
|
||||||
if (bloc == BTYPE_LAST)
|
if (bloc == BTYPE_LAST)
|
||||||
ss << "Weapon.";
|
ss << "Weapon";
|
||||||
else ss << (int)bloc;
|
else
|
||||||
|
ss << (int)bloc;
|
||||||
|
PrintText(fPosX, fPosYJump, ss.str());
|
||||||
|
}
|
||||||
|
|
||||||
PrintText(x, Height() / 12, scale, ss.str());
|
void Engine::DisplaySingleOrMultiplayerMenu() {
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
auto [scaleX, scaleY] = GetScale();
|
||||||
|
float fBackPosX = 0.0f;
|
||||||
|
float fBackPosY = 0.0f;
|
||||||
|
float fBackWidth = Width();
|
||||||
|
float fBackHeight = Height();
|
||||||
|
|
||||||
|
m_textureSoloMultiMenu.Bind();
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0f, 0.0f); glVertex2f(fBackPosX, fBackPosY);
|
||||||
|
glTexCoord2f(1.0f, 0.0f); glVertex2f(fBackWidth, fBackPosY);
|
||||||
|
glTexCoord2f(1.0f, 1.0f); glVertex2f(fBackWidth, fBackHeight);
|
||||||
|
glTexCoord2f(0.0f, 1.0f); glVertex2f(fBackPosX, fBackHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
float centerX = (Width() / 2.0f);
|
||||||
|
float centerY = (Height() / 2.0f);
|
||||||
|
float titleWidth = (centerX * 1.85f) * scaleX;
|
||||||
|
float titleHeight = (centerY * 1.85f) * scaleY;
|
||||||
|
|
||||||
|
// Solo game indicator
|
||||||
|
m_textureTitle.Bind();
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0f, 0.0f); glVertex2f(centerX, centerY);
|
||||||
|
glTexCoord2f(1.0f, 0.0f); glVertex2f(titleWidth, centerY);
|
||||||
|
glTexCoord2f(1.0f, 1.0f); glVertex2f(titleWidth, titleHeight);
|
||||||
|
glTexCoord2f(0.0f, 1.0f); glVertex2f(centerX, titleHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
// Solo game indicator
|
||||||
|
float fPosX = (centerX * 1.1f) * scaleX;
|
||||||
|
float fPosXWidth = (centerX * 1.75f) * scaleX;
|
||||||
|
float soloPosY = (centerY * 0.75f) * scaleY;
|
||||||
|
float soloHeight = (centerY * 0.9f) * scaleY;
|
||||||
|
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosX, soloPosY);
|
||||||
|
glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidth, soloPosY);
|
||||||
|
glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidth, soloHeight);
|
||||||
|
glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosX, soloHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Multiplayer game indicator
|
||||||
|
float multiPosY = (centerY * 0.5f) * scaleY;
|
||||||
|
float multiHeight = (centerY * 0.65f) * scaleY;
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosX, multiPosY);
|
||||||
|
glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidth, multiPosY);
|
||||||
|
glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidth, multiHeight);
|
||||||
|
glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosX, multiHeight);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// TODO: Add SOLO / MULTIPLAYER text with font
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||||
@@ -364,7 +535,6 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
|
|
||||||
int timer = GetCountdown(elapsedTime);
|
int timer = GetCountdown(elapsedTime);
|
||||||
|
|
||||||
// Appel de la fonction pour l'affichage de notifications
|
|
||||||
if (m_keyK) {
|
if (m_keyK) {
|
||||||
SystemNotification(m_messageNotification);
|
SystemNotification(m_messageNotification);
|
||||||
m_keyK = false;
|
m_keyK = false;
|
||||||
@@ -387,7 +557,6 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
DisplayCrosshair();
|
DisplayCrosshair();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset du blend function
|
|
||||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
|
||||||
@@ -401,31 +570,36 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::PrintText(float x, float y, float scale, const std::string& t) {
|
void Engine::PrintText(float x, float y, const std::string& t, float charSizeMultiplier) {
|
||||||
|
auto [scaleX, scaleY] = GetScale();
|
||||||
|
float scale = std::min(scaleX, scaleY);
|
||||||
|
|
||||||
|
float baseCharSize = 20 + (24 - 20) * (Width() - 1600) / (1920 - 1600);
|
||||||
|
float charSize = baseCharSize * charSizeMultiplier;
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslated(x, y, 0);
|
glTranslated(x, y, 0);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < t.length(); ++i) {
|
for (unsigned int i = 0; i < t.length(); ++i) {
|
||||||
float left = (float)((t[i] - 32) % 16) / 16.f;
|
float left = (float)((t[i] - 32) % 16) / 16.f;
|
||||||
float top = (float)((t[i] - 32) / 16) / 16.f;
|
float top = (float)((t[i] - 32) / 16) / 16.f;
|
||||||
top += .5f;
|
top += 0.5f;
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
|
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
|
||||||
glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(12 * scale, 0);
|
glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(charSize * scale, 0);
|
||||||
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12 * scale, 12 * scale);
|
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(charSize * scale, charSize * scale);
|
||||||
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12 * scale);
|
glTexCoord2f(left, 1.f - top); glVertex2f(0, charSize * scale);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glTranslated(8 * scale, 0, 0);
|
glTranslated(0.5555f * charSize * scale, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Engine::GetScale() const {
|
std::pair<float, float> Engine::GetScale() const {
|
||||||
float widthRatio = Width() / BASE_WIDTH;
|
float widthRatio = static_cast<float>(Width()) / BASE_WIDTH;
|
||||||
float heightRatio = Height() / BASE_HEIGHT;
|
float heightRatio = static_cast<float>(Height()) / BASE_HEIGHT;
|
||||||
|
return { widthRatio, heightRatio };
|
||||||
return (widthRatio + heightRatio) / 2.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
||||||
@@ -437,7 +611,7 @@ int Engine::GetCountdown(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
if (m_countdown < m_time)
|
if (m_countdown < m_time)
|
||||||
Stop();
|
Stop();
|
||||||
if(!m_stopcountdown)
|
if (!m_stopcountdown)
|
||||||
m_time += elapsedTime;
|
m_time += elapsedTime;
|
||||||
return m_countdown - (int)m_time;
|
return m_countdown - (int)m_time;
|
||||||
}
|
}
|
||||||
@@ -531,14 +705,20 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_bullets[x] = nullptr;
|
m_bullets[x] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
m_wrenderer.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_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
ProcessNotificationQueue();
|
|
||||||
DrawHud(elapsedTime, bloc);
|
DrawHud(elapsedTime, bloc);
|
||||||
|
DisplayPovGun();
|
||||||
|
ProcessNotificationQueue();
|
||||||
|
|
||||||
|
/*if (m_soloMultiChoiceMade) {
|
||||||
|
DisplaySingleOrMultiplayerMenu();
|
||||||
|
}*/
|
||||||
|
|
||||||
static bool fell = false;
|
static bool fell = false;
|
||||||
if (m_player.GetPosition().y < 1.7f && !fell) {
|
if (m_player.GetPosition().y < 1.7f && !fell) {
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "renderer.h"
|
#include "worldrenderer.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float GetScale() const;
|
std::pair<float, float> GetScale() const;
|
||||||
|
|
||||||
int GetFps(float elapsedTime) const;
|
int GetFps(float elapsedTime) const;
|
||||||
int GetCountdown(float elapsedTime);
|
int GetCountdown(float elapsedTime);
|
||||||
@@ -48,11 +48,13 @@ private:
|
|||||||
void DisplayNotification(std::string message);
|
void DisplayNotification(std::string message);
|
||||||
void ProcessNotificationQueue();
|
void ProcessNotificationQueue();
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
|
void DisplayPovGun();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
void DisplayHud(int timer);
|
void DisplayHud(int timer);
|
||||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||||
|
void DisplaySingleOrMultiplayerMenu();
|
||||||
void DrawHud(float elapsedTime, BlockType bloc);
|
void DrawHud(float elapsedTime, BlockType bloc);
|
||||||
void PrintText(float x, float y, float scale, const std::string& t);
|
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||||
|
|
||||||
Connector m_conn;
|
Connector m_conn;
|
||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
@@ -60,12 +62,15 @@ private:
|
|||||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||||
|
|
||||||
World m_world = World();
|
World m_world = World();
|
||||||
Renderer m_renderer = Renderer();
|
WorldRenderer m_wrenderer = WorldRenderer();
|
||||||
|
|
||||||
Texture m_textureSkybox;
|
|
||||||
Texture m_textureFont;
|
|
||||||
Texture m_textureCrosshair;
|
Texture m_textureCrosshair;
|
||||||
|
Texture m_textureFont;
|
||||||
Texture m_textureGun;
|
Texture m_textureGun;
|
||||||
|
Texture m_texturePovGun;
|
||||||
|
Texture m_textureSkybox;
|
||||||
|
Texture m_textureSoloMultiMenu;
|
||||||
|
Texture m_textureTitle;
|
||||||
|
|
||||||
Skybox m_skybox;
|
Skybox m_skybox;
|
||||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||||
@@ -91,6 +96,7 @@ private:
|
|||||||
bool m_displayHud = true;
|
bool m_displayHud = true;
|
||||||
bool m_displayInfo = false;
|
bool m_displayInfo = false;
|
||||||
bool m_resetcountdown = false;
|
bool m_resetcountdown = false;
|
||||||
|
bool m_soloMultiChoiceMade = true;
|
||||||
bool m_stopcountdown = false;
|
bool m_stopcountdown = false;
|
||||||
|
|
||||||
bool m_keyK = false;
|
bool m_keyK = false;
|
||||||
|
BIN
SQCSim2021/media/textures/single_multi.png
Normal file
BIN
SQCSim2021/media/textures/single_multi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
BIN
SQCSim2021/media/textures/skybox2.png
Normal file
BIN
SQCSim2021/media/textures/skybox2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 MiB |
BIN
SQCSim2021/media/textures/title.png
Normal file
BIN
SQCSim2021/media/textures/title.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@@ -1,70 +0,0 @@
|
|||||||
#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(), previous() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemotePlayer::Init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemotePlayer::Feed(const netprot::Output out) {
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if (current.position != previous.position)
|
|
||||||
{
|
|
||||||
Vector3f positionDelta = current.position - previous.position;
|
|
||||||
m_position = current.position + positionDelta;
|
|
||||||
m_direction = current.direction;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(current.direction != previous.direction)
|
|
||||||
{
|
|
||||||
m_direction = current.direction;
|
|
||||||
current.direction = current.direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current.states.shooting) {
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::SHOOTING;
|
|
||||||
}
|
|
||||||
else if (current.states.jumping) {
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::JUMPING;
|
|
||||||
}
|
|
||||||
else if (current.states.dead) {
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::DEAD;
|
|
||||||
}
|
|
||||||
else if(current.states.powerup){
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::POWERUP;
|
|
||||||
}
|
|
||||||
else if (current.states.still) {
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::STILL;
|
|
||||||
}
|
|
||||||
else if (current.states.running) {
|
|
||||||
//true;
|
|
||||||
m_animstate = Anim::RUNNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
previous.direction = current.direction;
|
|
||||||
previous.position = current.position;
|
|
||||||
previous.states = current.states;
|
|
||||||
previous.id = current.id;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
#ifndef REMOTEPLAYER_H__
|
|
||||||
#define REMOTEPLAYER_H__
|
|
||||||
#include "../SQCSim-common/player.h"
|
|
||||||
#include "../SQCSim-common/netprotocol.h"
|
|
||||||
#include "define.h"
|
|
||||||
#include "textureatlas.h"
|
|
||||||
#include "shader.h"
|
|
||||||
|
|
||||||
class RemotePlayer : public Player {
|
|
||||||
public:
|
|
||||||
enum Anim { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
|
||||||
|
|
||||||
RemotePlayer();
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
void Feed(const netprot::Output out);
|
|
||||||
|
|
||||||
private:
|
|
||||||
netprot::Output current, previous;
|
|
||||||
float m_aminacc;
|
|
||||||
Anim m_animstate;
|
|
||||||
uint64_t m_team_id;
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
@@ -1,30 +0,0 @@
|
|||||||
#ifndef RENDERER_H__
|
|
||||||
#define RENDERER_H__
|
|
||||||
#include <future>
|
|
||||||
#include <thread>
|
|
||||||
#include "../SQCSim-common/world.h"
|
|
||||||
#include "../SQCSim-common/transformation.h"
|
|
||||||
#include "define.h"
|
|
||||||
#include "mesh.h"
|
|
||||||
#include "textureatlas.h"
|
|
||||||
#include "shader.h"
|
|
||||||
#include "remoteplayer.h"
|
|
||||||
|
|
||||||
class Renderer {
|
|
||||||
private:
|
|
||||||
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
|
||||||
|
|
||||||
TextureAtlas* m_playertext = nullptr;
|
|
||||||
Shader* m_playershader = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Renderer();
|
|
||||||
~Renderer();
|
|
||||||
|
|
||||||
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
|
||||||
|
|
||||||
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const;
|
|
||||||
void RenderPlayer(Player* player, Transformation tran) const;
|
|
||||||
void RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const;
|
|
||||||
};
|
|
||||||
#endif
|
|
@@ -8,30 +8,30 @@ void Skybox::Init(float size){
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
VertexBuffer::VertexData* vd = new VertexBuffer::VertexData[24];
|
VertexBuffer::VertexData* vd = new VertexBuffer::VertexData[24];
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 0.f, .5f);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 0.f, .75f);
|
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 0.f, .75f);
|
||||||
|
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 0.f, .5f);
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||||
|
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .25f, .5f);
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||||
|
vd[count++] = VertexBuffer::VertexData(-size, -size, -size, 1.f, 1.f, 1.f, .5f, .5f);
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 1.f, .5f);
|
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, 1.f, .5f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 1.f, .75f);
|
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, 1.f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .75f, .75f);
|
||||||
|
vd[count++] = VertexBuffer::VertexData(size, -size, -size, 1.f, 1.f, 1.f, .75f, .5f);
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .25f, 1.f);
|
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, .25f, 1.f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, size, size, 1.f, 1.f, 1.f, .5f, 1.f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .25f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, size, 1.f, 1.f, 1.f, .5f, .75f);
|
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .5f, .75f);
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, size, -size, 1.f, 1.f, 1.f, .25f, .75f);
|
vd[count++] = VertexBuffer::VertexData(size, size, -size, 1.f, 1.f, 1.f, .5f, 1.f);
|
||||||
|
|
||||||
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .5f, .25f);
|
vd[count++] = VertexBuffer::VertexData(-size, -size, size, 1.f, 1.f, 1.f, .5f, .25f);
|
||||||
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, .75f, .25f);
|
vd[count++] = VertexBuffer::VertexData(size, -size, size, 1.f, 1.f, 1.f, .75f, .25f);
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
#include "renderer.h"
|
#include "worldrenderer.h"
|
||||||
|
|
||||||
Renderer::Renderer() {
|
WorldRenderer::WorldRenderer() {
|
||||||
m_meshes.Reset(nullptr);
|
m_meshes.Reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer() {
|
WorldRenderer::~WorldRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
|
void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) {
|
||||||
rendercount = 0;
|
rendercount = 0;
|
||||||
Vector3f angle;
|
Vector3f angle;
|
||||||
Vector3f cursor;
|
Vector3f cursor;
|
||||||
@@ -107,7 +107,7 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
|
|||||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
int cx = player.x;
|
int cx = player.x;
|
||||||
int cy = player.z;
|
int cy = player.z;
|
||||||
static int frameUpdate = 2;
|
static int frameUpdate = 2;
|
||||||
@@ -211,9 +211,3 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const {
|
|
||||||
}
|
|
23
SQCSim2021/worldrenderer.h
Normal file
23
SQCSim2021/worldrenderer.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef WORLDRENDERER_H__
|
||||||
|
#define WORLDRENDERER_H__
|
||||||
|
#include <future>
|
||||||
|
#include <thread>
|
||||||
|
#include "../SQCSim-common/world.h"
|
||||||
|
#include "../SQCSim-common/transformation.h"
|
||||||
|
#include "define.h"
|
||||||
|
#include "mesh.h"
|
||||||
|
#include "textureatlas.h"
|
||||||
|
#include "shader.h"
|
||||||
|
|
||||||
|
class WorldRenderer {
|
||||||
|
private:
|
||||||
|
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
||||||
|
|
||||||
|
public:
|
||||||
|
WorldRenderer();
|
||||||
|
~WorldRenderer();
|
||||||
|
|
||||||
|
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas);
|
||||||
|
void UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
};
|
||||||
|
#endif
|
Reference in New Issue
Block a user