Skip to content

Commit

Permalink
Remove some magic numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 11, 2024
1 parent fef8370 commit 385074d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ void Status::update(TankStats newStats, const Display& display)
void Status::draw(const Display& display) const
{
const int spacer{getHeight() / 5};
display.drawTextWithBackground(getCenter().x_, spacer * 1,
int verticalPosition{spacer};
display.drawTextWithBackground(getCenter().x_, verticalPosition,
"Lives: " + std::to_string(stats_.lives_));
display.drawTextWithBackground(getCenter().x_, spacer * 2,
verticalPosition += spacer;
display.drawTextWithBackground(getCenter().x_, verticalPosition,
"Shield: " + std::to_string(stats_.shield_));
display.drawTextWithBackground(getCenter().x_, spacer * 3,
verticalPosition += spacer;
display.drawTextWithBackground(getCenter().x_, verticalPosition,
"Speed: " + std::to_string(stats_.speed_));
verticalPosition += spacer;
display.drawTextWithBackground(
getCenter().x_, spacer * 4,
getCenter().x_, verticalPosition,
"Attack: " + std::to_string(stats_.attackPower_));
}

Expand Down
5 changes: 3 additions & 2 deletions src/Tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ TankStats Tank::getStats() const { return stats_; }
Bullet Tank::fire(TimePoint currentTime)
{
lastFire_ = currentTime;
return {getCenter(), stats_.speed_ + 2, isPlayerControlled(),
stats_.attackPower_, getDirection()};
const int bulletSpeedIncrease{2};
return {getCenter(), stats_.speed_ + bulletSpeedIncrease,
isPlayerControlled(), stats_.attackPower_, getDirection()};
}

std::pair<int, int> Tank::getNextExpectedPosition() const
Expand Down

0 comments on commit 385074d

Please sign in to comment.