Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Unit::move()
- {
- if (moving)
- {
- if (position.x < destination.x)
- {
- position.x = std::min(position.x + velocity*cos(angle), destination.x);
- cout << velocity << endl;
- }
- else if (position.x > destination.x)
- {
- position.x = std::max(position.x + velocity*cos(angle), destination.x);
- }
- if (position.y < destination.y)
- {
- position.y = std::min(position.y - velocity*sin(angle), destination.y);
- }
- else if (position.y > destination.y)
- {
- position.y = std::max(position.y - velocity*sin(angle), destination.y);
- }
- if (position == destination)
- moving = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement