Skip to content

Commit

Permalink
Small improvements in Game::moveEnemyTanks() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 7, 2024
1 parent 60fa6e3 commit c461b7b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ void Game::moveEnemyTanks()
{
if (!tank.isPlayerControlled())
{
Direction direction{Direction::UP};
const auto now{std::chrono::system_clock::now()};
if (tank.canFire(now))
if (const auto now{std::chrono::system_clock::now()};
tank.canFire(now))
bullets_.emplace_back(tank.fire(now));
const int randomDirection{distribution_(randomGenerator_)};

Direction direction{Direction::UP};
if (((tank.getX() % Config::getInstance().getTileSize()) == 0) &&
((tank.getY() % Config::getInstance().getTileSize()) == 0) &&
(randomDirection < 4))
Expand Down

0 comments on commit c461b7b

Please sign in to comment.