110 lines
2.5 KiB
C++
110 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "render/Renderer.h"
|
|
#include "Environment.h"
|
|
#include "render/TextureManager.h"
|
|
#include "SparkEmitter.h"
|
|
#include "planet/PlanetObject.h"
|
|
#include "UiManager.h"
|
|
#include "Projectile.h"
|
|
#include "utils/TaskManager.h"
|
|
#include <queue>
|
|
|
|
namespace ZL {
|
|
|
|
|
|
struct BoxCoords
|
|
{
|
|
Vector3f pos;
|
|
Matrix3f m;
|
|
};
|
|
|
|
|
|
class Game {
|
|
public:
|
|
Game();
|
|
~Game();
|
|
|
|
void setup();
|
|
void update();
|
|
void render();
|
|
|
|
bool shouldExit() const { return Environment::exitGameLoop; }
|
|
|
|
Renderer renderer;
|
|
TaskManager taskManager;
|
|
MainThreadHandler mainThreadHandler;
|
|
private:
|
|
void processTickCount();
|
|
void drawScene();
|
|
void drawCubemap(float skyPercent);
|
|
void drawShip();
|
|
void drawBoxes();
|
|
void drawUI();
|
|
|
|
void fireProjectiles();
|
|
|
|
void handleDown(int mx, int my);
|
|
void handleUp(int mx, int my);
|
|
void handleMotion(int mx, int my);
|
|
|
|
SDL_Window* window;
|
|
SDL_GLContext glContext;
|
|
|
|
|
|
|
|
size_t newTickCount;
|
|
size_t lastTickCount;
|
|
|
|
std::vector<BoxCoords> boxCoordsArr;
|
|
std::vector<VertexRenderStruct> boxRenderArr;
|
|
|
|
|
|
static const size_t CONST_TIMER_INTERVAL = 10;
|
|
static const size_t CONST_MAX_TIME_INTERVAL = 1000;
|
|
|
|
std::shared_ptr<Texture> sparkTexture;
|
|
std::shared_ptr<Texture> spaceshipTexture;
|
|
std::shared_ptr<Texture> cubemapTexture;
|
|
VertexDataStruct spaceshipBase;
|
|
VertexRenderStruct spaceship;
|
|
|
|
VertexRenderStruct cubemap;
|
|
|
|
std::shared_ptr<Texture> boxTexture;
|
|
VertexDataStruct boxBase;
|
|
|
|
SparkEmitter sparkEmitter;
|
|
SparkEmitter projectileEmitter;
|
|
SparkEmitter explosionEmitter;
|
|
PlanetObject planetObject;
|
|
UiManager uiManager;
|
|
|
|
std::vector<std::unique_ptr<Projectile>> projectiles;
|
|
std::shared_ptr<Texture> projectileTexture;
|
|
float projectileCooldownMs = 500.0f;
|
|
uint64_t lastProjectileFireTime = 0;
|
|
int maxProjectiles = 32;
|
|
std::vector<Vector3f> shipLocalEmissionPoints;
|
|
|
|
|
|
bool isDraggingShip = false;
|
|
bool isDraggingCamera = false;
|
|
Matrix3f rotateShipMat = Matrix3f::Identity(); // Локальный поворот от джойстика
|
|
Matrix3f shipWorldOrientation = Matrix3f::Identity(); // Ориентация корабля в мире (независимо от камеры)
|
|
bool shipMoveLockActive = false;
|
|
Matrix3f lockedCameraMat = Matrix3f::Identity();
|
|
|
|
|
|
bool shipAlive = true;
|
|
bool gameOver = false;
|
|
std::vector<bool> boxAlive;
|
|
float shipCollisionRadius = 3.5f;
|
|
float boxCollisionRadius = 2.0f;
|
|
bool uiGameOverShown = false;
|
|
bool showExplosion = false;
|
|
|
|
};
|
|
|
|
|
|
} // namespace ZL
|