Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. void CEquilateralTriangle::Tick()
  2. {
  3.     mBoundingRect.left += RandRange(-5,5);
  4.     mBoundingRect.top += RandRange(-5,5);
  5.     mBoundingRect.right += RandRange(-5,5);
  6.     mBoundingRect.bottom += RandRange(-5,5);
  7.     CorrectRect(&mBoundingRect);
  8.     int width = mBoundingRect.right - mBoundingRect.left;
  9.     int height = mBoundingRect.bottom - mBoundingRect.top;
  10.     if(width > height) {
  11.         mBoundingRect.top = mBoundingRect.bottom - ((width * sqrt(3.0)) / 2);
  12.     }
  13.     if(height > width) {
  14.         width = (2 * height) / sqrt(3.0);
  15.         mBoundingRect.left = mBoundingRect.right - width;
  16.         mBoundingRect.right = mBoundingRect.left + width;
  17.     }
  18.     updateVertices();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement