mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-29 17:02:11 +00:00
change player speed
This commit is contained in:
@@ -15,11 +15,6 @@ namespace BBM
|
||||
class PlayerBonusComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
|
||||
//! @brief The number of seconds before a speed bonus expire. This variable is used to reset the nextSpeedBonusRate value.
|
||||
std::chrono::nanoseconds speedBonusRate = 15s;
|
||||
//! @brief The number of nanosecond before the expiration of a speed bonus.
|
||||
std::chrono::nanoseconds nextSpeedBonusRate = speedBonusRate;
|
||||
//! @brief The number of seconds before a range bonus expire. This variable is used to reset the nextNoClipBonusRate value.
|
||||
std::chrono::nanoseconds noClipBonusRate = 5s;
|
||||
//! @brief The number of nanosecond before the expiration of a no clip bonus
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BBM
|
||||
//! @brief input value for pause
|
||||
bool pause = false;
|
||||
//! @brief The speed applied to every controllable entities.
|
||||
float speed = .25f;
|
||||
float speed = .15f;
|
||||
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace BBM {
|
||||
if (!bombHolder)
|
||||
return;
|
||||
bombHolder->maxBombCount++;
|
||||
std::cout << "BombHolder : " << bombHolder->maxBombCount << std::endl;
|
||||
}
|
||||
|
||||
void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
@@ -29,6 +30,7 @@ namespace BBM {
|
||||
if (!bombHolder || !playerBonus)
|
||||
return;
|
||||
bombHolder->explosionRadius++;
|
||||
std::cout << "BombRadius : " << bombHolder->explosionRadius << std::endl;
|
||||
}
|
||||
|
||||
void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
@@ -39,8 +41,8 @@ namespace BBM {
|
||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||
if (!controllable || !playerBonus)
|
||||
return;
|
||||
controllable->speed = 0.35f;
|
||||
playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate;
|
||||
controllable->speed += 0.05f;
|
||||
std::cout << "Speed : " << controllable->speed << std::endl;
|
||||
}
|
||||
|
||||
void Bonus::NoClipBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
@@ -50,7 +52,7 @@ namespace BBM {
|
||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||
if (!playerBonus)
|
||||
return;
|
||||
playerBonus->nextNoClipRate = playerBonus->nextSpeedBonusRate;
|
||||
playerBonus->nextNoClipRate = playerBonus->noClipBonusRate;
|
||||
playerBonus->isNoClipOn = true;
|
||||
}
|
||||
|
||||
@@ -58,7 +60,8 @@ namespace BBM {
|
||||
{
|
||||
double rnd = static_cast<double>(std::rand()) / RAND_MAX;
|
||||
|
||||
if (rnd <= 0.8)
|
||||
std::cout << "Random" << rnd << std::endl;
|
||||
if (rnd <= 1)
|
||||
return (static_cast<BonusType>((std::rand() % NOCLIP) + 1));
|
||||
return (NOTHING);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@ namespace BBM
|
||||
auto &holder = entity.get<BombHolderComponent>();
|
||||
auto &playerBonus = entity.get<PlayerBonusComponent>();
|
||||
|
||||
playerBonus.nextSpeedBonusRate -= dtime;
|
||||
if (playerBonus.nextSpeedBonusRate <= 0ns) {
|
||||
playerBonus.nextSpeedBonusRate = playerBonus.speedBonusRate;
|
||||
controllable.speed = 0.25f;
|
||||
}
|
||||
playerBonus.nextNoClipRate -= dtime;
|
||||
if (playerBonus.nextNoClipRate <= 0ns) {
|
||||
playerBonus.nextNoClipRate = playerBonus.noClipBonusRate;
|
||||
|
||||
Reference in New Issue
Block a user