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>
|
|
|
|
#include <cmath>
|
2023-09-29 12:04:08 -04:00
|
|
|
#include "../SQCSim-common/array2d.h"
|
|
|
|
#include "../SQCSim-common/blockinfo.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"
|
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-09-30 14:46:54 -04:00
|
|
|
#include "worldrenderer.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();
|
|
|
|
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:
|
2023-09-16 21:38:58 -04:00
|
|
|
float GetScale() const;
|
|
|
|
|
|
|
|
int GetFps(float elapsedTime) const;
|
2023-09-23 17:15:35 -04:00
|
|
|
int GetCountdown(float elapsedTime);
|
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-09-16 21:38:58 -04:00
|
|
|
|
2023-10-02 15:55:45 -04:00
|
|
|
void SystemNotification(std::string systemLog);
|
|
|
|
void KillNotification(Player killer, Player killed);
|
|
|
|
void DisplayNotification(std::string message);
|
|
|
|
void ProcessNotificationQueue();
|
2023-09-15 20:28:20 -04:00
|
|
|
void DisplayCrosshair();
|
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 DisplayInfo(float elapsedTime, BlockType bloc);
|
|
|
|
void DrawHud(float elapsedTime, BlockType bloc);
|
2023-09-16 21:38:58 -04:00
|
|
|
void PrintText(float x, float y, float scale, const std::string& t);
|
2021-09-24 10:15:43 -04:00
|
|
|
|
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];
|
|
|
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
2021-12-02 18:12:35 -05:00
|
|
|
|
2021-11-15 20:58:13 -05:00
|
|
|
World m_world = World();
|
2023-09-30 14:46:54 -04:00
|
|
|
WorldRenderer m_wrenderer = WorldRenderer();
|
2021-11-26 11:59:02 -05:00
|
|
|
|
2021-09-27 10:20:58 -04:00
|
|
|
Texture m_textureSkybox;
|
2021-10-26 17:28:37 -04:00
|
|
|
Texture m_textureFont;
|
|
|
|
Texture m_textureCrosshair;
|
2023-09-16 00:12:14 -04:00
|
|
|
Texture m_textureGun;
|
2023-09-16 21:38:58 -04:00
|
|
|
|
2021-10-12 15:58:54 -04:00
|
|
|
Skybox m_skybox;
|
2023-09-15 11:24:43 -04:00
|
|
|
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
|
|
|
|
2023-09-04 13:30:42 -04:00
|
|
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
2023-10-02 15:55:45 -04:00
|
|
|
|
2021-12-07 18:59:50 -05:00
|
|
|
Bullet* m_bullets[MAX_BULLETS];
|
|
|
|
|
2023-09-16 21:38:58 -04:00
|
|
|
float m_scale;
|
2023-09-23 17:15:35 -04:00
|
|
|
float m_time = 0;
|
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-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;
|
|
|
|
bool m_displayInfo = false;
|
2023-09-23 17:15:35 -04:00
|
|
|
bool m_resetcountdown = false;
|
|
|
|
bool m_stopcountdown = false;
|
2023-09-16 21:38:58 -04: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;
|
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 15:55:45 -04:00
|
|
|
|
|
|
|
std::string m_messageNotification = "";
|
2021-09-24 10:15:43 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENGINE_H__
|