0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 12:33:43 +00:00
SDL_Minigame/src/Vector2D.cpp

53 lines
868 B
C++

#include "Vector2D.h"
Vector2D::Vector2D()
{
this->x = 0.0f;
this->y = 0.0f;
}
Vector2D::Vector2D(float x, float y)
{
this->x = x;
this->y = y;
}
Vector2D& operator+(Vector2D& vector1, const Vector2D& vector2)
{
vector1.x += vector2.x;
vector1.y += vector2.y;
return vector1;
}
Vector2D& operator-(Vector2D& vector1, const Vector2D& vector2)
{
vector1.x -= vector2.x;
vector1.y -= vector2.y;
return vector1;
}
Vector2D& operator*(Vector2D& vector1, const Vector2D& vector2)
{
vector1.x *= vector2.x;
vector1.y *= vector2.y;
return vector1;
}
Vector2D& operator/(Vector2D& vector1, const Vector2D& vector2)
{
vector1.x /= vector2.x;
vector1.y /= vector2.y;
return vector1;
}
Vector2D& Vector2D::operator*(const int& i)
{
this->x *= i;
this->y *= i;
return *this;
}
Vector2D& Vector2D::zero()
{
this->x = 0.0f;
this->y = 0.0f;
return *this;
}