Skip to content

Commit

Permalink
health bar fix and algorithm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Urogna committed May 16, 2019
1 parent bc9018b commit dc7403a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Classes/Algorithm/GameAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int GameAlgorithm::nextVarroa(float bees, int varroa) {
_varroaCounter = 0;
float ratio = bees/MAX_BEES;

return varroa * ratio + 1;
return varroa * ratio;
} else {return 0;}
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Algorithm/GameAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define HONEY_PER_BEE 0.0025;
#define FOOD_EATEN_PER_BEE 0.00125;
#define BEES_PER_UPDATE 186;
#define BEES_PER_UPDATE 215;
#define BEES_DEAD_PER_UPDATE 21;
#define VARROA_KILL_RATE 0.25f;

Expand Down
15 changes: 6 additions & 9 deletions Classes/Game/BeeHive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void BeeHive::fromJSON(rapidjson::Document &doc) {
}

void BeeHive::varroaRandomizer() {
if(random(0, 10000) < 10 + 10 * (_beesAlive/MAX_BEES)) {
_varroaAlive = (int) random(1, 10);
if(random(0, 10000) < 20 * (_beesAlive/MAX_BEES)) {
_varroaAlive = (int) random(2, 10);

//Tutorial
auto storyScene = StoryScene::getInstance();
Expand Down Expand Up @@ -202,17 +202,15 @@ void BeeHive::setHealthIndicators() {
initHealthBar();
firstLoad = false;
}

if (_currentHealth != currentHealth()) {
_currentHealth = currentHealth();
switch (_currentHealth){
case (Healthy):
_healthImage->setColor(Color3B::GREEN);
_healthImage->setPercent(100.0f);
break;
case (Average):
_healthImage->setColor(Color3B::YELLOW);
_healthImage->setPercent(70.0f);
_healthImage->setColor(Color3B::YELLOW);
break;

case (Unhealthy):
Expand All @@ -228,8 +226,7 @@ void BeeHive::setHealthIndicators() {
_healthImage->setColor(Color3B::GREEN);
_healthImage->setPercent(100.0f);
}

}

}

void BeeHive::initHealthBar() {
Expand All @@ -238,7 +235,7 @@ void BeeHive::initHealthBar() {


// instantiate with "healthy" state image
_healthImage = ui::LoadingBar::create("indicators/greenSquare_long.png");
_healthImage = ui::LoadingBar::create("indicators/white_bar.png");
_healthImage->setPercent(100.0f);

_healthImage->setScale(0.08f);
Expand Down Expand Up @@ -277,7 +274,7 @@ bool BeeHive::isDead() {

void BeeHive::revive() {
if (Wallet::getInstance()->subtractMoney(300)) {
this->_beesAlive = 15000;
this->_beesAlive = 20000;
this->_varroaAlive = 0;
this->_food = 0;
this->_rawHoney = 0;
Expand Down
Binary file added Resources/indicators/white_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dc7403a

Please sign in to comment.