Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. void Unit::move()
  2. {
  3. if (moving)
  4. {
  5. if (position.x < destination.x)
  6. {
  7. position.x = std::min(position.x + velocity*cos(angle), destination.x);
  8. cout << velocity << endl;
  9. }
  10. else if (position.x > destination.x)
  11. {
  12. position.x = std::max(position.x + velocity*cos(angle), destination.x);
  13. }
  14. if (position.y < destination.y)
  15. {
  16. position.y = std::min(position.y - velocity*sin(angle), destination.y);
  17. }
  18. else if (position.y > destination.y)
  19. {
  20. position.y = std::max(position.y - velocity*sin(angle), destination.y);
  21. }
  22. if (position == destination)
  23. moving = false;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement