Skip to content

Commit

Permalink
*: Begin of debug fantom bullets
Browse files Browse the repository at this point in the history
PATCH
  • Loading branch information
romainpanno committed Nov 5, 2023
1 parent aadce62 commit 4383f6c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Client/Systems/Menus/Menu/MenuSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace Systems {
return;
}
try {
Parallax::initParalax();
// Parallax::initParalax();
preloadTexture();
initHud();
} catch (std::runtime_error &err) {
Expand Down
6 changes: 5 additions & 1 deletion src/Game/CreateMissiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ namespace Systems {
#ifdef CLIENT
static void addSpriteRectsForBullet(nlohmann::json &bulletData, Types::CollisionRect &collisionRect)
{
Logger::fatal("cacaaaaaaaaaaaaaaaaaaa------------------------------------------");
Json &json = Json::getInstance();
const std::string bulletPath = json.getDataFromJson<std::string>(bulletData, "spritePath");
Types::Rect spriteRect = json.getDataFromJson<Types::Rect>(bulletData, "spriteRect");
Types::SpriteDatas
bulletDatas(bulletPath, collisionRect.width, collisionRect.height, DEFAULTLAYER, 0);
bulletDatas(bulletPath, collisionRect.width, collisionRect.height, FRONTLAYER, 0);
Registry::getInstance().getComponents<Types::SpriteDatas>().insertBack(bulletDatas);
Registry::getInstance().getComponents<Types::Rect>().insertBack(spriteRect);

Expand All @@ -99,9 +100,11 @@ namespace Systems {

std::size_t createPlayerMissile(Types::Position pos, Types::Missiles &typeOfMissile)
{
Logger::fatal("Create missile");
if (typeOfMissile.type >= MAX_MISSILE_TYPE || typeOfMissile.type < 0) {
throw std::runtime_error("Unknown missile type");
}
Logger::fatal("Create missile2");
Json &json = Json::getInstance();
std::size_t id = Registry::getInstance().addEntity();
nlohmann::json bulletData =
Expand All @@ -122,6 +125,7 @@ namespace Systems {

Registry::getInstance().getComponents<Types::PlayerAllies>().insertBack(playerAlliesComp);
addPhysicsToEntity(bulletData, pos);
Logger::fatal("type of missile = " + std::to_string(typeOfMissile.type) + " pos = " + std::to_string(pos.x) + " " + std::to_string(pos.y));
Registry::getInstance().getComponents<Types::Position>().insertBack(pos);
Registry::getInstance().getComponents<Types::CollisionRect>().insertBack(collisionRect);
Registry::getInstance().getComponents<Types::Missiles>().insertBack(missileType);
Expand Down
6 changes: 3 additions & 3 deletions src/Nitwork/MessageTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ enum enemy_type_e {

enum missileTypes_e {
CLASSIC = 0,
FAST,
BOUNCE,
PERFORANT,
FAST = 1,
BOUNCE = 2,
PERFORANT = 3,
MAX_MISSILE_TYPE
};

Expand Down
2 changes: 0 additions & 2 deletions src/Nitwork/NitworkServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ namespace Nitwork {
void
NitworkServer::handleReadyMsg(const std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint)
{
Logger::fatal("cacaprout");
if (_isGameStarted) {
Logger::info("Game already started, connection refused");
return;
Expand All @@ -267,7 +266,6 @@ namespace Nitwork {
auto &director = Systems::SystemManagersDirector::getInstance();
std::lock_guard<std::mutex> lock(director.mutex);
director.getSystemManager(static_cast<std::size_t>(SystemManagers::GAME_LOGIC)).addSystem(Systems::waveHandler); // le sheeiiiiiitan VERIF
Logger::fatal("cacaprout");
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Systems/Network/ServerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace Systems {
Maths::addIntDecimals(msgNewBullet.pos.x),
Maths::addIntDecimals(msgNewBullet.pos.y),
};
struct Types::Missiles missileType = {static_cast<missileTypes_e>(msgNewBullet.missileType)};
struct Types::Missiles missileType = {msgNewBullet.missileType};
auto id = Systems::createPlayerMissile(position, missileType);
if (!arrMissiles.exist(id) || !arrHealth.exist(id)) {
Logger::error("Error: missile not created");
Expand Down

0 comments on commit 4383f6c

Please sign in to comment.