Vector2.cs 715 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. using System;
  6. namespace Crown
  7. {
  8. public struct Vector2
  9. {
  10. public Vector2(float x, float y)
  11. {
  12. this.x = x;
  13. this.y = y;
  14. }
  15. public static Vector2 operator+(Vector2 a, Vector2 b)
  16. {
  17. return new Vector2(a.x + b.x, a.y + b.y);
  18. }
  19. public static Vector2 operator-(Vector2 a, Vector2 b)
  20. {
  21. return new Vector2(a.x - b.x, a.y - b.y);
  22. }
  23. public static Vector2 operator*(Vector2 a, float k)
  24. {
  25. return new Vector2(a.x * k, a.y * k);
  26. }
  27. public static Vector2 operator*(float k, Vector2 a)
  28. {
  29. return a * k;
  30. }
  31. public float x, y;
  32. }
  33. }