shadow-over-bishkek001/src/Game.h
2026-04-01 19:07:21 +03:00

132 lines
3.1 KiB
C++

#pragma once
#include "BoneAnimatedModel.h"
#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 "network/NetworkInterface.h"
#include <queue>
#include <vector>
#include <string>
#include <memory>
#include <cstdint>
#include <render/TextRenderer.h>
#include "MenuManager.h"
#include "Space.h"
#include <unordered_set>
namespace ZL {
class Game {
public:
Game();
~Game();
void setup();
void setupPart2();
void update();
void render();
bool shouldExit() const { return Environment::exitGameLoop; }
Renderer renderer;
TaskManager taskManager;
MainThreadHandler mainThreadHandler;
//std::unique_ptr<INetworkClient> networkClient;
std::shared_ptr<Texture> loadingTexture;
VertexRenderStruct loadingMesh;
bool loadingCompleted = false;
std::shared_ptr<Texture> roomTexture;
VertexRenderStruct roomMesh;
std::shared_ptr<Texture> fireboxTexture;
VertexRenderStruct fireboxMesh;
std::shared_ptr<Texture> inaiTexture;
VertexRenderStruct inaiMesh;
std::shared_ptr<Texture> benchTexture;
VertexRenderStruct benchMesh;
BoneSystem violaIdleModel;
VertexRenderStruct violaIdleModelMutable;
BoneSystem violaWalkModel;
VertexRenderStruct violaWalkModelMutable;
BoneSystem zombieModel;
VertexRenderStruct zombieModelMutable;
std::shared_ptr<Texture> violaTexture;
float zombieCurrentIdleFrame = 0;
int zombieLastIdleFrame = 0;
float violaCurrentIdleFrame = 0;
float violaCurrentWalkFrame = 0;
int violaLastIdleFrame = 0;
int violaLastWalkFrame = 0;
int violaCurrentAnimation = 0;
float cameraAzimuth = 0.0f;
float cameraInclination = M_PI * 30.f / 180.f;
Eigen::Vector3f violaPosition = Eigen::Vector3f(0.f, 0.f, 0.f);
Eigen::Vector3f violaTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
float violaFacingAngle = 0.0f;
private:
bool rightMouseDown = false;
int lastMouseX = 0;
int lastMouseY = 0;
static constexpr float CAMERA_FOV_Y = 1.0f / 1.5f;
static constexpr float VIOLA_WALK_SPEED = 3.0f;
static constexpr float VIOLA_WALK_THRESHOLD = 0.05f;
static constexpr float VIOLA_ROTATION_SPEED = 8.0f; // radians per second
float violaTargetFacingAngle = 0.0f;
int64_t getSyncTimeMs();
void processTickCount();
void drawScene();
void drawUI();
void drawGame();
void drawLoading();
void handleDown(int64_t fingerId, int mx, int my);
void handleUp(int64_t fingerId, int mx, int my);
void handleMotion(int64_t fingerId, int mx, int my);
#ifdef EMSCRIPTEN
static Game* s_instance;
static void onResourcesZipLoaded(const char* filename);
static void onResourcesZipError(const char* filename);
#endif
//SDL_Window* window;
//SDL_GLContext glContext;
int64_t newTickCount;
int64_t lastTickCount;
uint32_t connectingStartTicks = 0;
static constexpr uint32_t CONNECTING_TIMEOUT_MS = 10000;
static const size_t CONST_TIMER_INTERVAL = 10;
static const size_t CONST_MAX_TIME_INTERVAL = 1000;
MenuManager menuManager;
//Space space;
};
} // namespace ZL