add local server

This commit is contained in:
Vlad committed 2026-02-09 18:42:07 +06:00
1 parent a59bcc0c4b
commit 629c9ba7b1
5 files changed
+6535 -32

No files matched your search

+28 -4
View File
@@ -26,8 +26,8 @@ namespace ZL
#ifdef EMSCRIPTEN
const char* CONST_ZIP_FILE = "resources.zip";
#else
const char* CONST_ZIP_FILE = "C:\\Work\\Projects\\space-game001\\resources.zip";
//const char* CONST_ZIP_FILE = "";
//const char* CONST_ZIP_FILE = "C:\\Work\\Projects\\space-game001\\resources.zip";
const char* CONST_ZIP_FILE = "";
#endif
static bool g_exitBgAnimating = false;
@@ -440,12 +440,27 @@ namespace ZL
//spaceshipBase = LoadFromTextFile02("./resources/spaceship006x.txt", CONST_ZIP_FILE);
//spaceshipBase.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI / 2.0, Eigen::Vector3f::UnitY())).toRotationMatrix());// QuatFromRotateAroundY(M_PI / 2.0).toRotationMatrix());
spaceshipTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/MainCharacter_Base_color_sRGB.png", CONST_ZIP_FILE));
spaceshipBase = LoadFromTextFile02("resources/spaceshipnew001.txt", CONST_ZIP_FILE);
spaceshipBase.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY())).toRotationMatrix());// QuatFromRotateAroundY(M_PI / 2.0).toRotationMatrix());
spaceshipBase.Move(Vector3f{ 1.2, 0, -5 });
/*
spaceshipTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/Cargo_Base_color_sRGB.png", CONST_ZIP_FILE));
spaceshipBase = LoadFromTextFile02("resources/cargoship001.txt", CONST_ZIP_FILE);
auto quat = Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI*0.5, Eigen::Vector3f::UnitZ()));
auto rotMatrix = quat.toRotationMatrix();
spaceshipBase.RotateByMatrix(rotMatrix);
auto quat2 = Eigen::Quaternionf(Eigen::AngleAxisf(M_PI*0.5, Eigen::Vector3f::UnitY()));
auto rotMatrix2 = quat2.toRotationMatrix();
spaceshipBase.RotateByMatrix(rotMatrix2);
//spaceshipBase.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY())).toRotationMatrix());// QuatFromRotateAroundY(M_PI / 2.0).toRotationMatrix());
*/
spaceship.AssignFrom(spaceshipBase);
spaceship.RefreshVBO();
@@ -835,7 +850,7 @@ namespace ZL
for (auto const& [id, remotePlayer] : remotePlayerStates)
{
//<<<<<<< HEAD
//<<<<<<< HEAD
const ClientState& st = remotePlayer;
// Позиция корабля в мире
Vector3f shipWorld = st.position;
@@ -1391,8 +1406,17 @@ namespace ZL
#endif
}
render();
if (networkClient) {
#ifndef NETWORK
auto localClient = dynamic_cast<ZL::LocalClient*>(networkClient.get());
if (localClient) {
localClient->setLocalPlayerState(Environment::shipState);
}
#endif
networkClient->Poll();
}
mainThreadHandler.processMainThreadTasks();
networkClient->Poll();
if (networkClient) {
auto pending = networkClient->getPendingProjectiles();