some fix
This commit is contained in:
1 parent
204b79bf06
commit
88f68b20ea
4 files changed
+63
-16
No files matched your search
+42
-5
@@ -236,6 +236,7 @@ namespace ZL
|
||||
uint64_t now = SDL_GetTicks64();
|
||||
if (now - lastProjectileFireTime >= static_cast<uint64_t>(projectileCooldownMs)) {
|
||||
lastProjectileFireTime = now;
|
||||
const float projectileSpeed = 60.0f;
|
||||
|
||||
this->fireProjectiles();
|
||||
|
||||
@@ -245,15 +246,21 @@ namespace ZL
|
||||
Eigen::Vector3f centerPos = Environment::shipState.position +
|
||||
Environment::shipState.rotation * Vector3f{ 0, 0.9f, 5.0f };
|
||||
|
||||
Eigen::Quaternionf q(Environment::shipState.rotation);
|
||||
float speedToSend = projectileSpeed + Environment::shipState.velocity;
|
||||
int shotCount = 2;
|
||||
|
||||
std::string fireMsg = "FIRE:" +
|
||||
std::to_string(now) + ":" +
|
||||
std::to_string(centerPos.x()) + ":" +
|
||||
std::to_string(centerPos.y()) + ":" +
|
||||
std::to_string(centerPos.z()) + ":" +
|
||||
std::to_string(worldForward.x()) + ":" +
|
||||
std::to_string(worldForward.y()) + ":" +
|
||||
std::to_string(worldForward.z()) + ":" +
|
||||
"2";
|
||||
std::to_string(q.w()) + ":" +
|
||||
std::to_string(q.x()) + ":" +
|
||||
std::to_string(q.y()) + ":" +
|
||||
std::to_string(q.z()) + ":" +
|
||||
std::to_string(speedToSend) + ":" +
|
||||
std::to_string(shotCount);
|
||||
|
||||
networkClient->Send(fireMsg);
|
||||
}
|
||||
@@ -1149,7 +1156,37 @@ namespace ZL
|
||||
const float projectileSpeed = 60.0f;
|
||||
const float lifeMs = 5000.0f;
|
||||
const float size = 0.5f;
|
||||
for (const auto& pi : pending) {
|
||||
const std::vector<Vector3f> localOffsets = {
|
||||
Vector3f{ -1.5f, 0.9f, 5.0f },
|
||||
Vector3f{ 1.5f, 0.9f, 5.0f }
|
||||
//Vector3f{},
|
||||
//Vector3f{}
|
||||
};
|
||||
|
||||
Vector3f localForward = { 0, 0, -1 };
|
||||
Vector3f worldForward = pi.rotation * localForward;
|
||||
|
||||
float len = worldForward.norm();
|
||||
if (len <= 1e-6f) {
|
||||
continue;
|
||||
}
|
||||
worldForward /= len;
|
||||
|
||||
Vector3f baseVel = worldForward * pi.velocity;
|
||||
|
||||
for (const auto& off : localOffsets) {
|
||||
Vector3f shotPos = pi.position + (pi.rotation * off);
|
||||
|
||||
for (auto& p : projectiles) {
|
||||
if (!p->isActive()) {
|
||||
p->init(shotPos, baseVel, lifeMs, size, projectileTexture, renderer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
auto remotePlayersSnapshot = networkClient->getRemotePlayers();
|
||||
for (const auto& pi : pending) {
|
||||
Eigen::Vector3f dir = pi.direction;
|
||||
@@ -1190,7 +1227,7 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user