booster quasi fonctionnel

affichage seulement visible a travers un autre booster.
ne se ramasse pas encore.
This commit is contained in:
Frederic Leger 2023-12-15 23:02:20 -05:00
parent 570bef266c
commit 2364fb9c1f
15 changed files with 285 additions and 192 deletions

View File

@ -131,6 +131,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="booster.h" />
<ClInclude Include="array2d.h" /> <ClInclude Include="array2d.h" />
<ClInclude Include="array3d.h" /> <ClInclude Include="array3d.h" />
<ClInclude Include="blockinfo.h" /> <ClInclude Include="blockinfo.h" />
@ -147,6 +148,7 @@
<ClInclude Include="world.h" /> <ClInclude Include="world.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="booster.cpp" />
<ClCompile Include="blockinfo.cpp" /> <ClCompile Include="blockinfo.cpp" />
<ClCompile Include="boostinfo.cpp" /> <ClCompile Include="boostinfo.cpp" />
<ClCompile Include="bullet.cpp" /> <ClCompile Include="bullet.cpp" />

View File

@ -54,6 +54,9 @@
<ClInclude Include="transformation.h"> <ClInclude Include="transformation.h">
<Filter>Fichiers d%27en-tête</Filter> <Filter>Fichiers d%27en-tête</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="booster.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="boostinfo.h"> <ClInclude Include="boostinfo.h">
<Filter>Fichiers d%27en-tête</Filter> <Filter>Fichiers d%27en-tête</Filter>
</ClInclude> </ClInclude>
@ -83,6 +86,9 @@
<ClCompile Include="transformation.cpp"> <ClCompile Include="transformation.cpp">
<Filter>Fichiers sources</Filter> <Filter>Fichiers sources</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="booster.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="boostinfo.cpp"> <ClCompile Include="boostinfo.cpp">
<Filter>Fichiers sources</Filter> <Filter>Fichiers sources</Filter>
</ClCompile> </ClCompile>

38
SQCSim-common/booster.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "booster.h"
Booster::Booster()
{
}
Booster::Booster(Vector3f tpos, BOOST_TYPE ttype)
{
pos = tpos;
type = ttype;
available = true;
}
Booster::~Booster()
{
}
Vector3f Booster::GetPosition()
{
return pos;
}
BOOST_TYPE Booster::GetType()
{
return type;
}
bool Booster::GetAvailability()
{
return available;
}
void Booster::SetAvailability(bool value)
{
available = value;
}

View File

