A small game engine for 2D games based of Raylib
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
766 B

  1. #pragma once
  2. #include <cmath>
  3. #include <numbers>
  4. namespace ant::core {
  5. template<typename T = float>
  6. struct Vec2 {
  7. T X;
  8. T Y;
  9. };
  10. template<typename T>
  11. auto operator+(const Vec2<T>& lhs, const Vec2<T>& rhs) -> Vec2<T>{
  12. return {.X = lhs.X + rhs.X, .Y = lhs.Y + rhs.Y};
  13. }
  14. template<typename T>
  15. auto operator*(const Vec2<T>& lhs, const Vec2<T>& rhs) -> Vec2<T>{
  16. return {.X = lhs.X * rhs.X, .Y = lhs.Y * rhs.Y};
  17. }
  18. template<typename T = float>
  19. struct transform {
  20. Vec2<T> position;
  21. float angle;
  22. };
  23. template<typename T>
  24. auto operator+(const transform<T>& lhs, const transform<T>& rhs) -> transform<T>{
  25. return {.position = lhs.position + rhs.position, .angle = std::fmod<float>(lhs.angle + rhs.angle, 180.0f)};
  26. }
  27. }