2021-09-24 10:15:43 -04:00
|
|
|
#ifndef ENGINE_H__
|
|
|
|
#define ENGINE_H__
|
2023-09-16 21:38:58 -04:00
|
|
|
|
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-12-05 06:25:48 -05:00
|
|
|
#include <set>
|
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"
|
2023-12-15 23:02:20 -05:00
|
|
|
#include "../SQCSim-common/booster.h"
|
2021-09-24 10:15:43 -04:00
|
|
|
#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"
|
2023-11-27 16:03:06 -05:00
|
|
|
#include "settings.h"
|
2021-09-24 10:15:43 -04:00
|
|
|
|
2021-11-15 20:58:13 -05:00
|
|
|
class Engine : public OpenglContext {
|
2021-09-24 10:15:43 -04:00
|
|
|
public:
|
|
|
|
Engine();
|
|
|
|
virtual ~Engine();
|
2023-12-15 23:02:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-24 10:15:43 -04:00
|
|
|
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);
|
2023-12-15 23:02:20 -05:00
|
|
|
virtual void MousePressEvent(const MOUSE_BUTTON& button, int x, int y);
|
|
|
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y);
|
2021-09-24 10:15:43 -04:00
|
|
|
|
|
|
|
private:
|
2023-09-16 21:38:58 -04:00
|
|
|
int GetFps(float elapsedTime) const;
|
2023-09-23 17:15:35 -04:00
|
|
|
int GetCountdown(float elapsedTime);
|
2023-12-01 09:49:00 -05:00
|
|
|
int GetOptionsChoice();
|
2023-12-09 15:54:06 -05:00
|
|
|
bool StartMultiplayerGame();
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-09-16 00:12:14 -04:00
|
|
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
2023-12-14 21:20:21 -05:00
|
|
|
void ChangeResolution(Resolution resolution);
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-10-23 15:43:55 -04:00
|
|
|
void InstantDamage();
|
2023-10-02 15:55:45 -04:00
|
|
|
void SystemNotification(std::string systemLog);
|
|
|
|
void KillNotification(Player killer, Player killed);
|
2023-12-03 00:15:18 -05:00
|
|
|
|
2023-10-02 15:55:45 -04:00
|
|
|
void DisplayNotification(std::string message);
|
2023-12-15 23:02:20 -05:00
|
|
|
|
2023-09-15 20:28:20 -04:00
|
|
|
void DisplayCrosshair();
|
2023-10-15 23:36:26 -04:00
|
|
|
void DisplayPovGun();
|
2023-09-16 00:12:14 -04:00
|
|
|
void DisplayCurrentItem();
|
2023-09-23 17:15:35 -04:00
|
|
|
void DisplayHud(int timer);
|
2023-09-15 20:28:20 -04:00
|
|
|
void DrawHud(float elapsedTime, BlockType bloc);
|
|
|
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
2023-12-03 00:15:18 -05:00
|
|
|
|
|
|
|
void DisplaySplashScreen();
|
|
|
|
|
|
|
|
void DisplayMainMenu();
|
|
|
|
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
|
|
|
|
void DrawMainMenuButtons(float centerX, float centerY);
|
|
|
|
void DrawSingleMultiButtons(float centerX, float centerY);
|
|
|
|
|
2023-12-08 23:06:33 -05:00
|
|
|
void DisplayLobbyMenu(float elapsedTime);
|
2023-12-08 23:42:01 -05:00
|
|
|
void SetPlayerUsername(float elapsedTime);
|
|
|
|
void SetServerAddress(float elapsedTime);
|
2023-12-08 23:06:33 -05:00
|
|
|
|
2023-12-11 21:41:40 -05:00
|
|
|
void DisplayPauseMenu(float elapsedTime);
|
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
void DisplayOptionsMenu();
|
2023-12-01 13:48:48 -05:00
|
|
|
void DisplayAudioMenu(float centerX, float centerY);
|
|
|
|
void DisplayGraphicsMenu(float centerX, float centerY);
|
2023-12-01 14:37:12 -05:00
|
|
|
void DisplayGameplayMenu(float centerX, float centerY);
|
2023-12-01 17:55:25 -05:00
|
|
|
void DrawSliderBackground(float centerX, float centerY, float minVal, float maxVal, float bottomSideValue, float topSideValue);
|
2023-12-01 19:20:55 -05:00
|
|
|
void DisplayBarPercentValue(float centerX, float centerY, float posX, float posY, float minVal, float maxVal, float value);
|
2023-12-03 00:15:18 -05:00
|
|
|
void DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue);
|
|
|
|
|
2023-10-15 23:36:26 -04:00
|
|
|
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
2023-12-01 09:49:00 -05:00
|
|
|
void ProcessNotificationQueue();
|
2023-12-08 19:55:59 -05:00
|
|
|
char SimulateKeyboard(unsigned char key);
|
2023-12-08 23:42:01 -05:00
|
|
|
void HandlePlayerInput(float elapsedTime);
|
2021-09-24 10:15:43 -04:00
|
|
|
|
2023-12-13 19:02:17 -05:00
|
|
|
Audio m_audio = Audio(AUDIO_PATH "music01.wav", AUDIO_PATH "menumusic01.wav");
|
2023-12-03 00:15:18 -05:00
|
|
|
irrklang::ISound* m_powpow, * m_scream;
|
|
|
|
irrklang::ISound* m_whoosh[MAX_BULLETS];
|
2023-11-20 16:02:45 -05:00
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
Bullet* m_bullets[MAX_BULLETS];
|
2023-11-20 16:02:45 -05:00
|
|
|
|
2023-12-04 13:13:54 -05:00
|
|
|
//Menu
|
|
|
|
Vector3f m_otherplayerpos = Vector3f(999, 999, 999);
|
2021-12-02 18:12:35 -05:00
|
|
|
|
2021-11-15 20:58:13 -05:00
|
|
|
World m_world = World();
|
2023-12-03 00:15:18 -05:00
|
|
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
|
|
|
|
2023-10-03 12:43:54 -04:00
|
|
|
Renderer m_renderer = Renderer();
|
2023-12-03 00:15:18 -05:00
|
|
|
|
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];
|
2023-12-09 15:54:06 -05:00
|
|
|
GameState m_gamestate = GameState::SPLASH;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
Shader m_shader01;
|
2023-11-20 15:40:43 -05:00
|
|
|
|
2021-10-12 15:58:54 -04:00
|
|
|
Skybox m_skybox;
|
2021-10-19 10:27:59 -04:00
|
|
|
|
2021-10-31 00:31:08 -04:00
|
|
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
2023-11-20 14:28:54 -05:00
|
|
|
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
|
2023-10-27 14:08:06 -04:00
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
TextureAtlas::TextureIndex texBoostHeal;
|
2023-10-02 17:09:03 -04:00
|
|
|
|
2021-10-26 17:28:37 -04:00
|
|
|
Texture m_textureCrosshair;
|
2023-10-23 16:11:35 -04:00
|
|
|
Texture m_textureFont;
|
2023-09-16 00:12:14 -04:00
|
|
|
Texture m_textureGun;
|
2023-10-15 23:36:26 -04:00
|
|
|
Texture m_texturePovGun;
|
2023-10-23 16:11:35 -04:00
|
|
|
Texture m_textureSkybox;
|
2023-11-14 22:17:00 -05:00
|
|
|
|
2023-12-06 13:14:51 -05:00
|
|
|
Texture m_textureLobbyMenu;
|
2023-12-03 00:15:18 -05:00
|
|
|
Texture m_textureMainMenu;
|
|
|
|
Texture m_textureOptionsMenu;
|
|
|
|
Texture m_texturePauseMenu;
|
|
|
|
Texture m_textureSplashScreen;
|
|
|
|
|
2023-12-01 13:48:48 -05:00
|
|
|
Texture m_textureHd;
|
|
|
|
Texture m_textureFhd;
|
|
|
|
Texture m_textureQhd;
|
|
|
|
Texture m_textureUhd;
|
2023-12-07 16:31:43 -05:00
|
|
|
|
|
|
|
Texture m_textureLobbyServer;
|
|
|
|
Texture m_textureLobbyIdentify;
|
2023-12-01 13:48:48 -05:00
|
|
|
Texture m_textureCheck;
|
|
|
|
Texture m_textureChecked;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-12-11 21:41:40 -05:00
|
|
|
Texture m_texturePauseResume;
|
|
|
|
Texture m_texturePauseMainMenu;
|
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
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;
|
|
|
|
|
|
|
|
Texture m_textureMenuBack;
|
|
|
|
Texture m_textureMenuMulti;
|
|
|
|
Texture m_textureMenuOptions;
|
|
|
|
Texture m_textureMenuPlay;
|
|
|
|
Texture m_textureMenuQuit;
|
|
|
|
Texture m_textureMenuSingle;
|
|
|
|
Texture m_textureMenuTitle;
|
|
|
|
|
|
|
|
Settings m_options = Settings(m_audio);
|
2023-10-02 17:09:03 -04:00
|
|
|
|
2023-12-01 13:48:48 -05:00
|
|
|
Resolution m_resolution = HD;
|
2023-11-14 22:17:00 -05:00
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
float m_splashTime = 2.0f;
|
2023-09-16 21:38:58 -04:00
|
|
|
float m_scale;
|
2023-09-23 17:15:35 -04:00
|
|
|
float m_time = 0;
|
2023-12-15 23:02:20 -05:00
|
|
|
|
2023-10-31 11:11:14 -04:00
|
|
|
float m_titleX = 0;
|
|
|
|
float m_titleY = 0;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-12-15 23:02:20 -05:00
|
|
|
|
2023-09-16 21:38:58 -04:00
|
|
|
|
|
|
|
int m_renderCount = 0;
|
2023-09-23 17:15:35 -04:00
|
|
|
int m_countdown = COUNTDOWN;
|
2023-11-08 10:32:16 -05:00
|
|
|
int m_nbReductionChunk = 4;
|
|
|
|
int m_timerReductionChunk = 30;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-12-14 00:08:07 -05:00
|
|
|
float m_mainvolume;
|
2023-12-13 19:59:01 -05:00
|
|
|
float m_musicvolume;
|
2023-12-14 00:08:07 -05:00
|
|
|
float m_sfxvolume;
|
2023-12-13 17:15:58 -05:00
|
|
|
float m_sensitivity;
|
2023-12-01 15:46:08 -05:00
|
|
|
|
2023-12-01 09:49:00 -05:00
|
|
|
int m_selectedOption = 0;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2023-12-03 00:15:18 -05:00
|
|
|
bool m_selectedOptAudioMainBar = false;
|
|
|
|
bool m_selectedOptAudioMusicBar = false;
|
2023-12-15 23:02:20 -05:00
|
|
|
bool m_selectedOptAudioSfxBar = false;
|
2023-12-03 00:15:18 -05:00
|
|
|
bool m_selectedGameplaySensitivityBar = false;
|
2023-12-01 15:46:08 -05:00
|
|
|
|
2023-10-23 15:43:55 -04:00
|
|
|
bool m_damage = false;
|
|
|
|
|
2023-09-16 21:38:58 -04:00
|
|
|
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;
|
2023-09-23 17:15:35 -04:00
|
|
|
bool m_resetcountdown = false;
|
2023-10-29 15:39:29 -04:00
|
|
|
bool m_soloMultiChoiceMade = false;
|
2023-09-23 17:15:35 -04:00
|
|
|
bool m_stopcountdown = false;
|
2023-12-03 00:15:18 -05:00
|
|
|
|
|
|
|
bool m_selectedPlayOptions = false;
|
|
|
|
bool m_selectedOptions = false;
|
|
|
|
bool m_selectedQuit = false;
|
2023-12-08 21:45:19 -05:00
|
|
|
|
2023-12-08 22:15:10 -05:00
|
|
|
std::string m_currentInputString;
|
2023-12-08 23:42:01 -05:00
|
|
|
std::string m_username;
|
|
|
|
std::string m_serverAddr;
|
2023-12-14 18:25:15 -05:00
|
|
|
|
2023-12-08 22:34:17 -05:00
|
|
|
char m_inputChar = 0;
|
|
|
|
bool m_invalidChar = false;
|
2023-12-08 21:45:19 -05:00
|
|
|
bool m_charChanged = false;
|
2023-12-08 23:06:33 -05:00
|
|
|
bool m_settingUsername = false;
|
|
|
|
bool m_settingServer = false;
|
2023-12-14 19:33:25 -05:00
|
|
|
bool m_selectedSinglePlayer = false;
|
|
|
|
bool m_selectedMultiPlayer = false;
|
|
|
|
bool m_singleReady = false;
|
2023-12-09 00:00:52 -05:00
|
|
|
bool m_multiReady = false;
|
2023-12-14 19:33:25 -05:00
|
|
|
|
2023-12-15 23:02:20 -05:00
|
|
|
|
2023-11-20 16:02:45 -05:00
|
|
|
bool m_key1 = false;
|
|
|
|
bool m_key2 = false;
|
2023-12-15 15:40:13 -05:00
|
|
|
|
2023-10-02 15:55:45 -04:00
|
|
|
bool m_keyK = false;
|
|
|
|
bool m_keyL = false;
|
2021-09-24 10:15:43 -04:00
|
|
|
bool m_keyW = false;
|
|
|
|
bool m_keyA = false;
|
|
|
|
bool m_keyS = false;
|
|
|
|
bool m_keyD = false;
|
2023-12-08 21:45:19 -05:00
|
|
|
bool m_keyEnter = false;
|
2021-10-01 10:52:33 -04:00
|
|
|
bool m_keySpace = false;
|
2023-12-08 19:55:59 -05:00
|
|
|
bool m_keyShift = false;
|
2023-12-08 23:06:33 -05:00
|
|
|
bool m_keyBackspace = false;
|
2023-12-03 00:15:18 -05:00
|
|
|
|
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-12-03 00:15:18 -05:00
|
|
|
|
2023-10-02 17:09:03 -04:00
|
|
|
float m_mousemx = 0;
|
|
|
|
float m_mousemy = 0;
|
2023-10-02 15:55:45 -04:00
|
|
|
|
2023-10-23 16:44:34 -04:00
|
|
|
bool m_networkgame = false;
|
2023-12-15 23:02:20 -05:00
|
|
|
|
2023-12-04 13:13:54 -05:00
|
|
|
Connector m_conn;
|
2023-12-05 06:25:48 -05:00
|
|
|
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
|
2023-12-04 13:13:54 -05:00
|
|
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
|
|
|
std::unordered_map<uint64_t, Player*> m_players;
|
2023-12-16 12:57:04 -05:00
|
|
|
std::set<uint64_t> m_deadplayers;
|
2023-12-04 13:13:54 -05:00
|
|
|
netprot::Buffer m_buf, m_bufout;
|
|
|
|
netprot::ChunkMod* m_chunkmod = nullptr;
|
2023-12-18 13:29:38 -05:00
|
|
|
std::unordered_map<uint64_t, Booster*> m_boosters;
|
2023-12-18 14:50:18 -05:00
|
|
|
std::set<uint64_t> m_boost_manifest;
|
2023-12-09 12:02:04 -05:00
|
|
|
|
2023-11-24 15:24:46 -05:00
|
|
|
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
|
2023-10-02 15:55:45 -04:00
|
|
|
std::string m_messageNotification = "";
|
2021-09-24 10:15:43 -04:00
|
|
|
};
|
|
|
|
|
2023-12-15 23:02:20 -05:00
|
|
|
#endif // ENGINE_H__
|