SQCSimulator2023/SQCSim2021/engine.h

168 lines
4.9 KiB
C
Raw Normal View History

#ifndef ENGINE_H__
#define ENGINE_H__
2023-09-25 08:23:52 -04:00
#include <algorithm>
2023-11-02 15:47:15 -04:00
#include <chrono>
2023-09-25 08:23:52 -04:00
#include <cmath>
2023-11-06 13:56:12 -05:00
#include <unordered_map>
2023-09-29 12:04:08 -04:00
#include "../SQCSim-common/array2d.h"
#include "../SQCSim-common/blockinfo.h"
2023-10-30 14:32:20 -04:00
#include "../SQCSim-common/boostinfo.h"
2023-09-29 17:02:57 -04:00
#include "../SQCSim-common/bullet.h"
2023-09-30 14:46:54 -04:00
#include "../SQCSim-common/chunk.h"
#include "../SQCSim-common/world.h"
#include "../SQCSim-common/transformation.h"
#include "../SQCSim-common/player.h"
#include "define.h"
#include "openglcontext.h"
#include "texture.h"
2021-10-26 17:28:37 -04:00
#include "shader.h"
2021-10-12 15:58:54 -04:00
#include "skybox.h"
2021-10-19 10:27:59 -04:00
#include "audio.h"
2021-10-26 17:28:37 -04:00
#include "textureatlas.h"
2023-09-25 08:23:52 -04:00
#include "connector.h"
2023-10-03 12:43:54 -04:00
#include "renderer.h"
2023-10-27 14:08:06 -04:00
#include "remoteplayer.h"
#include "booster.h"
#include "settings.h"
2021-11-15 20:58:13 -05:00
class Engine : public OpenglContext {
public:
Engine();
virtual ~Engine();
2023-10-02 17:09:03 -04:00
virtual void DrawMenu();
2023-10-23 17:51:29 -04:00
virtual void DrawPause();
2023-10-23 16:57:19 -04:00
virtual void DrawSplachScreen();
virtual void Init();
virtual void DeInit();
virtual void LoadResource();
virtual void UnloadResource();
virtual void Render(float elapsedTime);
virtual void KeyPressEvent(unsigned char key);
virtual void KeyReleaseEvent(unsigned char key);
virtual void MouseMoveEvent(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);
private:
int GetFps(float elapsedTime) const;
int GetCountdown(float elapsedTime);
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
2023-10-23 15:43:55 -04:00
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);
2023-10-23 16:11:35 -04:00
void DisplaySingleOrMultiplayerMenu();
void DrawHud(float elapsedTime, BlockType bloc);
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
2023-09-25 17:17:17 -04:00
Connector m_conn;
2021-12-02 18:12:35 -05:00
Shader m_shader01;
2021-10-31 00:31:08 -04:00
BlockInfo* m_blockinfo[BTYPE_LAST];
2023-10-30 14:32:20 -04:00
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
2021-10-31 00:31:08 -04:00
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
2021-12-02 18:12:35 -05:00
2021-11-15 20:58:13 -05:00
World m_world = World();
2023-10-03 12:43:54 -04:00
Renderer m_renderer = Renderer();
Booster m_booster = Booster();
2021-11-26 11:59:02 -05:00
2021-10-26 17:28:37 -04:00
Texture m_textureCrosshair;
2023-10-23 16:11:35 -04:00
Texture m_textureFont;
Texture m_textureGun;
Texture m_texturePovGun;
2023-10-23 16:11:35 -04:00
Texture m_textureSkybox;
Texture m_textureSoloMultiMenu;
2023-10-29 15:39:29 -04:00
Texture m_textureSoloText;
Texture m_textureMultiText;
Texture m_textureTitle;
TextureAtlas::TextureIndex texBoostHeal;
2021-10-12 15:58:54 -04:00
Skybox m_skybox;
Audio m_audio = Audio(AUDIO_PATH "start.wav");
2021-10-19 10:27:59 -04:00
2023-10-16 12:02:37 -04:00
irrklang::ISound* m_powpow,
* m_scream;
irrklang::ISound *m_whoosh[MAX_BULLETS];
2021-12-07 18:59:50 -05:00
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
Settings m_parameters = Settings(m_audio);
2021-12-07 18:59:50 -05:00
Bullet* m_bullets[MAX_BULLETS];
2023-11-06 13:56:12 -05:00
std::unordered_map<uint64_t, Player*> m_players;
2023-11-06 17:59:57 -05:00
netprot::Buffer m_buf, m_bufout;
2023-11-02 15:47:15 -04:00
std::chrono::high_resolution_clock::time_point m_startTime;
2023-10-27 14:08:06 -04:00
2023-10-02 17:09:03 -04:00
//Menu
2023-11-06 15:39:54 -05:00
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
2023-10-16 17:36:04 -04:00
GameState m_gamestate = GameState::MAIN_MENU;
2023-10-02 17:09:03 -04:00
Texture MenuTitleTexture;
Texture MenuBGTexture;
Texture MenuStartTexture;
Texture MenuQuitTexture;
Texture MenuOptionsTexture;
2023-10-30 15:49:17 -04:00
Texture PauseBGTexture;
2023-10-23 16:57:19 -04:00
Texture SplachScreenTexture;
2023-10-02 17:09:03 -04:00
2023-11-14 22:17:00 -05:00
float m_scale;
float m_time = 0;
2023-10-23 16:57:19 -04:00
float m_time_SplashScreen = 0;
float m_titleX = 0;
float m_titleY = 0;
int m_renderCount = 0;
int m_countdown = COUNTDOWN;
2023-11-08 10:32:16 -05:00
int m_nbReductionChunk = 4;
int m_timerReductionChunk = 30;
2023-10-23 15:43:55 -04:00
bool m_damage = false;
bool m_wireframe = false;
bool m_isSkybox = true;
bool m_block = false;
bool m_flash = true;
bool m_displayCrosshair = true;
bool m_displayHud = true;
2023-11-19 16:46:13 -05:00
bool m_displayInfo = true;
bool m_resetcountdown = false;
2023-10-29 15:39:29 -04:00
bool m_soloMultiChoiceMade = false;
bool m_stopcountdown = false;
2023-11-20 16:02:45 -05:00
bool m_key1 = false;
bool m_key2 = false;
bool m_keyK = false;
bool m_keyL = false;
bool m_keyW = false;
bool m_keyA = false;
bool m_keyS = false;
bool m_keyD = false;
2021-10-01 10:52:33 -04:00
bool m_keySpace = false;
2021-11-26 11:59:02 -05:00
bool m_mouseL = false;
bool m_mouseR = false;
bool m_mouseC = false;
bool m_mouseWU = false;
bool m_mouseWD = false;
2023-10-02 17:09:03 -04:00
//Pour trouver ou est la souris
float m_mousemx = 0;
float m_mousemy = 0;
2023-10-23 16:44:34 -04:00
bool m_networkgame = false;
2023-11-13 16:02:13 -05:00
netprot::PlayerInfo m_pinfo;
2023-11-19 16:46:13 -05:00
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));
std::string m_messageNotification = "";
};
#endif // ENGINE_H__