Advertisement
Orrexon

Tank::update()

Apr 6th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. void Tank::Update()
  2. {
  3.     if (currentPathIndex > 0 && currentPathIndex == path.size())
  4.     {
  5.         path.clear();
  6.         currentPathIndex = 0;
  7.         searching = false;
  8.     }
  9.     if (path.size() > 0)
  10.     {
  11.         sf::Vector2i direction;
  12.         sf::Vector2f dirNorm;
  13.         direction = (sf::Vector2i)path[currentPathIndex].GetPosition() - (sf::Vector2i)position;
  14.         dirNorm = normalize((sf::Vector2f)direction);
  15.         if (direction == sf::Vector2i(0,0))
  16.         {
  17.             currentPathIndex++;
  18.         }
  19.         move((sf::Vector2f)dirNorm);
  20.     }
  21.    
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement