Guest User

Untitled

a guest
Apr 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. bool GridFull = false;
  2. vec2set = false;
  3. if (RectangleTool == true && LeftMouseDown && Layer == 1)
  4. {
  5. _ctrl = true;
  6. /******************* Sets the first point of the Tile Fill Rectangle *******************/
  7. for(GridRowVector::size_type i = 0; i < RowVector.size(); i ++)
  8. {
  9. for(GridColumnVector::size_type j = 0; j < ColumnVector.size(); j++)
  10. {
  11. if (MousePos.x >= ColumnVector[j]->getPoint().x &&
  12. MousePos.x <= ColumnVector[j]->getPoint().x + 32 &&
  13. MousePos.y >= RowVector[i]->getPoint().y &&
  14. MousePos.y <= RowVector[i]->getPoint().y + 32 &&
  15. SettingSquare == false)
  16. {
  17. DrawVec1 = sf::Vector2f(ColumnVector[j]->getPoint().x,RowVector[i]->getPoint().y);
  18. cout << " VEC1 SET" << endl;
  19. vec1set = true;
  20. SettingSquare = true;
  21. }
  22.  
  23. }
  24. }
  25. }
  26. /********************* Sets the second point of the Tile Fill rectangle ******************/
  27. if (vec1set = true && RectangleTool == true && LeftMouseDown) /*Event.Type == sf::Event::MouseButtonReleased) && LeftMouseDown*/ /*(Event.MouseButton.Button == sf::Mouse::Left)*/
  28. {
  29. for(GridRowVector::size_type i = 0; i < RowVector.size(); i ++)
  30. {
  31. for(GridColumnVector::size_type j = 0; j < ColumnVector.size(); j++)
  32. {
  33. if (MousePos.x >= ColumnVector[j]->getPoint().x &&
  34. MousePos.x <= ColumnVector[j]->getPoint().x + 32 &&
  35. MousePos.y >= RowVector[i]->getPoint().y &&
  36. MousePos.y <= RowVector[i]->getPoint().y + 32 )
  37. {
  38. DrawVec2 = sf::Vector2f(ColumnVector[j]->getPoint().x,RowVector[i]->getPoint().y);
  39. cout << " VEC2 SET" << endl;
  40. vec2set = true;
  41. Rect = sf::Shape::Rectangle(DrawVec1,DrawVec2,sf::Color(188,143,143,70), 3.0f,sf::Color(188,143,143,255) );
  42. }
  43. }
  44. }
  45.  
  46. if (vec1set == true && vec2set == true)
  47. {
  48.  
  49. for(GridRowVector::size_type i = 0; i < RowVector.size(); i ++)
  50. {
  51. for(GridColumnVector::size_type j = 0; j < ColumnVector.size(); j++)
  52. {
  53. if (ColumnVector[j]->getPoint().x >= DrawVec1.x &&
  54. ColumnVector[j]->getPoint().x+32 <= DrawVec2.x &&
  55. RowVector[i]->getPoint().y >= DrawVec1.y &&
  56. RowVector[i]->getPoint().y+32 <= DrawVec2.y)
  57. {
  58. sf::Vector2f FillVector = sf::Vector2f(ColumnVector[j]->getPoint().x,RowVector[i]->getPoint().y);
  59. for (SpriteVector::size_type k = 0; k < mSprites.size(); k++)
  60. {
  61. if ( fabs(ColumnVector[j]->getPoint().x - mSprites[k]->getTile().GetPosition().x) < 0.0001 && fabs(RowVector[i]->getPoint().y - mSprites[k]->getTile().GetPosition().y) < 0.0001)
  62. {
  63. GridFull = true;
  64. }
  65.  
  66. if (GridFull == false)
  67. {
  68. mSprites.push_back(new Tile(mMouse.getTile(),mMouse.getId(),FillVector, Layer));
  69. /*cout << "square drawn" << endl;*/
  70. }
  71. }
  72. }
  73. vec1set = false;
  74. vec2set = false;
  75. }
  76. SettingSquare = false;
  77.  
  78. }
  79. }
  80. }
Add Comment
Please, Sign In to add comment