152 lines
4.2 KiB
C++
152 lines
4.2 KiB
C++
#ifndef ENGINE_H__
|
|
#define ENGINE_H__
|
|
|
|
#include <algorithm>
|
|
#include <chrono>
|
|
#include <cmath>
|
|
#include <unordered_map>
|
|
#include "../SQCSim-common/array2d.h"
|
|
#include "../SQCSim-common/blockinfo.h"
|
|
#include "../SQCSim-common/bullet.h"
|
|
#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"
|
|
#include "shader.h"
|
|
#include "skybox.h"
|
|
#include "audio.h"
|
|
#include "textureatlas.h"
|
|
#include "connector.h"
|
|
#include "renderer.h"
|
|
#include "remoteplayer.h"
|
|
|
|
class Engine : public OpenglContext {
|
|
public:
|
|
Engine();
|
|
virtual ~Engine();
|
|
virtual void DrawMenu();
|
|
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);
|
|
|
|
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 PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
|
|
|
Connector m_conn;
|
|
Shader m_shader01;
|
|
BlockInfo* m_blockinfo[BTYPE_LAST];
|
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
|
|
|
World m_world = World();
|
|
Renderer m_renderer = Renderer();
|
|
|
|
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;
|
|
|
|
Skybox m_skybox;
|
|
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
|
|
|
irrklang::ISound* m_powpow,
|
|
* m_scream;
|
|
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
|
|
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
|
|
|
Bullet* m_bullets[MAX_BULLETS];
|
|
|
|
std::unordered_map<uint64_t, Player*> m_players;
|
|
netprot::Buffer m_buf;
|
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
|
|
|
//Menu
|
|
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
|
GameState m_gamestate = GameState::MAIN_MENU;
|
|
Texture MenuTitleTexture;
|
|
Texture MenuBGTexture;
|
|
Texture MenuStartTexture;
|
|
Texture MenuQuitTexture;
|
|
Texture MenuOptionsTexture;
|
|
Texture SplachScreenTexture;
|
|
|
|
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;
|
|
|
|
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;
|
|
bool m_displayInfo = false;
|
|
bool m_resetcountdown = false;
|
|
bool m_soloMultiChoiceMade = false;
|
|
bool m_stopcountdown = 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;
|
|
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;
|
|
|
|
std::string m_messageNotification = "";
|
|
};
|
|
|
|
#endif // ENGINE_H__
|