diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 20:08:09 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 20:08:09 +0100 |
commit | 1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (patch) | |
tree | 211505d5328f24c9f9beabf8f874d9e13ef92130 /src/crepe/api/Vector2.h | |
parent | 9df087ede0b539ecbd2778236c7d1143362b384d (diff) | |
parent | 3d2428af8e8d9d49b4ade52d4806a7dae4cf1ab8 (diff) |
merge `master` into `loek/savemgr`
Diffstat (limited to 'src/crepe/api/Vector2.h')
-rw-r--r-- | src/crepe/api/Vector2.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h new file mode 100644 index 0000000..741951b --- /dev/null +++ b/src/crepe/api/Vector2.h @@ -0,0 +1,47 @@ +#pragma once + +namespace crepe { + +//! Vector2 class +class Vector2 { +public: + //! X component of the vector + float x; + //! Y component of the vector + float y; + + //! Default constructor + Vector2() = default; + + //! Constructor with initial values + Vector2(float x, float y); + + //! Subtracts another vector from this vector and returns the result. + Vector2 operator-(const Vector2 & other) const; + + //! Adds another vector to this vector and returns the result. + Vector2 operator+(const Vector2 & other) const; + + //! Multiplies this vector by a scalar and returns the result. + Vector2 operator*(float scalar) const; + + //! Multiplies this vector by another vector element-wise and updates this vector. + Vector2 & operator*=(const Vector2 & other); + + //! Adds another vector to this vector and updates this vector. + Vector2 & operator+=(const Vector2 & other); + + //! Adds a scalar value to both components of this vector and updates this vector. + Vector2 & operator+=(float other); + + //! Returns the negation of this vector. + Vector2 operator-() const; + + //! Checks if this vector is equal to another vector. + bool operator==(const Vector2 & other) const; + + //! Checks if this vector is not equal to another vector. + bool operator!=(const Vector2 & other) const; +}; + +} // namespace crepe |