Merge branch 'MenusMenusMenus' into SQC-15_paquets

This commit is contained in:
MarcEricMartel 2023-12-04 13:13:54 -05:00 committed by GitHub
commit 78b3ed85cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 1203 additions and 645 deletions

View File

@ -9,6 +9,10 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
//if (input.fail()) {
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(seed);
m_blocks.Reset(BTYPE_AIR);
int ratio = 0;
ratio = x * y % 7;
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
@ -47,8 +51,8 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
}
}
int rnd = rand() % 15;
if (rnd == 4)
//int rnd = rand() % 15;
if (ratio == 1)
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
for (int iy = 0; iy < 14; ++iy) {
@ -57,16 +61,16 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
Structure(ix, iy, iz, 2);
}
}
if (rnd == 3)
if (ratio == 3)
for (int ix = 0; ix < CHUNK_SIZE_Z; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_X; ++iz) {
for (int iy = 0; iy < 14; ++iy) {
if (iz == 4)
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
Structure(ix, iy, iz, 2);
Structure(ix, iy, iz, 1);
}
}
if (rnd == 6)
if (ratio == 5)
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
for (int iy = 0; iy < 14; ++iy) {

View File

@ -52,6 +52,7 @@ typedef uint64_t Timestamp;
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
#pragma comment(lib,"ws2_32.lib")
#include <ws2tcpip.h>
#include <Windows.h>
#include <cstdio>

View File

@ -27,6 +27,7 @@
<ClInclude Include="mesh.h" />
<ClInclude Include="openglcontext.h" />
<ClInclude Include="remoteplayer.h" />
<ClInclude Include="settings.h" />
<ClInclude Include="shader.h" />
<ClInclude Include="skybox.h" />
<ClInclude Include="texture.h" />
@ -44,6 +45,7 @@
<ClCompile Include="mesh.cpp" />
<ClCompile Include="openglcontext.cpp" />
<ClCompile Include="remoteplayer.cpp" />
<ClCompile Include="settings.cpp" />
<ClCompile Include="shader.cpp" />
<ClCompile Include="skybox.cpp" />
<ClCompile Include="texture.cpp" />

View File

@ -56,6 +56,9 @@
<ClInclude Include="booster.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="settings.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="engine.cpp">
@ -103,5 +106,8 @@
<ClCompile Include="booster.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="settings.cpp">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -48,3 +48,7 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
float Audio::GetMusicVolume() const {
return m_music->getVolume();
}

View File

@ -33,6 +33,8 @@ public:
void ToggleMusicState();
void PauseEngine();
float GetMusicVolume() const;
};
#endif // AUDIO_H__

View File

@ -43,7 +43,22 @@
#define SHADER_PATH "./media/shaders/"
#define AUDIO_PATH "./media/audio/"
#define CHUNK_PATH "./media/chunks/"
#define MENU_ITEM_PATH "./media/menu_items/"
#define BOOSTER_TEXTURE_PATH "./media/textures/Booster/"
enum GameState {
MAIN_MENU,
SPLASH,
OPTIONS,
QUIT,
PLAY,
PAUSE
};
enum Resolution {
HD = 0, // 1280x720 (High Definition)
FHD, // 1920x1080 (Full HD)
QHD, // 2560x1440 (Quad HD)
UHD // 3840x2160 (Ultra HD)
};
#endif // DEFINE_H__

File diff suppressed because it is too large Load Diff

View File

