aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Vector2.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-11 20:49:55 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-11 20:49:55 +0100
commitf2e5b685fd1357b55beeea967b12b353c5d65fb5 (patch)
tree838aaa7aa89e9360215edaae52dfb76a7740d153 /src/crepe/api/Vector2.cpp
parent47dd27c42f375b65ee53f8b1e8c1b25327315a92 (diff)
fixed build issue
Diffstat (limited to 'src/crepe/api/Vector2.cpp')
-rw-r--r--src/crepe/api/Vector2.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/crepe/api/Vector2.cpp b/src/crepe/api/Vector2.cpp
index 09bb59b..947c49e 100644
--- a/src/crepe/api/Vector2.cpp
+++ b/src/crepe/api/Vector2.cpp
@@ -3,7 +3,7 @@
namespace crepe {
// Constructor with initial values
-Vector2::Vector2(float x, float y) : x(x), y(y) {}
+Vector2::Vector2(double x, double y) : x(x), y(y) {}
// Subtracts another vector from this vector and returns the result.
Vector2 Vector2::operator-(const Vector2 & other) const {
@@ -16,7 +16,7 @@ Vector2 Vector2::operator+(const Vector2 & other) const {
}
// Multiplies this vector by a scalar and returns the result.
-Vector2 Vector2::operator*(float scalar) const {
+Vector2 Vector2::operator*(double scalar) const {
return {x * scalar, y * scalar};
}
@@ -35,7 +35,7 @@ Vector2 & Vector2::operator+=(const Vector2 & other) {
}
// Adds a scalar value to both components of this vector and updates this vector.
-Vector2 & Vector2::operator+=(float other) {
+Vector2 & Vector2::operator+=(double other) {
x += other;
y += other;
return *this;
@@ -54,4 +54,8 @@ bool Vector2::operator!=(const Vector2 & other) const {
return !(*this == other);
}
+double Vector2::dot(const Vector2& other) const {
+ return this->x * other.x + this->y * other.y;
+}
+
} // namespace crepe