58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
// prevent multiple inclusion
|
|
#pragma once
|
|
|
|
// class for 2D float vector
|
|
class float_vec2
|
|
{
|
|
// public members
|
|
public:
|
|
// x and y coordinates
|
|
float x, y;
|
|
// operator functions
|
|
float_vec2 operator+(float_vec2 vec)
|
|
{
|
|
return { x + vec.x, y + vec.y };
|
|
}
|
|
float_vec2 operator*(float v)
|
|
{
|
|
return { x * v, y * v };
|
|
}
|
|
float_vec2 operator*(float_vec2 vec)
|
|
{
|
|
return { x * vec.x, y * vec.y };
|
|
}
|
|
float_vec2 operator-(float_vec2 vec)
|
|
{
|
|
return { x - vec.x, y - vec.y };
|
|
}
|
|
float_vec2 operator-(float v)
|
|
{
|
|
return { x - v, y - v };
|
|
}
|
|
};
|
|
|
|
// class for 2D integer vector
|
|
class int_vec2
|
|
{
|
|
// public members
|
|
public:
|
|
// x and y coordinates
|
|
int x, y;
|
|
// operator functions
|
|
int_vec2 operator+(int_vec2 vec)
|
|
{
|
|
return { x + vec.x, y + vec.y };
|
|
}
|
|
int_vec2 operator*(int v)
|
|
{
|
|
return { x * v, y * v };
|
|
}
|
|
int_vec2 operator*(int_vec2 vec)
|
|
{
|
|
return { x * vec.x, y * vec.y };
|
|
}
|
|
int_vec2 operator-(int_vec2 vec)
|
|
{
|
|
return { x - vec.x, y - vec.y };
|
|
}
|
|
}; |