Skip to content
Open

Dev #10

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion GUI/src/Renderer/Raylib/Map/MapRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,28 @@ void zappy::gui::raylib::MapRenderer::removePlayer(const int &id)
for (auto it = this->_players.begin(); it != this->_players.end(); it++) {
if ((*it)->getId() == id) {
this->_players.erase(it);
this->_playerActionQueues.erase(id);
this->removeAllActions(id);
break;
}
}
}

void zappy::gui::raylib::MapRenderer::removeAllActions(const int &id)
{
this->_playerActionQueues.erase(id);

this->_playerAnimAction.erase(
std::remove_if(
this->_playerAnimAction.begin(),
this->_playerAnimAction.end(),
[id](const std::shared_ptr<APlayerAnimAction> &action) {
return action->getPlayerId() == id;
}
),
this->_playerAnimAction.end()
);
}

/**
* @brief Supprime toutes les actions de translation pour un joueur donné.
* @param id Identifiant du joueur.
Expand Down
1 change: 1 addition & 0 deletions GUI/src/Renderer/Raylib/Map/MapRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace zappy {
void removePlayer(const int &id);
void removeEgg(const int &id);

void removeAllActions(const int &id);
void removeAllTranslations(const int &id);
void removeAllRotations(const int &id);

Expand Down
9 changes: 3 additions & 6 deletions GUI/src/Renderer/Raylib/Menu/GameMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,10 @@ void zappy::gui::raylib::GameMenu::removePlayer(const int &id)
}
}

if (this->_displayedPlayersIndex >= static_cast<int>(_playersIds.size()))
this->_displayedPlayersIndex = this->_displayedPlayersIndex % static_cast<int>(_playersIds.size());

if (this->_playersIds.empty()) {
this->_displayedPlayersIndex = -1;
this->_numberPlayerDisplayed = 0;
}
} else if (this->_displayedPlayersIndex > static_cast<int>(_playersIds.size()))
this->_displayedPlayersIndex = this->_displayedPlayersIndex % static_cast<int>(_playersIds.size());
}

std::string zappy::gui::raylib::GameMenu::_decryptBroadcast(
Expand Down Expand Up @@ -346,7 +343,7 @@ void zappy::gui::raylib::GameMenu::_renderPlayersInfos(const int &screenWidth, c
const int x = screenWidth - paddingX;
const int y = paddingY;

if (this->_numberPlayerDisplayed <= 0) {
if (this->_numberPlayerDisplayed <= 0 || this->_displayedPlayersIndex < 0) {
const std::string text = "There is actually no player";
const int textWidth = MeasureText(text.c_str(), textSize);
DrawText(text.c_str(), x - textWidth, y, textSize, WHITE);
Expand Down
12 changes: 9 additions & 3 deletions GUI/src/Renderer/Raylib/Model/APlayerModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,20 @@ void zappy::gui::raylib::APlayerModel::update(const float &deltaUnits)
if (this->_modelAnimations == nullptr || this->_animsCount == 0)
return;

ModelAnimation anim = this->_modelAnimations[this->_animationIndexMap[this->_state]];
float speed = (this->_animationFrameSpeedMap[this->_state]);
int currentAnimIndex = this->_animationIndexMap[this->_state];

this->_frameAccumulator += deltaUnits * speed;
if (currentAnimIndex < 0 || currentAnimIndex >= this->_animsCount)
return;

ModelAnimation anim = this->_modelAnimations[currentAnimIndex];

if (anim.frameCount <= 0)
return;

float speed = this->_animationFrameSpeedMap[this->_state];

this->_frameAccumulator += deltaUnits * speed;

if (this->_frameAccumulator >= 1.0f) {
const int frameAdvance = static_cast<int>(this->_frameAccumulator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace zappy {
float _pulseTimer;

constexpr static float PULSE_INTERVAL = 2.0f;
constexpr static float PULSE_SPEED = 3.0f;
constexpr static float PULSE_LIFETIME = 3.0f;
constexpr static float PULSE_SPEED = 1.0f;
constexpr static float PULSE_LIFETIME = 9.0f;
};
} // namespace raylib
} // namespace gui
Expand Down