@ -1,18 +1,13 @@
#ifndef BOOSTER_H__ #ifndef BOOSTER_H__
#define BOOSTER_H__ #define BOOSTER_H__
#include "define.h" #include "define.h"
#include "textureatlas.h" #include "vector3.h"
#include "shader.h"
#include "../SQCSim-common/vector3.h"
#include "../SQCSim-common/transformation.h"
#include "../SQCSim-common/player.h"
class Booster { class Booster {
public: public:
Booster();
Booster(Vector3f tpos, BOOST_TYPE ttype); Booster(Vector3f tpos, BOOST_TYPE ttype);
~Booster(); ~Booster();
void RenderBillboard(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player);
Vector3f GetPosition(); Vector3f GetPosition();
BOOST_TYPE GetType(); BOOST_TYPE GetType();
bool GetAvailability(); bool GetAvailability();

View File

@ -31,7 +31,7 @@
#define TEXTURE_SIZE 512 #define TEXTURE_SIZE 512
#define MAX_BULLETS 512 #define MAX_BULLETS 512
#define NB_BOOST 1 #define NB_BOOST 2
#define TIME_SPEED_BOOST 10 //secondes #define TIME_SPEED_BOOST 10 //secondes
#define TIME_DAMAGE_BOOST 10 //secondes #define TIME_DAMAGE_BOOST 10 //secondes
#define TIME_INVINCIBLE_BOOST 4 //secondes #define TIME_INVINCIBLE_BOOST 4 //secondes

View File

@ -216,7 +216,8 @@ void Player::TakeBooster(Booster booster_table[])
{ {
for (int i = 0; i < sizeof(booster_table); i++) for (int i = 0; i < sizeof(booster_table); i++)
{ {
if (abs((m_position.x + m_position.y + m_position.z) - (booster_table[i].GetPosition().x + booster_table[i].GetPosition().y + booster_table[i].GetPosition().z)) <= 0.5f && booster_table[i].GetAvailability() == true) Vector3f pos = booster_table[i].GetPosition();
if (abs((m_position.x + m_position.y + m_position.z) - (pos.x + pos.y +pos.z)) <= 0.5f && booster_table[i].GetAvailability() == true)
{ {
GetBooster(booster_table[i].GetType()); GetBooster(booster_table[i].GetType());
booster_table[i].SetAvailability(false); booster_table[i].SetAvailability(false);

View File

@ -4,7 +4,7 @@
#include <cmath> #include <cmath>
#include "transformation.h" #include "transformation.h"
#include "vector3.h" #include "vector3.h"
#include "../SQCSim2021/booster.h" #include "booster.h"
#include "define.h" #include "define.h"

View File

@ -20,7 +20,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="audio.h" /> <ClInclude Include="audio.h" />
<ClInclude Include="booster.h" />
<ClInclude Include="connector.h" /> <ClInclude Include="connector.h" />
<ClInclude Include="define.h" /> <ClInclude Include="define.h" />
<ClInclude Include="engine.h" /> <ClInclude Include="engine.h" />
@ -38,7 +37,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="audio.cpp" /> <ClCompile Include="audio.cpp" />
<ClCompile Include="booster.cpp" />
<ClCompile Include="connector.cpp" /> <ClCompile Include="connector.cpp" />
<ClCompile Include="engine.cpp" /> <ClCompile Include="engine.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />

View File

@ -53,9 +53,6 @@
<ClInclude Include="remoteplayer.h"> <ClInclude Include="remoteplayer.h">
<Filter>Fichiers d%27en-tête</Filter> <Filter>Fichiers d%27en-tête</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="booster.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="settings.h"> <ClInclude Include="settings.h">
<Filter>Fichiers d%27en-tête</Filter> <Filter>Fichiers d%27en-tête</Filter>
</ClInclude> </ClInclude>
@ -103,9 +100,6 @@
<ClCompile Include="remoteplayer.cpp"> <ClCompile Include="remoteplayer.cpp">
<Filter>Fichiers sources</Filter> <Filter>Fichiers sources</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="booster.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="settings.cpp"> <ClCompile Include="settings.cpp">
<Filter>Fichiers sources</Filter> <Filter>Fichiers sources</Filter>
</ClCompile> </ClCompile>

View File

@ -1,81 +0,0 @@
#include "booster.h"
Booster::Booster(Vector3f tpos, BOOST_TYPE ttype)
{
pos = tpos;
type = ttype;
}
Booster::~Booster()
{
}
Vector3f Booster::GetPosition()
{
return pos;
}
BOOST_TYPE Booster::GetType()
{
return type;
}
bool Booster::GetAvailability()
{
return available;
}
void Booster::SetAvailability(bool value)
{
available = value;
}
void Booster::RenderBillboard(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player)
{
float width = 1.0f;
float height = 1.7f;
Matrix4 mat4 = tran.GetMatrix();
Vector3f DiffCam = GetPosition() - player.GetPosition();
Vector3f UpCam = Vector3f(mat4.Get12(), mat4.Get22(), mat4.Get32());
Vector3f CrossA = DiffCam.Cross(UpCam);
Vector3f CrossB = DiffCam.Cross(CrossA);
CrossA.Normalize();
CrossB.Normalize();
Vector3f playerPosition = GetPosition() + Vector3f(0.f, 0.f, 0.f);
Vector3f v1 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v2 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
Vector3f v3 = (playerPosition + CrossA * 0.5 * width - CrossB * 0.5 * height);
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
float u, v, w, h;
shader.Use();
textureAtlas.Bind();
textureAtlas.TextureIndexToCoord(0, u, v, w, h);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);
glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z);
glTexCoord2f(u + w, v + h); glVertex3f(v3.x, v3.y, v3.z);
glTexCoord2f(u, v + h); glVertex3f(v4.x, v4.y, v4.z);
glEnd();
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendEquation(GL_FUNC_SUBTRACT);
glDisable(GL_BLEND);
shader.Disable();
}

View File

@ -3,13 +3,13 @@
//#define SFML_STATIC true //#define SFML_STATIC true
#include "../SQCSim-common/define.h"
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <iomanip> #include <iomanip>
#include <GL/glew.h> #include <GL/glew.h>
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include "../SQCSim-common/define.h"
#ifdef _WIN32 #ifdef _WIN32
#include <gl/GL.h> #include <gl/GL.h>

View File

@ -78,7 +78,6 @@ void Engine::LoadResource() {
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl; std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
abort(); abort();
} }
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true); LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
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);
@ -124,15 +123,15 @@ void Engine::LoadResource() {
LoadTexture(m_textureMenuQuit, TEXTURE_PATH "menus/buttons/main/mainQuit.png", false); LoadTexture(m_textureMenuQuit, TEXTURE_PATH "menus/buttons/main/mainQuit.png", false);
LoadTexture(m_textureMenuSingle, TEXTURE_PATH "menus/buttons/main/mainSingle.png", false); LoadTexture(m_textureMenuSingle, TEXTURE_PATH "menus/buttons/main/mainSingle.png", false);
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); //0
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); //1
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); //2
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); //3
TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.png"); TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.png"); //4
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png"); TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png"); //5
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png"); TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png"); //6
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png"); TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png"); //7
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png"); TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png"); //8
//AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM //AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM
@ -1326,6 +1325,8 @@ void Engine::Render(float elapsedTime) {
static float pollTime = 0; static float pollTime = 0;
static float bulletTime = 0; static float bulletTime = 0;
static BlockType bloc = 1; static BlockType bloc = 1;
booster_table[0] = Booster({ 215, 15, 195 }, BTYPE_SPEED);
booster_table[1] = Booster({ 213, 15, 195 }, BTYPE_HEAL);
if (elapsedTime > 0.1f) return; if (elapsedTime > 0.1f) return;
@ -1424,17 +1425,14 @@ void Engine::Render(float elapsedTime) {
} }
} }
} }
gameTime += elapsedTime * 10;
Vector3f dance = Vector3f(sin(gameTime), 0, cos(-gameTime));
dance.Normalize();
booster_table[0] = Booster({ 195, 16, 195 }, BTYPE_SPEED);
m_remotePlayer.ApplyPhysics(dance, &m_world, elapsedTime, booster_table);
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);
m_remotePlayer.Render(m_animeAtlas, m_shader01, all, elapsedTime); glDisable(GL_CULL_FACE);
booster_table[0].RenderBillboard(m_textureAtlas, m_shader01, all, m_player); for (Booster booster : booster_table) {
glClear(GL_STENCIL_BUFFER_BIT);
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
}
glEnable(GL_CULL_FACE);
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas); if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);

View File

@ -5,6 +5,7 @@
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
#include <unordered_map> #include <unordered_map>
#include <set>
#include "../SQCSim-common/array2d.h" #include "../SQCSim-common/array2d.h"
#include "../SQCSim-common/blockinfo.h" #include "../SQCSim-common/blockinfo.h"
#include "../SQCSim-common/boostinfo.h" #include "../SQCSim-common/boostinfo.h"
@ -13,6 +14,7 @@
#include "../SQCSim-common/world.h" #include "../SQCSim-common/world.h"
#include "../SQCSim-common/transformation.h" #include "../SQCSim-common/transformation.h"
#include "../SQCSim-common/player.h" #include "../SQCSim-common/player.h"
#include "../SQCSim-common/booster.h"
#include "define.h" #include "define.h"
#include "openglcontext.h" #include "openglcontext.h"
#include "texture.h" #include "texture.h"
@ -23,16 +25,15 @@
#include "connector.h" #include "connector.h"
#include "renderer.h" #include "renderer.h"
#include "remoteplayer.h" #include "remoteplayer.h"
#include "booster.h" #include "settings.h"
class Engine : public OpenglContext { class Engine : public OpenglContext {
public: public:
Engine(); Engine();
virtual ~Engine(); virtual ~Engine();
virtual void DrawMenu();
virtual void DrawPause();
virtual void DrawSplachScreen();
virtual void Init(); virtual void Init();
virtual void DeInit(); virtual void DeInit();
virtual void LoadResource(); virtual void LoadResource();
@ -41,96 +42,159 @@ public:
virtual void KeyPressEvent(unsigned char key); virtual void KeyPressEvent(unsigned char key);
virtual void KeyReleaseEvent(unsigned char key); virtual void KeyReleaseEvent(unsigned char key);
virtual void MouseMoveEvent(int x, int y); virtual void MouseMoveEvent(int x, int y);
virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y); virtual void MousePressEvent(const MOUSE_BUTTON& button, int x, int y);
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y); virtual void MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y);
private: private:
int GetFps(float elapsedTime) const; int GetFps(float elapsedTime) const;
int GetCountdown(float elapsedTime); int GetCountdown(float elapsedTime);
int GetOptionsChoice();
bool StartMultiplayerGame();
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 ChangeResolution(Resolution resolution);
void InstantDamage(); void InstantDamage();
void SystemNotification(std::string systemLog); void SystemNotification(std::string systemLog);
void KillNotification(Player killer, Player killed); void KillNotification(Player killer, Player killed);
void DisplayNotification(std::string message); void DisplayNotification(std::string message);
void ProcessNotificationQueue();
void DisplayCrosshair(); void DisplayCrosshair();
void DisplayPovGun(); void DisplayPovGun();
void DisplayCurrentItem(); void DisplayCurrentItem();
void DisplayHud(int timer); void DisplayHud(int timer);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySingleOrMultiplayerMenu();
void DrawHud(float elapsedTime, BlockType bloc); void DrawHud(float elapsedTime, BlockType bloc);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySplashScreen();
void DisplayMainMenu();
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
void DrawMainMenuButtons(float centerX, float centerY);
void DrawSingleMultiButtons(float centerX, float centerY);
void DisplayLobbyMenu(float elapsedTime);
void SetPlayerUsername(float elapsedTime);
void SetServerAddress(float elapsedTime);
void DisplayPauseMenu(float elapsedTime);
void DisplayOptionsMenu();
void DisplayAudioMenu(float centerX, float centerY);
void DisplayGraphicsMenu(float centerX, float centerY);
void DisplayGameplayMenu(float centerX, float centerY);
void DrawSliderBackground(float centerX, float centerY, float minVal, float maxVal, float bottomSideValue, float topSideValue);
void DisplayBarPercentValue(float centerX, float centerY, float posX, float posY, float minVal, float maxVal, float value);
void DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue);
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f); void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
void ProcessNotificationQueue();
char SimulateKeyboard(unsigned char key);
void HandlePlayerInput(float elapsedTime);
Audio m_audio = Audio(AUDIO_PATH "music01.wav", AUDIO_PATH "menumusic01.wav");
irrklang::ISound* m_powpow, * m_scream;
irrklang::ISound* m_whoosh[MAX_BULLETS];
Bullet* m_bullets[MAX_BULLETS];
//Menu
Vector3f m_otherplayerpos = Vector3f(999, 999, 999);
Connector m_conn; World m_world = World();
Shader m_shader01; Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Renderer m_renderer = Renderer();
Booster booster_table[NB_BOOST];
BlockInfo* m_blockinfo[BTYPE_LAST]; BlockInfo* m_blockinfo[BTYPE_LAST];
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST]; BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
GameState m_gamestate = GameState::SPLASH;
Shader m_shader01;
Skybox m_skybox;
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST); TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST); TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
World m_world = World(); TextureAtlas::TextureIndex texBoostHeal;
Renderer m_renderer = Renderer();
Booster* booster_table;
Texture m_textureCrosshair; Texture m_textureCrosshair;
Texture m_textureFont; Texture m_textureFont;
Texture m_textureGun; Texture m_textureGun;
Texture m_texturePovGun; Texture m_texturePovGun;
Texture m_textureSkybox; Texture m_textureSkybox;
Texture m_textureSoloMultiMenu;
Texture m_textureSoloText;
Texture m_textureMultiText;
Texture m_textureTitle;
TextureAtlas::TextureIndex texBoostHeal; Texture m_textureLobbyMenu;
Texture m_textureMainMenu;
Texture m_textureOptionsMenu;
Texture m_texturePauseMenu;
Texture m_textureSplashScreen;
Skybox m_skybox; Texture m_textureHd;
Audio m_audio = Audio(AUDIO_PATH "start.wav"); Texture m_textureFhd;
Texture m_textureQhd;
Texture m_textureUhd;
irrklang::ISound* m_powpow, Texture m_textureLobbyServer;
* m_scream; Texture m_textureLobbyIdentify;
irrklang::ISound *m_whoosh[MAX_BULLETS]; Texture m_textureCheck;
Texture m_textureChecked;
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); Texture m_texturePauseResume;
Texture m_texturePauseMainMenu;
Bullet* m_bullets[MAX_BULLETS];
std::unordered_map<uint64_t, Player*> m_players; Texture m_textureOptAudio;
netprot::Buffer m_buf, m_bufout; Texture m_textureOptBack;
std::chrono::high_resolution_clock::time_point m_startTime; Texture m_textureOptGameplay;
Texture m_textureOptGraphics;
Texture m_textureOptMain;
Texture m_textureOptMusic;
Texture m_textureOptOptions;
Texture m_textureOptResolution;
Texture m_textureOptSensitivity;
Texture m_textureOptSfx;
//Menu Texture m_textureMenuBack;
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE }; Texture m_textureMenuMulti;
GameState m_gamestate = GameState::MAIN_MENU; Texture m_textureMenuOptions;
Texture MenuTitleTexture; Texture m_textureMenuPlay;
Texture MenuBGTexture; Texture m_textureMenuQuit;
Texture MenuStartTexture; Texture m_textureMenuSingle;
Texture MenuQuitTexture; Texture m_textureMenuTitle;
Texture MenuOptionsTexture;
Texture PauseBGTexture;
Texture SplachScreenTexture;
Settings m_options = Settings(m_audio);
Resolution m_resolution = HD;
float m_splashTime = 2.0f;
float m_scale; float m_scale;
float m_time = 0; float m_time = 0;
float m_time_SplashScreen = 0;
float m_titleX = 0; float m_titleX = 0;
float m_titleY = 0; float m_titleY = 0;
float m_Width = 0;
float m_Height = 0;
int m_renderCount = 0; int m_renderCount = 0;
int m_countdown = COUNTDOWN; int m_countdown = COUNTDOWN;
int m_nbReductionChunk = 4; int m_nbReductionChunk = 4;
int m_timerReductionChunk = 30; int m_timerReductionChunk = 30;
float m_mainvolume;
float m_musicvolume;
float m_sfxvolume;
float m_sensitivity;
int m_selectedOption = 0;
bool m_selectedOptAudioMainBar = false;
bool m_selectedOptAudioMusicBar = false;
bool m_selectedOptAudioSfxBar = false;
bool m_selectedGameplaySensitivityBar = false;
bool m_damage = false; bool m_damage = false;
bool m_wireframe = false; bool m_wireframe = false;
@ -143,7 +207,26 @@ private:
bool m_resetcountdown = false; bool m_resetcountdown = false;
bool m_soloMultiChoiceMade = false; bool m_soloMultiChoiceMade = false;
bool m_stopcountdown = false; bool m_stopcountdown = false;
bool m_selectedPlayOptions = false;
bool m_selectedOptions = false;
bool m_selectedQuit = false;
std::string m_currentInputString;
std::string m_username;
std::string m_serverAddr;
char m_inputChar = 0;
bool m_invalidChar = false;
bool m_charChanged = false;
bool m_settingUsername = false;
bool m_settingServer = false;
bool m_selectedSinglePlayer = false;
bool m_selectedMultiPlayer = false;
bool m_singleReady = false;
bool m_multiReady = false;
bool m_key1 = false; bool m_key1 = false;
bool m_key2 = false; bool m_key2 = false;
@ -153,20 +236,31 @@ private:
bool m_keyA = false; bool m_keyA = false;
bool m_keyS = false; bool m_keyS = false;
bool m_keyD = false; bool m_keyD = false;
bool m_keyEnter = false;
bool m_keySpace = false; bool m_keySpace = false;
bool m_keyShift = false;
bool m_keyBackspace = false;
bool m_mouseL = false; bool m_mouseL = false;
bool m_mouseR = false; bool m_mouseR = false;
bool m_mouseC = false; bool m_mouseC = false;
bool m_mouseWU = false; bool m_mouseWU = false;
bool m_mouseWD = false; bool m_mouseWD = false;
//Pour trouver ou est la souris
float m_mousemx = 0; float m_mousemx = 0;
float m_mousemy = 0; float m_mousemy = 0;
bool m_networkgame = false; bool m_networkgame = false;
netprot::PlayerInfo m_pinfo;
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f)); Connector m_conn;
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
std::chrono::high_resolution_clock::time_point m_startTime;
std::unordered_map<uint64_t, Player*> m_players;
netprot::Buffer m_buf, m_bufout;
netprot::ChunkMod* m_chunkmod = nullptr;
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
std::string m_messageNotification = ""; std::string m_messageNotification = "";
}; };
#endif // ENGINE_H__ #endif // ENGINE_H__

View File

@ -120,7 +120,7 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
unsigned int sx, sy, cx, cy; unsigned int sx, sy, cx, cy;
origin->GetScope(sx,sy); origin->GetScope(sx, sy);
for (int index = 0; index < rendercount; ++index) { for (int index = 0; index < rendercount; ++index) {
int chx = (renderManifest[index].x - sx) * CHUNK_SIZE_X, chy = (renderManifest[index].z - sy) * CHUNK_SIZE_Z; int chx = (renderManifest[index].x - sx) * CHUNK_SIZE_X, chy = (renderManifest[index].z - sy) * CHUNK_SIZE_Z;
@ -129,9 +129,9 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
glLoadMatrixf(world.GetMatrix().GetInternalValues()); glLoadMatrixf(world.GetMatrix().GetInternalValues());
float blcolor = renderManifest[index].y / (VIEW_DISTANCE / 50.f); float blcolor = renderManifest[index].y / (VIEW_DISTANCE / 50.f);
glBlendColor(blcolor, blcolor, blcolor, 1.f); glBlendColor(blcolor, blcolor, blcolor, 1.f);
origin->ChunkAt(chx, 1, chy)->GetPosition(cx,cy); origin->ChunkAt(chx, 1, chy)->GetPosition(cx, cy);
if (m_meshes.Get(cx - sx, cy - sy)) if (m_meshes.Get(cx - sx, cy - sy))
m_meshes.Get(cx - sx, cy -sy)->Render(); m_meshes.Get(cx - sx, cy - sy)->Render();
world.ApplyTranslation(-chx, 0, -chy); world.ApplyTranslation(-chx, 0, -chy);
} }
shader.Disable(); shader.Disable();
@ -147,7 +147,7 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
int threads = 0; int threads = 0;
std::future<Mesh*> updateThList[THREADS_UPDATE_CHUNKS]; std::future<Mesh*> updateThList[THREADS_UPDATE_CHUNKS];
unsigned int mx = 0 , my = 0, sx, sy; unsigned int mx = 0, my = 0, sx, sy;
origin->GetScope(sx, sy); origin->GetScope(sx, sy);
@ -244,27 +244,75 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
} }
} }
void Renderer::RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran) void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster)
{ {
//float x = pos.x; if (booster.GetAvailability() == true)
//float y = pos.y; {
//float z = pos.z; float width = 1.f;
//float width = 1.0f; float height = 1.f;
//float height = 1.0f;
//float u, v, w, h; Vector3f DiffCam = booster.GetPosition() - player.GetPosition();
//shader.Use(); Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
//textureAtlas.Bind();
//textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
//glLoadMatrixf(tran.GetMatrix().GetInternalValues()); Vector3f CrossA = DiffCam.Cross(UpCam);
//glBegin(GL_QUADS); Vector3f CrossB = DiffCam.Cross(CrossA);
//glTexCoord2f(u, v); glVertex3f(x - width / 2., y - height, z); //glVertex3f(v4.x, v4.y, v4.z);//glVertex3f(0, 50, 0);
//glTexCoord2f(u + w, v); glVertex3f(x + width / 2., y - height, z); //glVertex3f(v3.x, v3.y, v3.z); //glVertex3f(50,50, 0); CrossA.Normalize();
//glTexCoord2f(u + w, v + h); glVertex3f(x + width / 2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0); CrossB.Normalize();
//glTexCoord2f(u, v + h); glVertex3f(x - width / 2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
//glEnd(); Vector3f playerPosition = booster.GetPosition() + Vector3f(0.f, -.75f, 0.f);
//shader.Disable();
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);
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
int index;
BOOST_TYPE type = booster.GetType();
switch (type)
{
case BTYPE_HEAL:
index = 5;
break;
case BTYPE_DAMAGE:
index = 6;
break;
case BTYPE_SPEED:
index = 7;
break;
case BTYPE_INVINCIBLE:
index = 8;
break;
default:
index = 1;
break;
}
float u, v, w, h;
shader.Use();
textureAtlas.Bind();
textureAtlas.TextureIndexToCoord(index, u, v, w, h);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);
glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z);
glTexCoord2f(u + w, v + h); glVertex3f(v3.x, v3.y, v3.z);
glTexCoord2f(u, v + h); glVertex3f(v4.x, v4.y, v4.z);
glEnd();
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendEquation(GL_FUNC_SUBTRACT);
glDisable(GL_BLEND);
shader.Disable();
}
} }

View File

@ -29,7 +29,7 @@ public:
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]); void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
void RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran); void RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster);
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation world, Shader& shader, TextureAtlas& atlas) const; 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(Player* player, Transformation tran) const;