Guest User

Untitled

a guest
Jul 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. //Just visuals
  2. //None collider or selectable behaviour
  3.  
  4. class FolderSelection : Entity
  5. {
  6. float orX; //Origin of the rectangle in X
  7. float orY; //Origin of the rectangle in Y
  8. int width = 0; //width of the rectangle
  9. int height = 0; //height of the rectangle
  10. Color rectColor; //Color to fill
  11. Color outColor; //outline color
  12.  
  13. public FolderSelection()
  14. {
  15. }
  16.  
  17. public override void Update()
  18. {
  19. base.Update();
  20.  
  21. //Define origin according to mouse position when click
  22. if (Input.MouseButtonPressed(0))
  23. {
  24. orX = Input.MouseX;
  25. orY = Input.MouseY;
  26. width = 0;
  27. height = 0;
  28. }
  29.  
  30. //Define width and height
  31. if (Input.MouseButtonDown(0))
  32. {
  33. width = (int)(Input.MouseX - orX);
  34. height = (int)(Input.MouseY - orY);
  35. }
  36.  
  37. //Color and alpha to fill the rectangle
  38. rectColor = Color.Blue;
  39. rectColor.A = 0.1f;
  40.  
  41. //Color and alpha to fill the outline
  42. outColor = Color.Blue;
  43. outColor.A = 0.2f;
  44. }
  45.  
  46. public override void Render()
  47. {
  48. base.Render();
  49. //Render the rectangle when mouse button is down
  50. if (Input.MouseButtonDown(0))
  51. Draw.Rectangle(orX, orY, width, height, rectColor, outColor, 2);
  52. }
  53. }
Add Comment
Please, Sign In to add comment