@ -24,15 +24,12 @@
#include "renderer.h"
#include "remoteplayer.h"
#include "booster.h"
#include "settings.h"
class Engine : public OpenglContext {
public:
Engine();
virtual ~Engine();
virtual void DrawMenu();
virtual void DrawOption();
virtual void DrawSplachScreen();
virtual void Init();
virtual void DeInit();
virtual void LoadResource();
@ -47,98 +44,137 @@ public:
private:
int GetFps(float elapsedTime) const;
int GetCountdown(float elapsedTime);
int GetOptionsChoice();
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
void InstantDamage();
void SystemNotification(std::string systemLog);
void KillNotification(Player killer, Player killed);
void DisplayNotification(std::string message);
void ProcessNotificationQueue();
void DisplayCrosshair();
void DisplayPovGun();
void DisplayCurrentItem();
void DisplayHud(int timer);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySingleOrMultiplayerMenu();
void DrawHud(float elapsedTime, BlockType bloc);
void DisplayInfo(float elapsedTime, BlockType bloc);
void DisplaySplashScreen();
void DisplayPauseMenu();
void DisplayMainMenu();
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
void DrawMainMenuButtons(float centerX, float centerY);
void DrawSingleMultiButtons(float centerX, float centerY);
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 ProcessNotificationQueue();
Audio m_audio = Audio(AUDIO_PATH "start.wav");
irrklang::ISound* m_powpow, * m_scream;
irrklang::ISound* m_whoosh[MAX_BULLETS];
Bullet* m_bullets[MAX_BULLETS];
//Menu
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI };
Vector3f m_otherplayerpos = Vector3f(999, 999, 999);
Connector m_conn;
Shader m_shader01;
World m_world = World();
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Renderer m_renderer = Renderer();
Booster m_booster = Booster();
BlockInfo* m_blockinfo[BTYPE_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_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
World m_world = World();
Renderer m_renderer = Renderer();
Booster m_booster = Booster();
TextureAtlas::TextureIndex texBoostHeal;
Texture m_textureCrosshair;
Texture m_textureFont;
Texture m_textureGun;
Texture m_texturePovGun;
Texture m_textureSkybox;
Texture m_textureSoloMultiMenu;
Texture m_textureSoloText;
Texture m_textureMultiText;
Texture m_textureTitle;
TextureAtlas::TextureIndex texBoostHeal;
Texture m_textureMainMenu;
Texture m_textureOptionsMenu;
Texture m_texturePauseMenu;
Texture m_textureSplashScreen;
Skybox m_skybox;
Audio m_audio = Audio(AUDIO_PATH "start.wav");
Texture m_textureHd;
Texture m_textureFhd;
Texture m_textureQhd;
Texture m_textureUhd;
Texture m_textureCheck;
Texture m_textureChecked;
irrklang::ISound* m_powpow,
* m_scream;
irrklang::ISound *m_whoosh[MAX_BULLETS];
Texture m_textureOptAudio;
Texture m_textureOptBack;
Texture m_textureOptGameplay;
Texture m_textureOptGraphics;
Texture m_textureOptMain;
Texture m_textureOptMusic;
Texture m_textureOptOptions;
Texture m_textureOptResolution;
Texture m_textureOptSensitivity;
Texture m_textureOptSfx;
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Texture m_textureMenuBack;
Texture m_textureMenuMulti;
Texture m_textureMenuOptions;
Texture m_textureMenuPlay;
Texture m_textureMenuQuit;
Texture m_textureMenuSingle;
Texture m_textureMenuTitle;
Bullet* m_bullets[MAX_BULLETS];
std::vector<netprot::ChunkMod*> m_chunkmod_manifest;
Settings m_options = Settings(m_audio);
std::unordered_map<uint64_t, Player*> m_players;
netprot::Buffer m_buf, m_bufout;
std::chrono::high_resolution_clock::time_point m_startTime;
netprot::ChunkMod* m_chunkmod = nullptr;
//Menu
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI };
GameState m_gamestate = GameState::PLAY;
Texture MenuTitleTexture;
Texture MenuBGTexture;
Texture MenuBGOptionTexture;
Texture MenuStartTexture;
Texture MenuQuitTexture;
Texture MenuOptionsTexture;
Texture PauseBGTexture;
Texture SplachScreenTexture;
Texture MusicTexture; //TODO
Texture OnOffBtnTexture;//TODO
Texture BackBtnTexture;//TODO
Vector3f m_otherplayerpos = Vector3f(999, 999, 999);
Resolution m_resolution = HD;
float m_splashTime = 2.0f;
float m_scale;
float m_time = 0;
float m_time_SplashScreen = 0;
float m_titleX = 0;
float m_titleY = 0;
float m_Width = 0;
float m_Height = 0;
int m_renderCount = 0;
int m_countdown = COUNTDOWN;
int m_nbReductionChunk = 4;
int m_timerReductionChunk = 30;
float m_volPrincipal = 0.0f;
float m_volMusique = 0.0f;
float m_volEffets = 0.0f;
float m_volSensible = 0.0f;
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_wireframe = false;
@ -152,9 +188,12 @@ private:
bool m_soloMultiChoiceMade = false;
bool m_stopcountdown = false;
bool m_selectedPlayOptions = false;
bool m_selectedOptions = false;
bool m_selectedQuit = false;
bool m_key1 = false;
bool m_key2 = false;
bool m_keyK = false;
bool m_keyL = false;
bool m_keyW = false;
@ -162,16 +201,24 @@ private:
bool m_keyS = false;
bool m_keyD = false;
bool m_keySpace = false;
bool m_mouseL = false;
bool m_mouseR = false;
bool m_mouseC = false;
bool m_mouseWU = false;
bool m_mouseWD = false;
//Pour trouver ou est la souris
float m_mousemx = 0;
float m_mousemy = 0;
bool m_networkgame = false;
Connector m_conn;
std::vector<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;
netprot::PlayerInfo m_pinfo;
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 MiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 KiB

