oooooooooo
This commit is contained in:
parent
f1bb7447f9
commit
25b5c1e492
@ -199,11 +199,11 @@ void Player::ApplyTransformation(Transformation& transformation, bool rel, bool
|
|||||||
void Player::TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedtime)
|
void Player::TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedtime)
|
||||||
{
|
{
|
||||||
Vector3f playerpos = GetPosition();
|
Vector3f playerpos = GetPosition();
|
||||||
for (auto& [key, booster]: booster_table)
|
for (auto& [key, booster]: booster_table) {
|
||||||
{
|
|
||||||
Vector3f pos = booster->GetPosition();
|
Vector3f pos = booster->GetPosition();
|
||||||
if (booster->GetAvailability() && abs(playerpos.x - pos.x) <= 0.5f && abs(playerpos.y - pos.y) <= 1.0f && abs(playerpos.z - pos.z) <= 0.5f)
|
if (booster->GetAvailability() && abs(playerpos.x - pos.x) <= 0.5f && abs(playerpos.y - pos.y) <= 1.0f && abs(playerpos.z - pos.z) <= 0.5f)
|
||||||
{
|
{
|
||||||
|
std::cout << "booster got" << std::endl;
|
||||||
GetBooster(booster->GetType(), elapsedtime);
|
GetBooster(booster->GetType(), elapsedtime);
|
||||||
booster->SetAvailability(false);
|
booster->SetAvailability(false);
|
||||||
break;
|
break;
|
||||||
|
@ -241,12 +241,12 @@ void Server::Run() {
|
|||||||
int max = 0;
|
int max = 0;
|
||||||
for (int64_t x = 0; x < m_boostcount; ++x) {
|
for (int64_t x = 0; x < m_boostcount; ++x) {
|
||||||
Vector3f pos = Vector3f(rand() % (WORLD_SIZE_X * CHUNK_SIZE_X) + .5f, rand() % CHUNK_SIZE_Y + .5f, rand() % (WORLD_SIZE_Y * CHUNK_SIZE_Z) + .5f);
|
Vector3f pos = Vector3f(rand() % (WORLD_SIZE_X * CHUNK_SIZE_X) + .5f, rand() % CHUNK_SIZE_Y + .5f, rand() % (WORLD_SIZE_Y * CHUNK_SIZE_Z) + .5f);
|
||||||
if (m_world->BlockAt(pos) == BTYPE_AIR) {
|
if (m_world->BlockAt(pos) == BTYPE_AIR && m_world->BlockAt(Vector3f(pos.x, pos.y - 2, pos.z)) != BTYPE_AIR) {
|
||||||
Booster* boost = new Booster(pos, (BOOST_TYPE)(rand() % BTYPE_BOOST_LAST), getUniqueId());
|
Booster* boost = new Booster(pos, (BOOST_TYPE)(rand() % BTYPE_BOOST_LAST), getUniqueId());
|
||||||
m_boosters[boost->GetId()] = boost;
|
m_boosters[boost->GetId()] = boost;
|
||||||
}
|
}
|
||||||
else --x;
|
else --x;
|
||||||
if (++max > 1000)
|
if (++max > 100000)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,6 +390,7 @@ void Server::Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int max = 0;
|
||||||
for (auto& [key, booster] : m_boosters) {
|
for (auto& [key, booster] : m_boosters) {
|
||||||
if (booster->modified) {
|
if (booster->modified) {
|
||||||
PickupMod pmod;
|
PickupMod pmod;
|
||||||
@ -414,6 +415,9 @@ void Server::Run() {
|
|||||||
booster->modified = false;
|
booster->modified = false;
|
||||||
for (auto& [key, conn] : m_conns)
|
for (auto& [key, conn] : m_conns)
|
||||||
sendPackTo<PickupMod>(m_sock_udp, &pmod, &m_buf, conn->getAddr());
|
sendPackTo<PickupMod>(m_sock_udp, &pmod, &m_buf, conn->getAddr());
|
||||||
|
max++;
|
||||||
|
if (max > 5)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1511,7 +1511,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (Deserialize(&pmod, pck, &bsize)) {
|
if (Deserialize(&pmod, pck, &bsize)) {
|
||||||
if (m_boosters.count(pmod.id)) {
|
if (m_boosters.count(pmod.id)) {
|
||||||
Booster* boost = m_boosters.at(pmod.id);
|
Booster* boost = m_boosters.at(pmod.id);
|
||||||
|
std::cout << "Ramassé booster selon serveur " << (pmod.boost.damage ? "damage" : "") << (pmod.boost.hp ? "heal" : "") << (pmod.boost.invincible ? "invincible" : "");
|
||||||
boost->SetAvailability(pmod.available);
|
boost->SetAvailability(pmod.available);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1522,6 +1522,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
btype = BOOST_TYPE::BTYPE_HEAL;
|
btype = BOOST_TYPE::BTYPE_HEAL;
|
||||||
else if (pmod.boost.invincible)
|
else if (pmod.boost.invincible)
|
||||||
btype = BOOST_TYPE::BTYPE_INVINCIBLE;
|
btype = BOOST_TYPE::BTYPE_INVINCIBLE;
|
||||||
|
else break;
|
||||||
|
|
||||||
Booster* boost = new Booster(pmod.pos, btype, pmod.id);
|
Booster* boost = new Booster(pmod.pos, btype, pmod.id);
|
||||||
|
|
||||||
@ -1556,6 +1557,10 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_player.boostdamage = boost.damage;
|
m_player.boostdamage = boost.damage;
|
||||||
m_player.boostinvincible = boost.invincible;
|
m_player.boostinvincible = boost.invincible;
|
||||||
|
|
||||||
|
if (diff.Length() > 10.) {
|
||||||
|
m_player.Move(-diff);
|
||||||
|
}
|
||||||
|
|
||||||
if (diff.Length() > 1.5) {
|
if (diff.Length() > 1.5) {
|
||||||
diff.Normalize();
|
diff.Normalize();
|
||||||
m_player.Move(-diff);
|
m_player.Move(-diff);
|
||||||
@ -1630,8 +1635,10 @@ void Engine::Render(float elapsedTime) {
|
|||||||
rt->Render(m_animeAtlas, m_shader01, all, elapsedTime, m_player);
|
rt->Render(m_animeAtlas, m_shader01, all, elapsedTime, m_player);
|
||||||
}
|
}
|
||||||
for (auto& [key, booster] : m_boosters) {
|
for (auto& [key, booster] : m_boosters) {
|
||||||
if (booster->GetAvailability())
|
if (booster->GetAvailability()) {
|
||||||
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, *booster);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
}
|
}
|
||||||
|
@ -244,14 +244,11 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster)
|
void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster* booster) {
|
||||||
{
|
|
||||||
if (booster.GetAvailability() == true)
|
|
||||||
{
|
|
||||||
float width = 1.f;
|
float width = 1.f;
|
||||||
float height = 1.f;
|
float height = 1.f;
|
||||||
|
|
||||||
Vector3f DiffCam = booster.GetPosition() - player.GetPosition();
|
Vector3f DiffCam = booster->GetPosition() - player.GetPosition();
|
||||||
Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
|
Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
|
||||||
|
|
||||||
Vector3f CrossA = DiffCam.Cross(UpCam);
|
Vector3f CrossA = DiffCam.Cross(UpCam);
|
||||||
@ -260,7 +257,7 @@ void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transfo
|
|||||||
CrossA.Normalize();
|
CrossA.Normalize();
|
||||||
CrossB.Normalize();
|
CrossB.Normalize();
|
||||||
|
|
||||||
Vector3f playerPosition = booster.GetPosition() + Vector3f(0.f, -.75f, 0.f);
|
Vector3f playerPosition = booster->GetPosition() + Vector3f(0.f, -.75f, 0.f);
|
||||||
|
|
||||||
Vector3f v2 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
|
Vector3f v2 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
|
||||||
Vector3f v1 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
|
Vector3f v1 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
|
||||||
@ -268,7 +265,7 @@ void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transfo
|
|||||||
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
|
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
BOOST_TYPE type = booster.GetType();
|
BOOST_TYPE type = booster->GetType();
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -312,11 +309,8 @@ void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transfo
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
shader.Disable();
|
shader.Disable();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
|
||||||
void RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster);
|
void RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster* booster);
|
||||||
|
|
||||||
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation world, Shader& shader, TextureAtlas& atlas) const;
|
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation world, Shader& shader, TextureAtlas& atlas) const;
|
||||||
void RenderPlayer(Player* player, Transformation tran) const;
|
void RenderPlayer(Player* player, Transformation tran) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user