Compare commits
20 Commits
sqc_51-fin
...
sqc-14_cla
Author | SHA1 | Date | |
---|---|---|---|
|
889884490b | ||
|
bd817f9f7d | ||
|
57d60e02a7 | ||
|
ae201846b1 | ||
|
67a49a4cad | ||
|
d7e55c8446 | ||
|
183c5f186a | ||
|
54c25e6f78 | ||
|
bf164af23b | ||
|
0d948e3a28 | ||
|
b97890fff3 | ||
|
432b8545a7 | ||
|
54e2f32aba | ||
|
90fdc8ed1b | ||
|
47906776c8 | ||
|
fa9f0a3a8a | ||
|
43f3ce1428 | ||
|
bfda5e8948 | ||
|
aacb3b4ceb | ||
|
2532dfb258 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -373,3 +373,5 @@ 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,7 +33,11 @@ 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
|
||||||
|
@@ -5,9 +5,11 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
|
|||||||
m_velocity = Vector3f(0, 0, 0);
|
m_velocity = Vector3f(0, 0, 0);
|
||||||
m_airborne = true;
|
m_airborne = true;
|
||||||
m_hp = 0.75f; //TODO: Remettre <20> 1.0f
|
m_hp = 0.75f; //TODO: Remettre <20> 1.0f
|
||||||
m_username = "Zelda Bee-Bop";
|
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;
|
||||||
@@ -206,3 +208,9 @@ 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,6 +12,8 @@ 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);
|
||||||
@@ -26,12 +28,13 @@ public:
|
|||||||
float GetHP() const;
|
float GetHP() const;
|
||||||
void Teleport(int& x, int& z);
|
void Teleport(int& x, int& z);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
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;
|
||||||
@@ -40,6 +43,9 @@ private:
|
|||||||
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,13 +25,14 @@
|
|||||||
<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="worldrenderer.h" />
|
<ClInclude Include="renderer.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="audio.cpp" />
|
<ClCompile Include="audio.cpp" />
|
||||||
@@ -40,13 +41,14 @@
|
|||||||
<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="worldrenderer.cpp" />
|
<ClCompile Include="renderer.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
||||||
|
@@ -47,7 +47,10 @@
|
|||||||
<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="worldrenderer.h">
|
<ClInclude Include="renderer.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>
|
||||||
@@ -88,7 +91,10 @@
|
|||||||
<ClCompile Include="mesh.cpp">
|
<ClCompile Include="mesh.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="worldrenderer.cpp">
|
<ClCompile Include="renderer.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="remoteplayer.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -17,6 +17,8 @@ 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,8 +20,8 @@
|
|||||||
#define SRV_ADDR "127.0.0.1"
|
#define SRV_ADDR "127.0.0.1"
|
||||||
#define COUNTDOWN 300
|
#define COUNTDOWN 300
|
||||||
|
|
||||||
#define BASE_WIDTH 640
|
#define BASE_WIDTH 1920
|
||||||
#define BASE_HEIGHT 480
|
#define BASE_HEIGHT 1080
|
||||||
|
|
||||||
#define TEXTURE_PATH "./media/textures/"
|
#define TEXTURE_PATH "./media/textures/"
|
||||||
#define SHADER_PATH "./media/shaders/"
|
#define SHADER_PATH "./media/shaders/"
|
||||||
|
@@ -1,5 +1,23 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Define a structure to represent notifications
|
||||||
|
struct Notification {
|
||||||
|
std::string message;
|
||||||
|
float displayStartTime = 0.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use a queue to manage notifications
|
||||||
|
//std::queue<Notification> notificationQueue;
|
||||||
|
// Use a vector to manage notifications
|
||||||
|
std::vector<Notification> notifications;
|
||||||
|
|
||||||
Engine::Engine() {}
|
Engine::Engine() {}
|
||||||
|
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
@@ -113,6 +131,91 @@ void Engine::LoadResource() {
|
|||||||
|
|
||||||
void Engine::UnloadResource() {}
|
void Engine::UnloadResource() {}
|
||||||
|
|
||||||
|
void Engine::SystemNotification(std::string systemLog) {
|
||||||
|
std::string message = "";
|
||||||
|
|
||||||
|
message = systemLog;
|
||||||
|
|
||||||
|
DisplayNotification(message);
|
||||||
|
}
|
||||||
|
void Engine::KillNotification(Player killer, Player killed) {
|
||||||
|
std::string message = "";
|
||||||
|
|
||||||
|
message = killed.GetUsername() + " killed by -> " + killer.GetUsername();
|
||||||
|
|
||||||
|
DisplayNotification(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Engine::DisplayNotification(std::string message) {
|
||||||
|
|
||||||
|
if (message.length() > 45) {
|
||||||
|
message = message.substr(0, 45);
|
||||||
|
}
|
||||||
|
// Create a new notification and add it to the queue
|
||||||
|
Notification newNotification;
|
||||||
|
newNotification.message = message;
|
||||||
|
newNotification.displayStartTime = m_time;
|
||||||
|
|
||||||
|
notifications.push_back(newNotification);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a method to process the notification queue
|
||||||
|
void Engine::ProcessNotificationQueue() {
|
||||||
|
m_textureFont.Bind();
|
||||||
|
float scale = GetScale();
|
||||||
|
unsigned int xOffset = Width() - Width() * 0.26;
|
||||||
|
unsigned int yOffset = Height() - (Height() / 2.2);
|
||||||
|
|
||||||
|
// Iterate through the notifications and display them
|
||||||
|
for (auto it = notifications.begin(); it != notifications.end(); ) {
|
||||||
|
float timeSinceDisplay = m_time - it->displayStartTime;
|
||||||
|
|
||||||
|
// Display the notification message with vertical offset
|
||||||
|
unsigned int y = yOffset - (static_cast<unsigned int>(scale * 20) * (it - notifications.begin()));
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PrintText(xOffset, y, scale, it->message);
|
||||||
|
|
||||||
|
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();
|
||||||
|
// Check if it's time to remove the notification (display for 2 seconds)
|
||||||
|
if (timeSinceDisplay >= 4.0f) {
|
||||||
|
it = notifications.erase(it); // Remove the notification
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Engine::DisplayCrosshair() {
|
void Engine::DisplayCrosshair() {
|
||||||
m_textureCrosshair.Bind();
|
m_textureCrosshair.Bind();
|
||||||
static const int crossSize = 32;
|
static const int crossSize = 32;
|
||||||
@@ -261,6 +364,17 @@ 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) {
|
||||||
|
SystemNotification(m_messageNotification);
|
||||||
|
m_keyK = false;
|
||||||
|
}
|
||||||
|
if (m_keyL) {
|
||||||
|
|
||||||
|
KillNotification(m_player, m_player);
|
||||||
|
m_keyL = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_displayInfo) {
|
if (m_displayInfo) {
|
||||||
DisplayInfo(elapsedTime, bloc);
|
DisplayInfo(elapsedTime, bloc);
|
||||||
}
|
}
|
||||||
@@ -417,12 +531,13 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_bullets[x] = nullptr;
|
m_bullets[x] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_wrenderer.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_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&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);
|
||||||
|
|
||||||
static bool fell = false;
|
static bool fell = false;
|
||||||
@@ -474,6 +589,13 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
break;
|
break;
|
||||||
case 5: // F - Ignorer
|
case 5: // F - Ignorer
|
||||||
break;
|
break;
|
||||||
|
case 10: // K - Debugging DisplayNotification()
|
||||||
|
m_keyK = true;
|
||||||
|
m_messageNotification = "notifications systeme peuvent <20>tre affich<63>";
|
||||||
|
break;
|
||||||
|
case 11: // L - Debugging DisplayNotification()
|
||||||
|
m_keyL = true;
|
||||||
|
break;
|
||||||
case 6: // G - Ignorer
|
case 6: // G - Ignorer
|
||||||
break;
|
break;
|
||||||
case 12: // M - Ignorer
|
case 12: // M - Ignorer
|
||||||
@@ -522,6 +644,12 @@ void Engine::KeyReleaseEvent(unsigned char key) {
|
|||||||
m_displayInfo = !m_displayInfo;
|
m_displayInfo = !m_displayInfo;
|
||||||
std::cout << "DISPLAY INFO " << (m_displayInfo ? "enabled" : "disabled") << std::endl;
|
std::cout << "DISPLAY INFO " << (m_displayInfo ? "enabled" : "disabled") << std::endl;
|
||||||
break;
|
break;
|
||||||
|
case 10: // K
|
||||||
|
m_keyK = false;
|
||||||
|
break;
|
||||||
|
case 11: // L - Debugging DisplayNotification()
|
||||||
|
m_keyL = false;
|
||||||
|
break;
|
||||||
case 12: // M - Toggle music
|
case 12: // M - Toggle music
|
||||||
m_audio.ToggleMusicState();
|
m_audio.ToggleMusicState();
|
||||||
break;
|
break;
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "worldrenderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
@@ -43,6 +43,10 @@ private:
|
|||||||
|
|
||||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||||
|
|
||||||
|
void SystemNotification(std::string systemLog);
|
||||||
|
void KillNotification(Player killer, Player killed);
|
||||||
|
void DisplayNotification(std::string message);
|
||||||
|
void ProcessNotificationQueue();
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
void DisplayHud(int timer);
|
void DisplayHud(int timer);
|
||||||
@@ -56,7 +60,7 @@ private:
|
|||||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||||
|
|
||||||
World m_world = World();
|
World m_world = World();
|
||||||
WorldRenderer m_wrenderer = WorldRenderer();
|
Renderer m_renderer = Renderer();
|
||||||
|
|
||||||
Texture m_textureSkybox;
|
Texture m_textureSkybox;
|
||||||
Texture m_textureFont;
|
Texture m_textureFont;
|
||||||
@@ -70,7 +74,7 @@ private:
|
|||||||
irrklang::ISound* m_scream;
|
irrklang::ISound* m_scream;
|
||||||
|
|
||||||
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
@@ -89,6 +93,8 @@ private:
|
|||||||
bool m_resetcountdown = false;
|
bool m_resetcountdown = false;
|
||||||
bool m_stopcountdown = false;
|
bool m_stopcountdown = false;
|
||||||
|
|
||||||
|
bool m_keyK = false;
|
||||||
|
bool m_keyL = false;
|
||||||
bool m_keyW = false;
|
bool m_keyW = false;
|
||||||
bool m_keyA = false;
|
bool m_keyA = false;
|
||||||
bool m_keyS = false;
|
bool m_keyS = false;
|
||||||
@@ -99,6 +105,8 @@ private:
|
|||||||
bool m_mouseC = false;
|
bool m_mouseC = false;
|
||||||
bool m_mouseWU = false;
|
bool m_mouseWU = false;
|
||||||
bool m_mouseWD = false;
|
bool m_mouseWD = false;
|
||||||
|
|
||||||
|
std::string m_messageNotification = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_H__
|
#endif // ENGINE_H__
|
||||||
|
BIN
SQCSim2021/media/textures/Bouton/BasicPlay.png
Normal file
BIN
SQCSim2021/media/textures/Bouton/BasicPlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
BIN
SQCSim2021/media/textures/Bouton/BasicQuit.png
Normal file
BIN
SQCSim2021/media/textures/Bouton/BasicQuit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
SQCSim2021/media/textures/GUN.png
Normal file
BIN
SQCSim2021/media/textures/GUN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 267 KiB |
70
SQCSim2021/remoteplayer.cpp
Normal file
70
SQCSim2021/remoteplayer.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
25
SQCSim2021/remoteplayer.h
Normal file
25
SQCSim2021/remoteplayer.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#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,13 +1,13 @@
|
|||||||
#include "worldrenderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
WorldRenderer::WorldRenderer() {
|
Renderer::Renderer() {
|
||||||
m_meshes.Reset(nullptr);
|
m_meshes.Reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldRenderer::~WorldRenderer() {
|
Renderer::~Renderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) {
|
void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
|
||||||
rendercount = 0;
|
rendercount = 0;
|
||||||
Vector3f angle;
|
Vector3f angle;
|
||||||
Vector3f cursor;
|
Vector3f cursor;
|
||||||
@@ -107,7 +107,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
|||||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||||
};
|
};
|
||||||
|
|
||||||
void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void Renderer::UpdateMesh(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,3 +211,9 @@ void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const {
|
||||||
|
}
|
30
SQCSim2021/renderer.h
Normal file
30
SQCSim2021/renderer.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#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
|
@@ -1,23 +0,0 @@
|
|||||||
#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