mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-02 10:15:32 +00:00
Fixing refill times
This commit is contained in:
@@ -22,7 +22,7 @@ namespace BBM
|
||||
//! @brief The max number of bomb that this entity can have.
|
||||
unsigned int maxBombCount = 3;
|
||||
//! @brief The number of seconds of each refill. This variable is used to reset the nextBombRefill value.
|
||||
std::chrono::nanoseconds refillRate = 5000ns;
|
||||
std::chrono::nanoseconds refillRate = 5000ms;
|
||||
//! @brief The number of nanosecond before the next bomb refill.
|
||||
std::chrono::nanoseconds nextBombRefill = refillRate;
|
||||
|
||||
|
||||
@@ -36,18 +36,16 @@ namespace BBM
|
||||
auto &position = entity.getComponent<PositionComponent>();
|
||||
auto &controllable = entity.getComponent<ControllableComponent>();
|
||||
|
||||
if (controllable.bomb && holder.bombCount > 0) {
|
||||
holder.bombCount--;
|
||||
this->_spawnBomb(position.position);
|
||||
}
|
||||
if (holder.bombCount < holder.maxBombCount) {
|
||||
holder.nextBombRefill -= dtime;
|
||||
if (holder.nextBombRefill <= 0ns) {
|
||||
holder.nextBombRefill = holder.refillRate;
|
||||
holder.bombCount++;
|
||||
std::cout << "Count: " << holder.bombCount << std::endl;
|
||||
}
|
||||
}
|
||||
if (controllable.bomb && holder.bombCount > 0) {
|
||||
holder.bombCount--;
|
||||
std::cout << "Now" << std::endl;
|
||||
this->_spawnBomb(position.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user