Skip to content

Commit

Permalink
Multiplayer explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
sebimih13 committed Jan 30, 2025
1 parent 92d84a5 commit 3835a21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions DeadZone/source/Client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,13 @@ void Client::sendBullet(const std::shared_ptr<Bullet>& const entity)
}

nlohmann::json jsonData;

jsonData["bullet"]["isThrownGrenade"] = isThrownGrenade;
jsonData["bullet"]["x"] = entity->getX();
jsonData["bullet"]["y"] = entity->getY();
jsonData["bullet"]["rotateAngle"] = entity->getRotateAngle();
jsonData["bullet"]["speed"] = entity->getSpeed();
jsonData["bullet"]["textureName2D"] = entity->getTextureName2D();
jsonData["bullet"]["damage"] = entity->getDamage();
jsonData["bullet"]["textureName2D"] = entity->getTextureName2D();
jsonData["bullet"]["damage"] = isThrownGrenade ? std::dynamic_pointer_cast<ThrownGrenade>(entity)->getExplosionDamage() : entity->getDamage();

// TODO: trimite si ceilalti parametrii daca vrem sa avem mai multi modificatori

Expand Down
3 changes: 3 additions & 0 deletions DeadZone/source/Entity/Bullet/ThrownGrenade.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ class ThrownGrenade : public virtual Bullet
virtual void update() override;

virtual void onCollide(CollidableEntity& other, glm::vec2 overlap) override;

// Getters
double getExplosionDamage() const { return explosionDamage; }
};
2 changes: 1 addition & 1 deletion DeadZone/source/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void Server::update()
jsonData["bullets"][otherConnectedClient.first]["rotateAngle"] = otherConnectedClient.second.bulletData.get()->getRotateAngle();
jsonData["bullets"][otherConnectedClient.first]["speed"] = otherConnectedClient.second.bulletData.get()->getSpeed();
jsonData["bullets"][otherConnectedClient.first]["textureName2D"] = otherConnectedClient.second.bulletData.get()->getTextureName2D();
jsonData["bullets"][otherConnectedClient.first]["damage"] = otherConnectedClient.second.bulletData.get()->getDamage();
jsonData["bullets"][otherConnectedClient.first]["damage"] = std::dynamic_pointer_cast<ThrownGrenade>(otherConnectedClient.second.bulletData)->getExplosionDamage();
}

// closeRangeDamage
Expand Down

0 comments on commit 3835a21

Please sign in to comment.