/
nantonenko95
/
raylib-introduction
Обзор
Документация
Войти
/
nantonenko95
/
raylib-introduction
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/vec2.cpp
97 строк
2 KB
Nikita
Player is bounded to game zone
10 ноя 2024, 13:08
10 ноя 2024, 13:08
ad6a75b
Код
Авторство
О чём код?
#include "vec2.h" #include "raymath.h" Vec2 Vec2::operator-() const { return Vec2(-x, -y); } Vec2 Vec2::operator+() const { return Vec2(x, y); } Vec2 Vec2::normalize() const { return Vec2(Vector2Normalize(toVector2())); } float Vec2::length() const { return Vector2Length(toVector2()); } float Vec2::distanceTo(const Vec2 &other) { return Vector2Distance(toVector2(), other.toVector2()); } float Vec2::angle() const { return Vector2Angle(toVector2(), {1, 0}); } float Vec2::angle(const Vec2 &other) const { return Vector2Angle(toVector2(), other.toVector2()); } Vec2 Vec2::rotate(float angleRads) const { return Vec2(Vector2Rotate(toVector2(), angleRads)); } std::string Vec2::toString() const { return "(" + std::to_string(x) + "," + std::to_string(y) + ")"; } Vec2 Vec2::clamp(const Vec2 &min, const Vec2 &max) const { return Vec2(Vector2Clamp(toVector2(), min.toVector2(), max.toVector2())); } Vec2 &operator+=(Vec2 &a, const Vec2 &b) { a.x += b.x; a.y += b.y; return a; } Vec2 &operator+=(Vec2 &a, float b) { a.x += b; a.y += b; return a; } Vec2 &operator-=(Vec2 &a, const Vec2 &b) { a.x -= b.x; a.y -= b.y; return a; } Vec2 &operator-=(Vec2 &a, float b) { a.x -= b; a.y -= b; return a; } Vec2 &operator*=(Vec2 &a, const Vec2 &b) { a.x *= b.x; a.y *= b.y; return a; } Vec2 &operator*=(Vec2 &a, float b) { a.x *= b; a.y *= b; return a; } Vec2 &operator/=(Vec2 &a, const Vec2 &b) { a.x /= b.x; a.y /= b.y; return a; } Vec2 &operator/=(Vec2 &a, float b) { a.x /= b; a.y /= b; return a; } Vec2 operator+(const Vec2 &a, const Vec2 &b) { return Vec2(a.x + b.x, a.y + b.y); } Vec2 operator+(const Vec2 &a, float b) { return Vec2(a.x + b, a.y + b); } Vec2 operator-(const Vec2 &a, const Vec2 &b) { return Vec2(a.x - b.x, a.y - b.y); } Vec2 operator-(const Vec2 &a, float b) { return Vec2(a.x - b, a.y - b); } Vec2 operator*(const Vec2 &a, const Vec2 &b) { return Vec2(a.x * b.x, a.y * b.y); } Vec2 operator*(const Vec2 &a, float b) { return Vec2(a.x * b, a.y * b); } Vec2 operator/(const Vec2 &a, const Vec2 &b) { return Vec2(a.x / b.x, a.y / b.y); } Vec2 operator/(const Vec2 &a, float b) { return Vec2(a.x / b, a.y / b); }