View File

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

146
SQCSim2021/settings.cpp Normal file
View File

@ -0,0 +1,146 @@
#include "settings.h"
Settings::Settings(Audio& audio)
: m_audio(audio),
m_mainVolume(0.5f),
m_musicVolume(0.5f),
m_sfxVolume(0.5f),
m_resolution(FHD),
m_fullscreen(false),
m_brightness(0.5f),
m_contrast(0.5f),
m_mouseSensitivity(0.5f) {
ApplyResolution(m_resolution);
}
void Settings::SaveFile(const std::string& filename) {
std::ofstream file(filename);
if (!file.is_open()) {
std::cerr << "Failed to open file for saving parameters" << std::endl;
return;
}
file << m_mainVolume << '\n';
file << m_musicVolume << '\n';
file << m_sfxVolume << '\n';
file << static_cast<int>(m_resolution) << '\n';
file << m_fullscreen << '\n';
file << m_brightness << '\n';
file << m_contrast << '\n';
file << m_mouseSensitivity << '\n';
file.close();
}
void Settings::LoadFile(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
std::cerr << "Failed to open file for loading parameters" << std::endl;
return;
}
file >> m_mainVolume;
file >> m_musicVolume;
file >> m_sfxVolume;
int resolutionValue;
file >> resolutionValue;
m_resolution = static_cast<Resolution>(resolutionValue);
file >> m_fullscreen;
file >> m_brightness;
file >> m_contrast;
file >> m_mouseSensitivity;
file.close();
}
float Settings::GetMainVolume() const {
return m_mainVolume;
}
void Settings::SetMainVolume(float volume) {
m_mainVolume = volume;
}
void Settings::GetMusicVolume() {
m_musicVolume = m_audio.GetMusicVolume();
}
void Settings::SetMusicVolume(float volume) {
m_musicVolume = volume;
}
float Settings::GetSfxVolume() const {
return m_sfxVolume;
}
void Settings::SetSfxVolume(float volume) {
m_sfxVolume = volume;
}
float Settings::GetBrightness() const {
return m_brightness;
}
void Settings::SetBrightness(float brightness) {
m_brightness = brightness;
}
float Settings::GetContrast() const {
return m_contrast;
}
void Settings::SetContrast(float contrast) {
m_contrast = contrast;
}
bool Settings::GetFullscreen() const {
return m_fullscreen;
}
void Settings::SetFullscreen(bool fullscreen) {
m_fullscreen = fullscreen;
}
const Resolution& Settings::GetResolution() const {
return m_resolution;
}
void Settings::SetResolution(const Resolution& resolution) {
m_resolution = resolution;
}
float Settings::GetMouseSensitivity() const {
return m_mouseSensitivity;
}
void Settings::SetMouseSensitivity(float sensitivity) {
m_mouseSensitivity = sensitivity;
}
void Settings::ApplyResolution(Resolution resolution) {
switch (resolution) {
case HD:
m_rezWidth = 1280;
m_rezHeight = 720;
break;
case FHD:
m_rezWidth = 1920;
m_rezHeight = 1080;
break;
case QHD:
m_rezWidth = 2560;
m_rezHeight = 1440;
break;
case UHD:
m_rezWidth = 3840;
m_rezHeight = 2160;
break;
default:
break;
}
}

70
SQCSim2021/settings.h Normal file
View File

@ -0,0 +1,70 @@
#ifndef SETTINGS_H__
#define SETTINGS_H__
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include "define.h"
#include "audio.h"
class Settings {
public:
Settings(Audio& audio);
void SaveFile(const std::string& filename);
void LoadFile(const std::string& filename);
// Audio
float GetMainVolume() const;
void SetMainVolume(float volume);
void GetMusicVolume();
void SetMusicVolume(float volume);
float GetSfxVolume() const;
void SetSfxVolume(float volume);
// Graphic
float GetBrightness() const;
void SetBrightness(float brightness);
float GetContrast() const;
void SetContrast(float contrast);
bool GetFullscreen() const;
void SetFullscreen(bool fullscreen);
const Resolution& GetResolution() const;
void SetResolution(const Resolution& resolution);
// Gameplay
float GetMouseSensitivity() const;
void SetMouseSensitivity(float sensitivity);
void ApplyResolution(Resolution resolution);
private:
Audio& m_audio;
// Audio
float m_mainVolume;
float m_musicVolume;
float m_sfxVolume;
// Graphic
Resolution m_resolution;
bool m_fullscreen;
int m_rezWidth;
int m_rezHeight;
float m_brightness;
float m_contrast;
// Gameplay
float m_mouseSensitivity;
};
#endif // PARAMETERS_H