Refactoring major
This commit is contained in:
parent
1265d87bc5
commit
5b57696acf
1560
src/Game.cpp
1560
src/Game.cpp
File diff suppressed because it is too large
Load Diff
88
src/Game.h
88
src/Game.h
@ -35,113 +35,27 @@ namespace ZL {
|
|||||||
Renderer renderer;
|
Renderer renderer;
|
||||||
TaskManager taskManager;
|
TaskManager taskManager;
|
||||||
MainThreadHandler mainThreadHandler;
|
MainThreadHandler mainThreadHandler;
|
||||||
|
|
||||||
std::unique_ptr<INetworkClient> networkClient;
|
std::unique_ptr<INetworkClient> networkClient;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t getSyncTimeMs();
|
int64_t getSyncTimeMs();
|
||||||
void processTickCount();
|
void processTickCount();
|
||||||
void drawScene();
|
void drawScene();
|
||||||
void drawCubemap(float skyPercent);
|
|
||||||
void drawShip();
|
|
||||||
void drawBoxes();
|
|
||||||
void drawBoxesLabels();
|
|
||||||
void drawUI();
|
void drawUI();
|
||||||
void drawRemoteShips();
|
|
||||||
void drawRemoteShipsLabels();
|
|
||||||
void fireProjectiles();
|
|
||||||
|
|
||||||
bool worldToScreen(const Vector3f& world, float& outX, float& outY, float& outDepth) const;
|
|
||||||
|
|
||||||
void handleDown(int mx, int my);
|
void handleDown(int mx, int my);
|
||||||
void handleUp(int mx, int my);
|
void handleUp(int mx, int my);
|
||||||
void handleMotion(int mx, int my);
|
void handleMotion(int mx, int my);
|
||||||
|
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
SDL_GLContext glContext;
|
SDL_GLContext glContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t newTickCount;
|
int64_t newTickCount;
|
||||||
int64_t lastTickCount;
|
int64_t lastTickCount;
|
||||||
|
|
||||||
std::vector<BoxCoords> boxCoordsArr;
|
|
||||||
std::vector<VertexRenderStruct> boxRenderArr;
|
|
||||||
|
|
||||||
std::vector<std::string> boxLabels;
|
|
||||||
std::unique_ptr<TextRenderer> textRenderer;
|
|
||||||
|
|
||||||
//std::unordered_map<int, ClientStateInterval> latestRemotePlayers;
|
|
||||||
std::unordered_map<int, ClientState> remotePlayerStates;
|
|
||||||
|
|
||||||
float newShipVelocity = 0;
|
|
||||||
|
|
||||||
static const size_t CONST_TIMER_INTERVAL = 10;
|
static const size_t CONST_TIMER_INTERVAL = 10;
|
||||||
static const size_t CONST_MAX_TIME_INTERVAL = 1000;
|
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;
|
|
||||||
|
|
||||||
MenuManager menuManager;
|
MenuManager menuManager;
|
||||||
|
Space space;
|
||||||
std::vector<std::unique_ptr<Projectile>> projectiles;
|
|
||||||
std::shared_ptr<Texture> projectileTexture;
|
|
||||||
float projectileCooldownMs = 500.0f;
|
|
||||||
int64_t lastProjectileFireTime = 0;
|
|
||||||
int maxProjectiles = 32;
|
|
||||||
std::vector<Vector3f> shipLocalEmissionPoints;
|
|
||||||
|
|
||||||
|
|
||||||
bool shipAlive = true;
|
|
||||||
bool gameOver = false;
|
|
||||||
std::vector<bool> boxAlive;
|
|
||||||
float shipCollisionRadius = 15.0f;
|
|
||||||
float boxCollisionRadius = 2.0f;
|
|
||||||
//bool uiGameOverShown = false;
|
|
||||||
bool showExplosion = false;
|
|
||||||
uint64_t lastExplosionTime = 0;
|
|
||||||
const uint64_t explosionDurationMs = 500;
|
|
||||||
|
|
||||||
bool serverBoxesApplied = false;
|
|
||||||
|
|
||||||
static constexpr float MAX_DIST_SQ = 10000.f * 10000.f;
|
|
||||||
static constexpr float FADE_START = 6000.f;
|
|
||||||
static constexpr float FADE_RANGE = 4000.f;
|
|
||||||
static constexpr float BASE_SCALE = 140.f;
|
|
||||||
static constexpr float PERSPECTIVE_K = 0.05f; // Tune
|
|
||||||
static constexpr float MIN_SCALE = 0.4f;
|
|
||||||
static constexpr float MAX_SCALE = 0.8f;
|
|
||||||
static constexpr float CLOSE_DIST = 600.0f;
|
|
||||||
|
|
||||||
std::unordered_set<int> deadRemotePlayers;
|
|
||||||
|
|
||||||
// --- Target HUD (brackets + offscreen arrow) ---
|
|
||||||
int trackedTargetId = -1;
|
|
||||||
bool targetWasVisible = false;
|
|
||||||
float targetAcquireAnim = 0.0f; // 0..1 схлопывание (0 = далеко, 1 = на месте)
|
|
||||||
|
|
||||||
// временный меш для HUD (будем перезаливать VBO маленькими порциями)
|
|
||||||
VertexRenderStruct hudTempMesh;
|
|
||||||
|
|
||||||
// helpers
|
|
||||||
bool projectToNDC(const Vector3f& world, float& ndcX, float& ndcY, float& ndcZ, float& clipW) const;
|
|
||||||
void drawTargetHud(); // рисует рамку или стрелку
|
|
||||||
int pickTargetId() const; // выбирает цель (пока: ближайший живой удаленный игрок)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1482
src/Space.cpp
1482
src/Space.cpp
File diff suppressed because it is too large
Load Diff
31
src/Space.h
31
src/Space.h
@ -27,31 +27,32 @@ namespace ZL {
|
|||||||
Matrix3f m;
|
Matrix3f m;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
class Space {
|
class Space {
|
||||||
public:
|
public:
|
||||||
Space(Renderer& iRenderer, TaskManager& iTaskManager, MainThreadHandler& iMainThreadHandler);
|
Space(Renderer& iRenderer, TaskManager& iTaskManager, MainThreadHandler& iMainThreadHandler, std::unique_ptr<INetworkClient>& iNetworkClient, MenuManager& iMenuManager);
|
||||||
~Space();
|
~Space();
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void update();
|
void update();
|
||||||
void render();
|
|
||||||
|
|
||||||
bool shouldExit() const { return Environment::exitGameLoop; }
|
bool shouldExit() const { return Environment::exitGameLoop; }
|
||||||
|
|
||||||
Renderer& renderer;
|
Renderer& renderer;
|
||||||
TaskManager& taskManager;
|
TaskManager& taskManager;
|
||||||
MainThreadHandler& mainThreadHandler;
|
MainThreadHandler& mainThreadHandler;
|
||||||
|
std::unique_ptr<INetworkClient>& networkClient;
|
||||||
|
MenuManager& menuManager;
|
||||||
|
|
||||||
private:
|
|
||||||
int64_t getSyncTimeMs();
|
public:
|
||||||
void processTickCount();
|
void processTickCount(int64_t newTickCount, int64_t delta);
|
||||||
void drawScene();
|
void drawScene();
|
||||||
void drawCubemap(float skyPercent);
|
void drawCubemap(float skyPercent);
|
||||||
void drawShip();
|
void drawShip();
|
||||||
void drawBoxes();
|
void drawBoxes();
|
||||||
void drawBoxesLabels();
|
void drawBoxesLabels();
|
||||||
void drawUI();
|
//void drawUI();
|
||||||
void drawRemoteShips();
|
void drawRemoteShips();
|
||||||
void drawRemoteShipsLabels();
|
void drawRemoteShipsLabels();
|
||||||
void fireProjectiles();
|
void fireProjectiles();
|
||||||
@ -62,13 +63,13 @@ namespace ZL {
|
|||||||
void handleUp(int mx, int my);
|
void handleUp(int mx, int my);
|
||||||
void handleMotion(int mx, int my);
|
void handleMotion(int mx, int my);
|
||||||
|
|
||||||
SDL_Window* window;
|
//SDL_Window* window;
|
||||||
SDL_GLContext glContext;
|
//SDL_GLContext glContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t newTickCount;
|
//int64_t newTickCount;
|
||||||
int64_t lastTickCount;
|
//int64_t lastTickCount;
|
||||||
|
|
||||||
std::vector<BoxCoords> boxCoordsArr;
|
std::vector<BoxCoords> boxCoordsArr;
|
||||||
std::vector<VertexRenderStruct> boxRenderArr;
|
std::vector<VertexRenderStruct> boxRenderArr;
|
||||||
@ -76,7 +77,6 @@ namespace ZL {
|
|||||||
std::vector<std::string> boxLabels;
|
std::vector<std::string> boxLabels;
|
||||||
std::unique_ptr<TextRenderer> textRenderer;
|
std::unique_ptr<TextRenderer> textRenderer;
|
||||||
|
|
||||||
//std::unordered_map<int, ClientStateInterval> latestRemotePlayers;
|
|
||||||
std::unordered_map<int, ClientState> remotePlayerStates;
|
std::unordered_map<int, ClientState> remotePlayerStates;
|
||||||
|
|
||||||
float newShipVelocity = 0;
|
float newShipVelocity = 0;
|
||||||
@ -101,7 +101,7 @@ namespace ZL {
|
|||||||
SparkEmitter explosionEmitter;
|
SparkEmitter explosionEmitter;
|
||||||
PlanetObject planetObject;
|
PlanetObject planetObject;
|
||||||
|
|
||||||
MenuManager menuManager;
|
//MenuManager menuManager;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Projectile>> projectiles;
|
std::vector<std::unique_ptr<Projectile>> projectiles;
|
||||||
std::shared_ptr<Texture> projectileTexture;
|
std::shared_ptr<Texture> projectileTexture;
|
||||||
@ -116,7 +116,6 @@ namespace ZL {
|
|||||||
std::vector<bool> boxAlive;
|
std::vector<bool> boxAlive;
|
||||||
float shipCollisionRadius = 15.0f;
|
float shipCollisionRadius = 15.0f;
|
||||||
float boxCollisionRadius = 2.0f;
|
float boxCollisionRadius = 2.0f;
|
||||||
//bool uiGameOverShown = false;
|
|
||||||
bool showExplosion = false;
|
bool showExplosion = false;
|
||||||
uint64_t lastExplosionTime = 0;
|
uint64_t lastExplosionTime = 0;
|
||||||
const uint64_t explosionDurationMs = 500;
|
const uint64_t explosionDurationMs = 500;
|
||||||
@ -146,7 +145,9 @@ namespace ZL {
|
|||||||
bool projectToNDC(const Vector3f& world, float& ndcX, float& ndcY, float& ndcZ, float& clipW) const;
|
bool projectToNDC(const Vector3f& world, float& ndcX, float& ndcY, float& ndcZ, float& clipW) const;
|
||||||
void drawTargetHud(); // рисует рамку или стрелку
|
void drawTargetHud(); // рисует рамку или стрелку
|
||||||
int pickTargetId() const; // выбирает цель (пока: ближайший живой удаленный игрок)
|
int pickTargetId() const; // выбирает цель (пока: ближайший живой удаленный игрок)
|
||||||
};*/
|
|
||||||
|
void clearTextRendererCache();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace ZL
|
} // namespace ZL
|
||||||
Loading…
Reference in New Issue
Block a user